Commit 1cc9061f authored by Sergei Trofimovich's avatar Sergei Trofimovich

driver: unconditionally disable relaxation when linking partially

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:

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: default avatarSergei Trofimovich <>

Test Plan: pass -optl-Wl,--relax in test above

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:
parent 43b08cfb
......@@ -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
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