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

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

Details

Summary

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 <slyfox@gentoo.org>

Test Plan

validate on sparc

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Lint Skipped
Unit
Unit Tests Skipped
trofi retitled this revision from to driver: pass '-fPIC' option to assembler as well.Aug 26 2014, 5:37 PM
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

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

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:

StgWord64
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!