Opened 3 years ago

Last modified 3 years ago

#11780 new bug

GHC stage-2 build fails with "relocation R_X86_64_PC32 against `exitStaticPtrTable' can not be used when making a shared object"

Reported by: zadarnowski Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.3
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: #10671 Differential Rev(s):
Wiki Page:


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.

Change History (1)

comment:1 Changed 3 years ago by thomie

How did you figure out it has anything to do with pragma GCC visibility push(hidden)?

Maybe you could submit a patch to Phabricator, so others can test it? Please include a source comment, explaining the situation.

Note: See TracTickets for help on using tickets.