Commit 5ddb307e authored by Moritz Angermann's avatar Moritz Angermann

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
parent 8d4bce42
......@@ -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
])
......
......@@ -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?
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment