Link error with GOLD linker
- I think we should add "pthread" to the list of extra-libs in "rts/package.conf.in" for the threaded RTS on UNIX-like host OSes.
- we should include MachDeps.h in "rts/package.conf.in"
Current master branch (2e8463b2) build is broken on my system[0]. When ghc-stage1 tries to produce ghc-stage2, I get:
/home/hsyl20/repo/ghc/rts/dist/build/libHSrts_thr-ghc8.1.20161107.so: error: undefined reference to 'pthread_create'
/home/hsyl20/repo/ghc/rts/dist/build/libHSrts_thr-ghc8.1.20161107.so: error: undefined reference to 'pthread_detach
(logs: http://pastebin.com/EbqEx6Gg )
I have tracked down the regression to the following recent commit: a977c965 If I revert this commit, it builds. However I think this commit has only revealed the bug: if I add "pthread" to the list of extra-libs in "rts/package.conf.in", it builds too. We already add it on freebsd and openbsd but not on Linux.
I think I have finally found out why other devs on #ghc haven't noticed this bug: my system uses the GOLD linker (because of #12748 (closed)), but if I switch back to the BFD linker, it builds without error.
While investigating this bug, I have noticed that linker flags for 64-bit atomic ops introduced by https://git.haskell.org/ghc.git/commitdiff/c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc aren't set while they should: WORD_SIZE_IN_BITS isn't defined because we don't include MachDeps.h
[0] x86-64, ArchLinux (Linux 4.8.6), GNU gold (GNU Binutils 2.27) 1.12, gcc (GCC) 6.2.1 20160830
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | high |
Resolution | Unresolved |
Component | Compiler (Linking) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |