[GHC] #12816: Link error with GOLD linker

GHC ghc-devs at haskell.org
Tue Nov 8 09:29:12 UTC 2016


#12816: Link error with GOLD linker
-------------------------------------+-------------------------------------
           Reporter:  hsyl20         |             Owner:
               Type:  bug            |            Status:  new
           Priority:  high           |         Milestone:  8.0.2
          Component:  Compiler       |           Version:  8.1
  (Linking)                          |
           Keywords:                 |  Operating System:  Linux
       Architecture:  x86_64         |   Type of failure:  Building GHC
  (amd64)                            |  failed
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 1. 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.
 2. we should include MachDeps.h in "rts/package.conf.in"

 Current master branch (2e8463b232054b788b73e6551947a9434aa76009) 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:
 a977c96537bb7077c6445f02db98636b150e6e14
 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), 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

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12816>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list