[commit: ghc] ghc-7.10: Use the gold linker for linux/ARM and android/ARM targets. (a86fe8a)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 16:42:46 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/a86fe8a4602e8e57f3aff3f2bc78055a8fa8fe2e/ghc
>---------------------------------------------------------------
commit a86fe8a4602e8e57f3aff3f2bc78055a8fa8fe2e
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Thu Mar 12 14:36:50 2015 +1100
Use the gold linker for linux/ARM and android/ARM targets.
Fixes #8976 and #9873 by making use of the Binutils ld.gold
linker explicit whenever the target is linux/ARM or android/ARM.
This does not affect iOS where Apple provides its own linker.
In order to achieve this, we need to add `-fuse-ld=gold` to
the SettingsCCompilerLinkFlags setting and set
SettingsLdCommand to `ld.gold` (or `${target}-ld.gold` when
cross-compiling). In addition, simplifying the use of
`$(CONF_GCC_LINKER_OPTS_STAGEn)`.
This patch was tested by ensuring that the following worked
as expected:
* Native builds on linux/x86_64 (nothing changed).
* Native builds on linux/arm (and uses the gold linker).
* Linux to linux/arm cross compiles (and uses the cross
gold linker).
Contributions by Ben Gamari, Joachim Breitner and Reid Barton.
Reviewers: nomeata, bgamari, austin, rwbarton
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D715
GHC Trac Issues: #8976 #9873
(cherry picked from commit 71fcc4c096ec0b575522e4c2d0104ef7a71a13c5)
>---------------------------------------------------------------
a86fe8a4602e8e57f3aff3f2bc78055a8fa8fe2e
aclocal.m4 | 5 +++++
configure.ac | 13 ++++++++++++-
libffi/ghc.mk | 2 +-
mk/config.mk.in | 1 -
rules/build-package-data.mk | 2 +-
rules/distdir-opts.mk | 1 -
6 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 0cc9dcc..141a42d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -565,6 +565,11 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
$3="$$3 -D_HPUX_SOURCE"
$5="$$5 -D_HPUX_SOURCE"
;;
+ arm*linux*)
+ # On arm/linux and arm/android, tell gcc to link using the gold linker.
+ # Forcing LD to be ld.gold is done in configre.ac.
+ $3="$$3 -fuse-ld=gold"
+ ;;
esac
# If gcc knows about the stack protector, turn it off.
diff --git a/configure.ac b/configure.ac
index 689ebd8..b357f19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -489,7 +489,18 @@ FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
dnl ** Which ld to use?
dnl --------------------------------------------------------------
FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
-LdCmd="$LD"
+case $target in
+arm*linux*)
+ # Arm requires use of the binutils ld.gold linker.
+ # This case should catch at least arm-unknown-linux-gnueabihf and
+ # arm-linux-androideabi.
+ FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
+ LdCmd="$LD_GOLD"
+ ;;
+*)
+ LdCmd="$LD"
+ ;;
+esac
AC_SUBST([LdCmd])
dnl ** Which nm to use?
diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index abbe87f..a5645de 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -100,7 +100,7 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
NM=$(NM) \
RANLIB=$(REAL_RANLIB_CMD) \
CFLAGS="$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -w" \
- LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
+ LDFLAGS="$(SRC_LD_OPTS) -w" \
"$(SHELL)" ./configure \
--prefix=$(TOP)/libffi/build/inst \
--libdir=$(TOP)/libffi/build/inst/lib \
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 42720c8..49d8610 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -568,7 +568,6 @@ define set_stage_HSC2HS_OPTS
# $1 = stage
SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(filter-out -O,$$(SRC_CC_OPTS) $$(CONF_CC_OPTS_STAGE$1)))
SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --cflag=,$$(CONF_CPP_OPTS_STAGE$1))
-SRC_HSC2HS_OPTS_STAGE$1 += $$(addprefix --lflag=,$$(CONF_GCC_LINKER_OPTS_STAGE$1))
endef
$(eval $(call set_stage_HSC2HS_OPTS,0))
$(eval $(call set_stage_HSC2HS_OPTS,1))
diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk
index 494b89a..817bf8d 100644
--- a/rules/build-package-data.mk
+++ b/rules/build-package-data.mk
@@ -50,7 +50,7 @@ endif
# for a feature it may not generate warning-free C code, and thus may
# think that the feature doesn't exist if -Werror is on.
$1_$2_CONFIGURE_CFLAGS = $$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS) $$(SRC_CC_WARNING_OPTS)
-$1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$(CONF_GCC_LINKER_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)
+$1_$2_CONFIGURE_LDFLAGS = $$(SRC_LD_OPTS) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)
$1_$2_CONFIGURE_CPPFLAGS = $$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS)
$1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$($1_$2_CONFIGURE_CFLAGS)"
diff --git a/rules/distdir-opts.mk b/rules/distdir-opts.mk
index 3126a88..b2f0d1b 100644
--- a/rules/distdir-opts.mk
+++ b/rules/distdir-opts.mk
@@ -65,7 +65,6 @@ $1_$2_DIST_LD_LIB_DIRS := $$(subst $$(space)',$$(space)-L',$$(space)$$($1_$2_DEP
endif
$1_$2_DIST_LD_OPTS = \
- $$(CONF_GCC_LINKER_OPTS_STAGE$3) \
$$(SRC_LD_OPTS) \
$$($1_LD_OPTS) \
$$($1_$2_LD_OPTS) \
More information about the ghc-commits
mailing list