diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-16 22:58:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-16 22:58:15 +0000 |
commit | e05f609b61c23846ee21a24a97631d2364f55078 (patch) | |
tree | b71fb59e87fb66b9dbc2c85e0acde20be4cc27ed /autoconf | |
parent | f7e2bc80d1c645c347532f0847b77ed72b348e5a (diff) | |
download | external_llvm-e05f609b61c23846ee21a24a97631d2364f55078.zip external_llvm-e05f609b61c23846ee21a24a97631d2364f55078.tar.gz external_llvm-e05f609b61c23846ee21a24a97631d2364f55078.tar.bz2 |
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
Diffstat (limited to 'autoconf')
-rw-r--r-- | autoconf/configure.ac | 3 | ||||
-rw-r--r-- | autoconf/m4/link_options.m4 | 43 |
2 files changed, 46 insertions, 0 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 76083d2..49a140c 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1022,6 +1022,9 @@ AC_LINK_USE_R dnl Determine whether the linker supports the -export-dynamic option. AC_LINK_EXPORT_DYNAMIC +dnl Determine whether the linker supports the -retain-symbols-file option. +AC_LINK_RETAIN_SYMBOLS_FILE + dnl Check for libtool and the library that has dlopen function (which must come dnl before the AC_PROG_LIBTOOL check in order to enable dlopening libraries with dnl libtool). diff --git a/autoconf/m4/link_options.m4 b/autoconf/m4/link_options.m4 index 66036de..3442e46 100644 --- a/autoconf/m4/link_options.m4 +++ b/autoconf/m4/link_options.m4 @@ -39,3 +39,46 @@ if test "$llvm_cv_link_use_export_dynamic" = yes ; then fi ]) +# +# Determine if the system can handle the -retain-symbols-file option being +# passed to the linker. +# +# This macro is specific to LLVM. +# +AC_DEFUN([AC_LINK_RETAIN_SYMBOLS_FILE], +[AC_CACHE_CHECK([for compiler -Wl,-retain-symbols-file option], + [llvm_cv_link_use_retain_symbols_file], +[ AC_LANG_PUSH([C]) + oldcflags="$CFLAGS" + + # The following code is from the autoconf manual, + # "11.13: Limitations of Usual Tools". + # Create a temporary directory $tmp in $TMPDIR (default /tmp). + # Use mktemp if possible; otherwise fall back on mkdir, + # with $RANDOM to make collisions less likely. + : ${TMPDIR=/tmp} + { + tmp=` + (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null + ` && + test -n "$tmp" && test -d "$tmp" + } || { + tmp=$TMPDIR/foo$$-$RANDOM + (umask 077 && mkdir "$tmp") + } || exit $? + + echo "main" > "$tmp/exports" + + CFLAGS="$CFLAGS -Wl,-retain-symbols-file=$tmp/exports" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[int main() { return 0; }]])], + [llvm_cv_link_use_retain_symbols_file=yes],[llvm_cv_link_use_retain_symbols_file=no]) + rm "$tmp/exports" + rmdir "$tmp" + CFLAGS="$oldcflags" + AC_LANG_POP([C]) +]) +if test "$llvm_cv_link_use_retain_symbols_file" = yes ; then + AC_SUBST(HAVE_LINK_RETAIN_SYMBOLS_FILE,1) + fi +]) + |