summaryrefslogtreecommitdiff
path: root/aclocal.m4
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2017-05-11 18:12:33 +0800
committerMoritz Angermann <moritz.angermann@gmail.com>2017-05-11 18:31:24 +0800
commit5ddb307edf15c4d86e5c35c4063ec967424e19f2 (patch)
treec3eb1267950a43e582b5e83d8a48a7c250448998 /aclocal.m4
parent8d4bce42de7929b0dec7e7d68e66bcfc4d266322 (diff)
downloadhaskell-5ddb307edf15c4d86e5c35c4063ec967424e19f2.tar.gz
Do not hardcode the specific linker to use
This should be handled appropriately by a wrapper script around the compiler, if one wants to insist on the specific linker to be used. Otherwise this breaks if the used compiler fails to understand this directive. I believe that using a specific linker should be part of the compilers toolchain, we delegate to and not hardcoded here in ghc. Reviewers: dfeuer, erikd, hvr, austin, rwbarton, bgamari Reviewed By: bgamari Subscribers: snowleopard, davean, dfeuer, thomie, erikd Differential Revision: https://phabricator.haskell.org/D3351
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m437
1 files changed, 26 insertions, 11 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index d874d41730..32e55cd6ac 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -572,6 +572,7 @@ AC_DEFUN([FP_SET_CFLAGS_C99],
# $5 is the name of the CPP flags variable
AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
[
+ FIND_LD([$1],[UseLd])
AC_MSG_CHECKING([Setting up $2, $3, $4 and $5])
case $$1 in
i386-*)
@@ -610,18 +611,14 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
;;
arm*linux*)
# On arm/linux and arm/android, tell gcc to generate Arm
- # instructions (ie not Thumb) and to link using the gold linker.
- # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
+ # instructions (ie not Thumb).
$2="$$2 -marm"
- $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
+ $3="$$3 -Wl,-z,noexecstack"
$4="$$4 -z noexecstack"
;;
aarch64*linux*)
- # On aarch64/linux and aarch64/android, tell gcc to link using the
- # gold linker.
- # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
- $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
+ $3="$$3 -Wl,-z,noexecstack"
$4="$$4 -z noexecstack"
;;
@@ -642,6 +639,15 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
esac
+ case $UseLd in
+ *ld.gold)
+ $3="$$3 -fuse-ld=gold"
+ ;;
+ *ld.bfd)
+ $3="$$3 -fuse-ld=bfd"
+ ;;
+ esac
+
# If gcc knows about the stack protector, turn it off.
# Otherwise the stack-smash handler gets triggered.
echo 'int main(void) {return 0;}' > conftest.c
@@ -1991,11 +1997,12 @@ AC_DEFUN([FIND_LLVM_PROG],[
# Find the version of `ld` to use. This is used in both in the top level
# configure.ac and in distrib/configure.ac.in.
#
-# $1 = the variable to set
+# $1 = the platform
+# $2 = the variable to set
#
AC_DEFUN([FIND_LD],[
AC_CHECK_TARGET_TOOL([LD], [ld])
- case $target in
+ case $1 in
arm*linux* | \
aarch64*linux* )
# Arm and Aarch64 requires use of the binutils ld.gold linker.
@@ -2003,10 +2010,18 @@ AC_DEFUN([FIND_LD],[
# arm-linux-androideabi, arm64-unknown-linux and
# aarch64-linux-android
AC_CHECK_TARGET_TOOL([LD_GOLD], [ld.gold])
- $1="$LD_GOLD"
+ if test "$LD_GOLD" != ""; then
+ $2="$LD_GOLD"
+ elif test `$LD --version | grep -c "GNU gold"` -gt 0; then
+ AC_MSG_NOTICE([ld is ld.gold])
+ $2="$LD"
+ else
+ AC_MSG_WARN([could not find ld.gold, falling back to $LD])
+ $2="$LD"
+ fi
;;
*)
- $1="$LD"
+ $2="$LD"
;;
esac
])