2 # Get the linker version string.
4 # This macro is specific to LLVM.
6 AC_DEFUN([AC_LINK_GET_VERSION],
7 [AC_CACHE_CHECK([for linker version],[llvm_cv_link_version],
9 version_string="$(${LD:-ld} -v 2>&1 | head -1)"
12 if (echo "$version_string" | grep -q "ld64"); then
13 llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)\( (.*)\)\{0,1\}#\1#")
15 llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#")
18 AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version",
19 [Linker version detected at compile time.])
23 # Determine if the system can handle the -R option being passed to the linker.
25 # This macro is specific to LLVM.
27 AC_DEFUN([AC_LINK_USE_R],
28 [AC_CACHE_CHECK([for compiler -Wl,-R<path> option],[llvm_cv_link_use_r],
31 CFLAGS="$CFLAGS -Wl,-R."
32 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
33 [llvm_cv_link_use_r=yes],[llvm_cv_link_use_r=no])
37 if test "$llvm_cv_link_use_r" = yes ; then
38 AC_DEFINE([HAVE_LINK_R],[1],[Define if you can use -Wl,-R. to pass -R. to the linker, in order to add the current directory to the dynamic linker search path.])
43 # Determine if the system can handle the -rdynamic option being passed
46 # This macro is specific to LLVM.
48 AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
49 [AC_CACHE_CHECK([for compiler -rdynamic option],
50 [llvm_cv_link_use_export_dynamic],
53 CFLAGS="$CFLAGS -rdynamic"
54 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
55 [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
59 if test "$llvm_cv_link_use_export_dynamic" = yes ; then
60 AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -rdynamic.])
65 # Determine if the system can handle the --version-script option being
66 # passed to the linker.
68 # This macro is specific to LLVM.
70 AC_DEFUN([AC_LINK_VERSION_SCRIPT],
71 [AC_CACHE_CHECK([for compiler -Wl,--version-script option],
72 [llvm_cv_link_use_version_script],
76 # The following code is from the autoconf manual,
77 # "11.13: Limitations of Usual Tools".
78 # Create a temporary directory $tmp in $TMPDIR (default /tmp).
79 # Use mktemp if possible; otherwise fall back on mkdir,
80 # with $RANDOM to make collisions less likely.
84 (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
86 test -n "$tmp" && test -d "$tmp"
88 tmp=$TMPDIR/foo$$-$RANDOM
89 (umask 077 && mkdir "$tmp")
92 echo "{" > "$tmp/export.map"
93 echo " global: main;" >> "$tmp/export.map"
94 echo " local: *;" >> "$tmp/export.map"
95 echo "};" >> "$tmp/export.map"
97 CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map"
98 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
99 [llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no])
105 if test "$llvm_cv_link_use_version_script" = yes ; then
106 AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1)