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 -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-\([^ ]*\)#\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 -R option being passed to the linker.
45 # This macro is specific to LLVM.
47 AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
48 [AC_CACHE_CHECK([for compiler -Wl,-export-dynamic option],
49 [llvm_cv_link_use_export_dynamic],
52 CFLAGS="$CFLAGS -Wl,-export-dynamic"
53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
54 [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
58 if test "$llvm_cv_link_use_export_dynamic" = yes ; then
59 AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -Wl,-export-dynamic.])
64 # Determine if the system can handle the --version-script option being
65 # passed to the linker.
67 # This macro is specific to LLVM.
69 AC_DEFUN([AC_LINK_VERSION_SCRIPT],
70 [AC_CACHE_CHECK([for compiler -Wl,--version-script option],
71 [llvm_cv_link_use_version_script],
75 # The following code is from the autoconf manual,
76 # "11.13: Limitations of Usual Tools".
77 # Create a temporary directory $tmp in $TMPDIR (default /tmp).
78 # Use mktemp if possible; otherwise fall back on mkdir,
79 # with $RANDOM to make collisions less likely.
83 (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
85 test -n "$tmp" && test -d "$tmp"
87 tmp=$TMPDIR/foo$$-$RANDOM
88 (umask 077 && mkdir "$tmp")
91 echo "{" > "$tmp/export.map"
92 echo " global: main;" >> "$tmp/export.map"
93 echo " local: *;" >> "$tmp/export.map"
94 echo "};" >> "$tmp/export.map"
96 CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map"
97 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
98 [llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no])
104 if test "$llvm_cv_link_use_version_script" = yes ; then
105 AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1)