llvm.org GIT mirror llvm / e05f609
Add an autoconf check for -retain-symbols-file and conditionalize use of that option with it. This eliminates an imprecise "Linux" test, and should help support old versions of gold. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101560 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
4 changed file(s) with 58 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
336336 NO_MISSING_FIELD_INITIALIZERS = @NO_MISSING_FIELD_INITIALIZERS@
337337 # -Wno-variadic-macros
338338 NO_VARIADIC_MACROS = @NO_VARIADIC_MACROS@
339
340 # Flags supported by the linker.
341 # bfd ld / gold -retain-symbols-file file
342 HAVE_LINK_RETAIN_SYMBOLS_FILE = @HAVE_LINK_RETAIN_SYMBOLS_FILE@
560560 # Get "4" out of 10.4 for later pieces in the makefile.
561561 DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/')
562562
563 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress \
563 SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined,suppress \
564564 -dynamiclib
565565 ifneq ($(ARCH),ARM)
566566 SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION)
989989 # Now add the linker command-line options to use the native export file.
990990
991991 ifeq ($(HOST_OS),Darwin)
992 LLVMLibsOptions += -Wl,-exported_symbols_list -Wl,$(NativeExportsFile)
993 endif
994
995 # This isn't really Linux-specific; it works at least on gold and bfd ld, but
996 # there's no convenient way to detect it.
997 ifeq ($(HOST_OS),Linux)
998 LLVMLibsOptions += -Wl,-retain-symbols-file -Wl,$(NativeExportsFile)
992 LLVMLibsOptions += -Wl,-exported_symbols_list,$(NativeExportsFile)
993 endif
994
995 # gold, bfd ld, etc.
996 ifeq ($(HAVE_LINK_RETAIN_SYMBOLS_FILE),1)
997 LLVMLibsOptions += -Wl,-retain-symbols-file,$(NativeExportsFile)
999998 endif
1000999
10011000 endif
12961295
12971296 # Tiger tools don't support this.
12981297 ifneq ($(DARWIN_MAJVERS),4)
1299 LD.Flags += -Wl,-exported_symbol -Wl,_main
1298 LD.Flags += -Wl,-exported_symbol,_main
13001299 endif
13011300 endif
13021301
10211021 dnl Determine whether the linker supports the -export-dynamic option.
10221022 AC_LINK_EXPORT_DYNAMIC
10231023
1024 dnl Determine whether the linker supports the -retain-symbols-file option.
1025 AC_LINK_RETAIN_SYMBOLS_FILE
1026
10241027 dnl Check for libtool and the library that has dlopen function (which must come
10251028 dnl before the AC_PROG_LIBTOOL check in order to enable dlopening libraries with
10261029 dnl libtool).
3838 fi
3939 ])
4040
41 #
42 # Determine if the system can handle the -retain-symbols-file option being
43 # passed to the linker.
44 #
45 # This macro is specific to LLVM.
46 #
47 AC_DEFUN([AC_LINK_RETAIN_SYMBOLS_FILE],
48 [AC_CACHE_CHECK([for compiler -Wl,-retain-symbols-file option],
49 [llvm_cv_link_use_retain_symbols_file],
50 [ AC_LANG_PUSH([C])
51 oldcflags="$CFLAGS"
52
53 # The following code is from the autoconf manual,
54 # "11.13: Limitations of Usual Tools".
55 # Create a temporary directory $tmp in $TMPDIR (default /tmp).
56 # Use mktemp if possible; otherwise fall back on mkdir,
57 # with $RANDOM to make collisions less likely.
58 : ${TMPDIR=/tmp}
59 {
60 tmp=`
61 (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
62 ` &&
63 test -n "$tmp" && test -d "$tmp"
64 } || {
65 tmp=$TMPDIR/foo$$-$RANDOM
66 (umask 077 && mkdir "$tmp")
67 } || exit $?
68
69 echo "main" > "$tmp/exports"
70
71 CFLAGS="$CFLAGS -Wl,-retain-symbols-file=$tmp/exports"
72 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[int main() { return 0; }]])],
73 [llvm_cv_link_use_retain_symbols_file=yes],[llvm_cv_link_use_retain_symbols_file=no])
74 rm "$tmp/exports"
75 rmdir "$tmp"
76 CFLAGS="$oldcflags"
77 AC_LANG_POP([C])
78 ])
79 if test "$llvm_cv_link_use_retain_symbols_file" = yes ; then
80 AC_SUBST(HAVE_LINK_RETAIN_SYMBOLS_FILE,1)
81 fi
82 ])
83