diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2017-05-11 18:12:33 +0800 |
---|---|---|
committer | Moritz Angermann <moritz.angermann@gmail.com> | 2017-05-11 18:31:24 +0800 |
commit | 5ddb307edf15c4d86e5c35c4063ec967424e19f2 (patch) | |
tree | c3eb1267950a43e582b5e83d8a48a7c250448998 | |
parent | 8d4bce42de7929b0dec7e7d68e66bcfc4d266322 (diff) | |
download | haskell-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
-rw-r--r-- | aclocal.m4 | 37 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | distrib/configure.ac.in | 2 |
3 files changed, 28 insertions, 13 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 ]) diff --git a/configure.ac b/configure.ac index 0a0f79006d..73ee64d8ec 100644 --- a/configure.ac +++ b/configure.ac @@ -497,7 +497,7 @@ FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) dnl ** Which ld to use? dnl -------------------------------------------------------------- -FIND_LD([LdCmd]) +FIND_LD([$target],[LdCmd]) AC_SUBST([LdCmd]) dnl ** Which nm to use? diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index ffa057449d..cea3c493e9 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -86,7 +86,7 @@ AC_SUBST([OptCmd]) dnl ** Which ld to use? dnl -------------------------------------------------------------- -FIND_LD([LdCmd]) +FIND_LD([$target],[LdCmd]) AC_SUBST([LdCmd]) FP_GCC_VERSION |