blob: b48710c094d96dbcb5157bb13ebd3ca05c29b3f4 [file] [log] [blame]
Nick Lewycky18f99072009-03-05 08:20:21 +00001#
2# Determine if the system can handle the -R option being passed to the linker.
3#
4# This macro is specific to LLVM.
5#
6AC_DEFUN([AC_LINK_USE_R],
7[AC_CACHE_CHECK([for compiler -Wl,-R<path> option],[llvm_cv_link_use_r],
8[ AC_LANG_PUSH([C])
9 oldcflags="$CFLAGS"
10 CFLAGS="$CFLAGS -Wl,-R."
Dan Gohman39ed6782010-04-25 00:12:20 +000011 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
Nick Lewycky18f99072009-03-05 08:20:21 +000012 [llvm_cv_link_use_r=yes],[llvm_cv_link_use_r=no])
13 CFLAGS="$oldcflags"
14 AC_LANG_POP([C])
15])
16if test "$llvm_cv_link_use_r" = yes ; then
17 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.])
18 fi
19])
20
21#
22# Determine if the system can handle the -R option being passed to the linker.
23#
24# This macro is specific to LLVM.
25#
26AC_DEFUN([AC_LINK_EXPORT_DYNAMIC],
27[AC_CACHE_CHECK([for compiler -Wl,-export-dynamic option],
28 [llvm_cv_link_use_export_dynamic],
29[ AC_LANG_PUSH([C])
30 oldcflags="$CFLAGS"
31 CFLAGS="$CFLAGS -Wl,-export-dynamic"
Dan Gohman39ed6782010-04-25 00:12:20 +000032 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
Nick Lewycky18f99072009-03-05 08:20:21 +000033 [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no])
34 CFLAGS="$oldcflags"
35 AC_LANG_POP([C])
36])
37if test "$llvm_cv_link_use_export_dynamic" = yes ; then
38 AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -Wl,-export-dynamic.])
39 fi
40])
41
Dan Gohmane05f6092010-04-16 22:58:15 +000042#
Dan Gohmanda612d62010-06-01 14:56:56 +000043# Determine if the system can handle the --version-script option being
Dan Gohmane05f6092010-04-16 22:58:15 +000044# passed to the linker.
45#
46# This macro is specific to LLVM.
47#
Dan Gohmanda612d62010-06-01 14:56:56 +000048AC_DEFUN([AC_LINK_VERSION_SCRIPT],
49[AC_CACHE_CHECK([for compiler -Wl,--version-script option],
50 [llvm_cv_link_use_version_script],
Dan Gohmane05f6092010-04-16 22:58:15 +000051[ AC_LANG_PUSH([C])
52 oldcflags="$CFLAGS"
53
54 # The following code is from the autoconf manual,
55 # "11.13: Limitations of Usual Tools".
56 # Create a temporary directory $tmp in $TMPDIR (default /tmp).
57 # Use mktemp if possible; otherwise fall back on mkdir,
58 # with $RANDOM to make collisions less likely.
59 : ${TMPDIR=/tmp}
60 {
61 tmp=`
62 (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
63 ` &&
64 test -n "$tmp" && test -d "$tmp"
65 } || {
66 tmp=$TMPDIR/foo$$-$RANDOM
67 (umask 077 && mkdir "$tmp")
68 } || exit $?
69
Dan Gohmanda612d62010-06-01 14:56:56 +000070 echo "{" > "$tmp/export.map"
71 echo " global: main;" >> "$tmp/export.map"
72 echo " local: *;" >> "$tmp/export.map"
73 echo "};" >> "$tmp/export.map"
Dan Gohmane05f6092010-04-16 22:58:15 +000074
Dan Gohmanda612d62010-06-01 14:56:56 +000075 CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map"
Dan Gohman39ed6782010-04-25 00:12:20 +000076 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
Dan Gohman943005e2010-06-01 16:22:27 +000077 [llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no])
Dan Gohmanda612d62010-06-01 14:56:56 +000078 rm "$tmp/export.map"
Dan Gohmane05f6092010-04-16 22:58:15 +000079 rmdir "$tmp"
80 CFLAGS="$oldcflags"
81 AC_LANG_POP([C])
82])
Dan Gohmanda612d62010-06-01 14:56:56 +000083if test "$llvm_cv_link_use_version_script" = yes ; then
84 AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1)
Dan Gohmane05f6092010-04-16 22:58:15 +000085 fi
86])
87