GHC stage-2 build fails with "relocation R_X86_64_PC32 against `exitStaticPtrTable' can not be used when making a shared object"
On very old versions of CentOS (5.x) running GCC 4.1.2, GHC fails to build with the following error:
/usr/bin/ld: rts/dist/build/RtsStartup.dyn_o: relocation R_X86_64_PC32 against `exitStaticPtrTable' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
This appears to be caused by #pragma GCC visibility push(hidden) in BeginPrivate.h. Removing the HAS_VISIBILITY_HIDDEN macro from mk/config.h results in a successful build.
BeginPrivate.h contains a comment which seems to indicate similar problem occurs with GCC 4.2.1 on FreeBSD. I suggest that the #if directive in {Begin,End}Private.h be changed to cover both systems, by enabling visibility pragmas only on GCC versions higher than 4.2 as follows:
#if defined(HAS_VISIBLITY_HIDDEN) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)
Old versions of CentOS are still prolific in enterprise environments so it would be great for advocacy reasons to get that fix into the next release of GHC.
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |