[commit: ghc] master: Do not hardcode the specific linker to use (5ddb307)
git at git.haskell.org
git at git.haskell.org
Thu May 11 13:00:54 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/5ddb307edf15c4d86e5c35c4063ec967424e19f2/ghc
>---------------------------------------------------------------
commit 5ddb307edf15c4d86e5c35c4063ec967424e19f2
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date: Thu May 11 18:12:33 2017 +0800
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
>---------------------------------------------------------------
5ddb307edf15c4d86e5c35c4063ec967424e19f2
aclocal.m4 | 37 ++++++++++++++++++++++++++-----------
configure.ac | 2 +-
distrib/configure.ac.in | 2 +-
3 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index d874d41..32e55cd 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 0a0f790..73ee64d 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 ffa0574..cea3c49 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
More information about the ghc-commits
mailing list