Link with -rdynamic instead of -Wl,-export-dynamic.
[oota-llvm.git] / autoconf / m4 / link_options.m4
index b48710c094d96dbcb5157bb13ebd3ca05c29b3f4..b58d61745f97028ee10444e5f0f865872901d419 100644 (file)
@@ -1,3 +1,24 @@
+#
+# Get the linker version string.
+#
+# This macro is specific to LLVM.
+#
+AC_DEFUN([AC_LINK_GET_VERSION],
+  [AC_CACHE_CHECK([for linker version],[llvm_cv_link_version],
+  [
+   version_string="$(ld -v 2>&1 | head -1)"
+
+   # Check for ld64.
+   if (echo "$version_string" | grep -q "ld64"); then
+     llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)\( (.*)\)\{0,1\}#\1#")
+   else
+     llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#")
+   fi
+  ])
+  AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version",
+                     [Linker version detected at compile time.])
+])
+
 #
 # Determine if the system can handle the -R option being passed to the linker.
 #
@@ -19,23 +40,24 @@ if test "$llvm_cv_link_use_r" = yes ; then
 ])
 
 #
-# Determine if the system can handle the -R option being passed to the linker.
+# Determine if the system can handle the -rdynamic option being passed
+# to the compiler.
 #
 # This macro is specific to LLVM.
 #
 AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
-[AC_CACHE_CHECK([for compiler -Wl,-export-dynamic option],
+[AC_CACHE_CHECK([for compiler -rdynamic option],
                 [llvm_cv_link_use_export_dynamic],
 [ AC_LANG_PUSH([C])
   oldcflags="$CFLAGS"
-  CFLAGS="$CFLAGS -Wl,-export-dynamic"
+  CFLAGS="$CFLAGS -rdynamic"
   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
     [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
   CFLAGS="$oldcflags"
   AC_LANG_POP([C])
 ])
 if test "$llvm_cv_link_use_export_dynamic" = yes ; then
-  AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -Wl,-export-dynamic.])
+  AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -rdynamic.])
   fi
 ])