Limit the number of flags directly given to the linker, and refactor rpath

This will make things easier for MSVC support.
This commit is contained in:
Mike Hommey 2012-04-16 16:30:25 +02:00 committed by Jason Evans
parent 5bee66d3ed
commit fa08da752b
2 changed files with 10 additions and 18 deletions

View File

@ -33,23 +33,20 @@ O := @o@
A := @a@ A := @a@
EXE := @exe@ EXE := @exe@
LIB := @lib@ LIB := @lib@
ifeq (macho, @abi@)
WL_SONAME := dylib_install_name
else
WL_SONAME := soname
endif
REV := @rev@ REV := @rev@
install_suffix := @install_suffix@ install_suffix := @install_suffix@
ABI := @abi@ ABI := @abi@
XSLTPROC := @XSLTPROC@ XSLTPROC := @XSLTPROC@
AUTOCONF := @AUTOCONF@ AUTOCONF := @AUTOCONF@
RPATH := @RPATH@ _RPATH = @RPATH@
RPATH = $(if $(1),$(call _RPATH,$(1)))
cfghdrs_in := @cfghdrs_in@ cfghdrs_in := @cfghdrs_in@
cfghdrs_out := @cfghdrs_out@ cfghdrs_out := @cfghdrs_out@
cfgoutputs_in := @cfgoutputs_in@ cfgoutputs_in := @cfgoutputs_in@
cfgoutputs_out := @cfgoutputs_out@ cfgoutputs_out := @cfgoutputs_out@
enable_autogen := @enable_autogen@ enable_autogen := @enable_autogen@
enable_experimental := @enable_experimental@ enable_experimental := @enable_experimental@
DSO_LDFLAGS = @DSO_LDFLAGS@
ifeq (macho, $(ABI)) ifeq (macho, $(ABI))
TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib TEST_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(objroot)lib
@ -136,7 +133,7 @@ $(objroot)src/%.pic.$(O): $(srcroot)src/%.c
$(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) $(objroot)lib/$(LIBJEMALLOC).$(SO).$(REV) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
@mkdir -p $(@D) @mkdir -p $(@D)
$(CC) -shared -Wl,-$(WL_SONAME),$(@F) $(RPATH_EXTRA:%=$(RPATH)%) -o $@ $+ $(LDFLAGS) $(LIBS) $(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) -o $@ $+ $(LDFLAGS) $(LIBS)
$(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O)) $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(CSRCS:$(srcroot)%.c=$(objroot)%.pic.$(O))
@mkdir -p $(@D) @mkdir -p $(@D)
@ -154,11 +151,7 @@ $(objroot)test/%.$(O): $(srcroot)test/%.c
$(objroot)test/%$(EXE): $(objroot)test/%.$(O) \ $(objroot)test/%$(EXE): $(objroot)test/%.$(O) \
$(objroot)lib/$(LIBJEMALLOC).$(SO) $(objroot)lib/$(LIBJEMALLOC).$(SO)
@mkdir -p $(@D) @mkdir -p $(@D)
ifneq ($(RPATH), ) $(CC) -o $@ $< $(call RPATH,$(objroot)lib) -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
$(CC) -o $@ $< $(RPATH)$(objroot)lib -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
else
$(CC) -o $@ $< -L$(objroot)lib -ljemalloc$(install_suffix) $(LIBS)
endif
build_lib_shared: $(DSOS) build_lib_shared: $(DSOS)
build_lib_static: $(STATIC_LIBS) build_lib_static: $(STATIC_LIBS)

View File

@ -199,6 +199,8 @@ o="o"
a="a" a="a"
exe= exe=
lib="lib" lib="lib"
DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
RPATH='-Wl,-rpath,$(1)'
dnl Heap profiling uses the log(3) function. dnl Heap profiling uses the log(3) function.
LIBS="$LIBS -lm" LIBS="$LIBS -lm"
@ -220,12 +222,12 @@ case "${host}" in
LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
so="dylib" so="dylib"
force_tls="0" force_tls="0"
DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
;; ;;
*-*-freebsd*) *-*-freebsd*)
CFLAGS="$CFLAGS" CFLAGS="$CFLAGS"
abi="elf" abi="elf"
AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
RPATH="-Wl,-rpath,"
force_lazy_lock="1" force_lazy_lock="1"
;; ;;
*-*-linux*) *-*-linux*)
@ -234,7 +236,6 @@ case "${host}" in
abi="elf" abi="elf"
AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
RPATH="-Wl,-rpath,"
default_munmap="0" default_munmap="0"
;; ;;
*-*-netbsd*) *-*-netbsd*)
@ -250,12 +251,11 @@ case "${host}" in
[abi="aout"]) [abi="aout"])
AC_MSG_RESULT([$abi]) AC_MSG_RESULT([$abi])
AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
RPATH="-Wl,-rpath,"
;; ;;
*-*-solaris2*) *-*-solaris2*)
CFLAGS="$CFLAGS" CFLAGS="$CFLAGS"
abi="elf" abi="elf"
RPATH="-Wl,-R," RPATH='-Wl,-R,$(1)'
dnl Solaris needs this for sigwait(). dnl Solaris needs this for sigwait().
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
LIBS="$LIBS -lposix4 -lsocket -lnsl" LIBS="$LIBS -lposix4 -lsocket -lnsl"
@ -269,12 +269,10 @@ case "${host}" in
LD_PRELOAD_VAR="LDR_PRELOAD" LD_PRELOAD_VAR="LDR_PRELOAD"
fi fi
abi="xcoff" abi="xcoff"
RPATH="-Wl,-rpath,"
;; ;;
*) *)
AC_MSG_RESULT([Unsupported operating system: ${host}]) AC_MSG_RESULT([Unsupported operating system: ${host}])
abi="elf" abi="elf"
RPATH="-Wl,-rpath,"
;; ;;
esac esac
AC_SUBST([abi]) AC_SUBST([abi])
@ -285,6 +283,7 @@ AC_SUBST([o])
AC_SUBST([a]) AC_SUBST([a])
AC_SUBST([exe]) AC_SUBST([exe])
AC_SUBST([lib]) AC_SUBST([lib])
AC_SUBST([DSO_LDFLAGS])
JE_COMPILABLE([__attribute__ syntax], JE_COMPILABLE([__attribute__ syntax],
[static __attribute__((unused)) void foo(void){}], [static __attribute__((unused)) void foo(void){}],