driver: pass '-fPIC' option to assembler as well

Authored by trofi on Aug 26 2014, 5:37 PM.



Before the patch '-fPIC' was passed only to C compiler,
but not to assembler itself.

It led to runtime crash in GHC_DYNAMIC_PROGRAMS=YES mode
on sparc32.

Technical details are in 'Note [-fPIC for assembler]'.

Signed-off-by: Sergei Trofimovich <>

Test Plan

validate on sparc

Diff Detail

rGHC Glasgow Haskell Compiler
Lint Skipped
Unit Tests Skipped
trofi updated this revision to Diff 442.Aug 26 2014, 5:37 PM
trofi retitled this revision from to driver: pass '-fPIC' option to assembler as well.
trofi updated this object.
trofi edited the test plan for this revision. (Show Details)
trofi added reviewers: simonmar, kgardas.
austin accepted this revision.Aug 27 2014, 11:47 AM
austin edited edge metadata.

Great find, LGTM! @kgardas, I'll assume you probably also want to look.

This revision is now accepted and ready to land.Aug 27 2014, 11:47 AM
kgardas edited edge metadata.Aug 27 2014, 12:06 PM

May this be the reason why building of HEAD in current setup fails on Solaris/SPARC and the only cure is to disable shared libs (as we did in 623883f1ed0ee11cc925c4590fb09565403fd231 to fix Trac #8857)? Perhaps. I'll certainly give it a try on my venerable T1 box now!

trofi added a comment.Aug 27 2014, 1:35 PM

To build ghc-HEAD on sparc as-is you will also need to do something with missing gcc builtins.
I worked around it as:

hs_atomic_add64(volatile StgWord64 *x, StgWord64 val)

  • return __sync_fetch_and_add(x, val);

+ //return __sync_fetch_and_add(x, val);
+ StgWord64 r = *x;
+ *x += val;
+ return r;

and so on.

trofi closed this revision.Aug 27 2014, 2:24 PM
trofi updated this revision to Diff 452.

Closed by commit rGHCa93ab43ab5f4 (authored by @trofi).

Verified that this fixes shared libs issue on sparc/solaris with unregisterised (currently only supported) build. At least build succeed and bindisttest Hello world is buildable in both static and dynamic forms. Great and thanks for the patch!