summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2018-08-21 20:08:42 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2018-08-21 20:09:08 +0100
commit1cc9061fce4270739677d475190fd6e890e8b1f9 (patch)
treec019ee9e07142f85a04631d917f878b847e367fc /compiler/main
parent43b08cfbac5ce7ad6fc245651329094896de06e0 (diff)
downloadhaskell-1cc9061fce4270739677d475190fd6e890e8b1f9.tar.gz
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@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
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DriverPipeline.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 94a0a31887..68f69fc707 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