[commit: ghc] master: driver: unconditionally disable relaxation when linking partially (1cc9061)
git at git.haskell.org
git at git.haskell.org
Tue Aug 21 19:10:47 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/1cc9061fce4270739677d475190fd6e890e8b1f9/ghc
>---------------------------------------------------------------
commit 1cc9061fce4270739677d475190fd6e890e8b1f9
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date: Tue Aug 21 20:08:42 2018 +0100
driver: unconditionally disable relaxation when linking partially
In https://github.com/gentoo-haskell/gentoo-haskell/issues/704
user explicitly uses -Wl,--relax for most built binaries.
Most of the time this works fine except for capi haskell code
similar to the following:
```haskell
{-# LANGUAGE CApiFFI #-}
module Z where
import Foreign.C
foreign import capi "unistd.h close" c_close :: CInt -> IO CInt
```
In this case compilation fails as:
```
$ inplace/bin/ghc-stage2 -c Z.hs -optl-Wl,--relax -fforce-recomp
ld: --relax and -r may not be used together
```
GHC's driver already disables relaxation on sparc as there relaxation
is already a default mode.
This change disables relaxation on partial linking for all platforms
where linker is binutils linker.
Reported-by: wmyrda
Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/704
Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
Test Plan: pass -optl-Wl,--relax in test above
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4888
>---------------------------------------------------------------
1cc9061fce4270739677d475190fd6e890e8b1f9
compiler/main/DriverPipeline.hs | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 94a0a31..68f69fc 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2169,12 +2169,11 @@ joinObjectFiles dflags o_files output_fn = do
++ (if osInfo == OSFreeBSD
then [SysTools.Option "-L/usr/lib"]
else [])
- -- gcc on sparc sets -Wl,--relax implicitly, but
- -- -r and --relax are incompatible for ld, so
+ -- gcc on sparc sets -Wl,--relax implicitly (another
+ -- use case is when use passes -optl-Wl,--relax)
+ -- but -r and --relax are incompatible for ld, so
-- disable --relax explicitly.
- ++ (if platformArch (targetPlatform dflags)
- `elem` [ArchSPARC, ArchSPARC64]
- && ldIsGnuLd
+ ++ (if ldIsGnuLd
then [SysTools.Option "-Wl,-no-relax"]
else [])
++ map SysTools.Option ld_build_id
More information about the ghc-commits
mailing list