118f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 2ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar# Get the linker version string. 3ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar# 4ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar# This macro is specific to LLVM. 5ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar# 6ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel DunbarAC_DEFUN([AC_LINK_GET_VERSION], 7ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar [AC_CACHE_CHECK([for linker version],[llvm_cv_link_version], 8ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar [ 9ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar version_string="$(ld -v 2>&1 | head -1)" 10ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar 11ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar # Check for ld64. 12ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar if (echo "$version_string" | grep -q "ld64"); then 138b37637b7fd8a0af74d68d5f29c12ac285ef0e07Charles Davis llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)\( (.*)\)\{0,1\}#\1#") 14ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar else 15ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#") 16ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar fi 17ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar ]) 18ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version", 19ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar [Linker version detected at compile time.]) 20ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar]) 21ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar 22ee0f32d723431cdae943e8a8d45ecdb856a0e76cDaniel Dunbar# 2318f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# Determine if the system can handle the -R option being passed to the linker. 2418f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 2518f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# This macro is specific to LLVM. 2618f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 2718f99072a61429cc6aec9bd3dc611867819d962bNick LewyckyAC_DEFUN([AC_LINK_USE_R], 2818f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky[AC_CACHE_CHECK([for compiler -Wl,-R<path> option],[llvm_cv_link_use_r], 2918f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky[ AC_LANG_PUSH([C]) 3018f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky oldcflags="$CFLAGS" 3118f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky CFLAGS="$CFLAGS -Wl,-R." 3239ed6789c537ab6ec3d9b5944761e87c215f4fabDan Gohman AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], 3318f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky [llvm_cv_link_use_r=yes],[llvm_cv_link_use_r=no]) 3418f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky CFLAGS="$oldcflags" 3518f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky AC_LANG_POP([C]) 3618f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky]) 3718f99072a61429cc6aec9bd3dc611867819d962bNick Lewyckyif test "$llvm_cv_link_use_r" = yes ; then 3818f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky 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.]) 3918f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky fi 4018f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky]) 4118f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky 4218f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 4318f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# Determine if the system can handle the -R option being passed to the linker. 4418f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 4518f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# This macro is specific to LLVM. 4618f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky# 4718f99072a61429cc6aec9bd3dc611867819d962bNick LewyckyAC_DEFUN([AC_LINK_EXPORT_DYNAMIC], 4818f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky[AC_CACHE_CHECK([for compiler -Wl,-export-dynamic option], 4918f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky [llvm_cv_link_use_export_dynamic], 5018f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky[ AC_LANG_PUSH([C]) 5118f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky oldcflags="$CFLAGS" 5218f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky CFLAGS="$CFLAGS -Wl,-export-dynamic" 5339ed6789c537ab6ec3d9b5944761e87c215f4fabDan Gohman AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], 5418f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky [llvm_cv_link_use_export_dynamic=yes],[llvm_cv_link_use_export_dynamic=no]) 5518f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky CFLAGS="$oldcflags" 5618f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky AC_LANG_POP([C]) 5718f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky]) 5818f99072a61429cc6aec9bd3dc611867819d962bNick Lewyckyif test "$llvm_cv_link_use_export_dynamic" = yes ; then 5918f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky AC_DEFINE([HAVE_LINK_EXPORT_DYNAMIC],[1],[Define if you can use -Wl,-export-dynamic.]) 6018f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky fi 6118f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky]) 6218f99072a61429cc6aec9bd3dc611867819d962bNick Lewycky 63e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman# 64da612d62260220618af9be428aa827d5d04f344fDan Gohman# Determine if the system can handle the --version-script option being 65e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman# passed to the linker. 66e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman# 67e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman# This macro is specific to LLVM. 68e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman# 69da612d62260220618af9be428aa827d5d04f344fDan GohmanAC_DEFUN([AC_LINK_VERSION_SCRIPT], 70da612d62260220618af9be428aa827d5d04f344fDan Gohman[AC_CACHE_CHECK([for compiler -Wl,--version-script option], 71da612d62260220618af9be428aa827d5d04f344fDan Gohman [llvm_cv_link_use_version_script], 72e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman[ AC_LANG_PUSH([C]) 73e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman oldcflags="$CFLAGS" 74e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman 75e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman # The following code is from the autoconf manual, 76e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman # "11.13: Limitations of Usual Tools". 77e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman # Create a temporary directory $tmp in $TMPDIR (default /tmp). 78e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman # Use mktemp if possible; otherwise fall back on mkdir, 79e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman # with $RANDOM to make collisions less likely. 80e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman : ${TMPDIR=/tmp} 81e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman { 82e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman tmp=` 83e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null 84e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman ` && 85e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman test -n "$tmp" && test -d "$tmp" 86e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman } || { 87e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman tmp=$TMPDIR/foo$$-$RANDOM 88e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman (umask 077 && mkdir "$tmp") 89e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman } || exit $? 90e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman 91da612d62260220618af9be428aa827d5d04f344fDan Gohman echo "{" > "$tmp/export.map" 92da612d62260220618af9be428aa827d5d04f344fDan Gohman echo " global: main;" >> "$tmp/export.map" 93da612d62260220618af9be428aa827d5d04f344fDan Gohman echo " local: *;" >> "$tmp/export.map" 94da612d62260220618af9be428aa827d5d04f344fDan Gohman echo "};" >> "$tmp/export.map" 95e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman 96da612d62260220618af9be428aa827d5d04f344fDan Gohman CFLAGS="$CFLAGS -Wl,--version-script=$tmp/export.map" 9739ed6789c537ab6ec3d9b5944761e87c215f4fabDan Gohman AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], 98943005e09482f47619cc1345320df359c6c3021eDan Gohman [llvm_cv_link_use_version_script=yes],[llvm_cv_link_use_version_script=no]) 99da612d62260220618af9be428aa827d5d04f344fDan Gohman rm "$tmp/export.map" 100e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman rmdir "$tmp" 101e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman CFLAGS="$oldcflags" 102e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman AC_LANG_POP([C]) 103e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman]) 104da612d62260220618af9be428aa827d5d04f344fDan Gohmanif test "$llvm_cv_link_use_version_script" = yes ; then 105da612d62260220618af9be428aa827d5d04f344fDan Gohman AC_SUBST(HAVE_LINK_VERSION_SCRIPT,1) 106e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman fi 107e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman]) 108e05f609b61c23846ee21a24a97631d2364f55078Dan Gohman 109