driver: unconditionally disable relaxation when linking partially
Concern Raised1cc9061fce42

Authored by trofi on Aug 21 2018, 2:08 PM.

Description

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

RyanGlScott raised a concern with this commit.Aug 21 2018, 7:12 PM
RyanGlScott added a subscriber: RyanGlScott.

This commit appears to have broken the build on master (at least, when you build from scratch). When building with make -j4, building base eventually fails with:

Panic! libraries/base/dist-install/build/GHC/Float.hi exists, but libraries/base/dist-install/build/GHC/Float.dyn_o does not.

See https://phabricator.haskell.org/harbormaster/build/51903/ for an example of this failure.

One can avoid this particular error by running make -j1, but even then base will eventually fail at the ar step:

"ar" q  libraries/base/dist-install/build/libHSbase-4.12.0.0.a @libraries/base/dist-install/build/libHSbase-4.12.0.0.a.contents 
ar: creating libraries/base/dist-install/build/libHSbase-4.12.0.0.a 
ar: libraries/base/dist-install/build/Control/Concurrent.o: No such file or directory

On top of all that, when building GHC, this commit appears to generate a 114K file called -relax, which isn't version-controlled and isn't listed under .gitignore (so it shows up under "Untracked files" when one runs git status).

This commit now has outstanding concerns.Aug 21 2018, 7:12 PM

I went ahead and reverted that commit for now in 44ba66527ae207ce2dd64eb2bce14656d474f6d1.