Bug#1023649: ghc: FTBFS haskell-random powerpc (ghc Segmentation fault)

Ilias Tsitsimpis iliastsi at debian.org
Mon Oct 16 16:53:12 BST 2023


Hi Adrian,

On Sun, Oct 15, 2023 at 09:01PM, John Paul Adrian Glaubitz wrote:
> Unfortunately, we're running into another familiar problem which is a missing -latomic
> when building hadrian using the bootstrap.py script which does not take any build flags,
> the build of the »shake« package fails with the linker complaining about unresolved
> references to 64-bit atomic helper functions:
> 
> Linking /home/glaubitz/ghc18/ghc-9.4.7/hadrian/_build/dists/shake-0.19.4/build/shake/shake ...
> /usr/bin/ld: /usr/lib/ghc/rts/libHSrts_thr.a(STM.thr_o): in function `stmStartTransaction':
> (.text.stmStartTransaction+0xe4): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.stmStartTransaction+0xfc): undefined reference to `__atomic_store_8'
> /usr/bin/ld: /usr/lib/ghc/rts/libHSrts_thr.a(STM.thr_o): in function `stmCommitTransaction':
> (.text.stmCommitTransaction+0x40): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.stmCommitTransaction+0x118): undefined reference to `__atomic_load_8'
> /usr/bin/ld: /usr/lib/ghc/rts/libHSrts_thr.a(ThreadPaused.thr_o): in function `threadPaused':
> (.text.threadPaused+0x314): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.threadPaused+0x32c): undefined reference to `__atomic_store_8'
> /usr/bin/ld: /usr/lib/ghc/rts/libHSrts_thr.a(Threads.thr_o): in function `tryWakeupThread':
> (.text.tryWakeupThread+0x194): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.tryWakeupThread+0x1a8): undefined reference to `__atomic_store_8'
> /usr/bin/ld: (.text.tryWakeupThread+0x1c4): undefined reference to `__atomic_load_8'
> (...)
> /usr/bin/ld: (.text.throwToMsg+0x444): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.throwToMsg+0x458): undefined reference to `__atomic_store_8'
> /usr/bin/ld: (.text.throwToMsg+0x478): undefined reference to `__atomic_load_8'
> /usr/bin/ld: (.text.throwToMsg+0x490): undefined reference to `__atomic_store_8'
> /usr/bin/ld: /usr/lib/ghc/rts/libHSrts_thr.a(SpinLock.thr_o): in function `acquire_spin_lock_slow_path':
> (.text.acquire_spin_lock_slow_path+0x64): undefined reference to `__atomic_fetch_add_8'
> /usr/bin/ld: (.text.acquire_spin_lock_slow_path+0x80): undefined reference to `__atomic_fetch_add_8'
> collect2: error: ld returned 1 exit status
> `powerpc-linux-gnu-gcc' failed in phase `Linker'. (Exit code: 1)

This is a problem with your custom GHC (9.0.3). I believe you need to
use this patch as well [1], when building your custom GHC. I am
surprised this didn't fail during build time. Also, take a look at the
patches we have in Debian, there might be others that you need to use as
well.

[1] https://sources.debian.org/src/ghc/9.0.2-4/debian/patches/latomic-64bit/

> When building hadrian with "./hadrian/build -j", it's possible to pass the necessary
> "-latomic" with the help of "*.*.ghc.link.opts = -latomic". I assume, for the bootstrap
> python script, will have to patch either the Haskell sources or the Python script.

Note that "*.*.ghc.link.opts = -latomic" is parsed by hadrian itself,
it will not affect how hadrian is built. I haven't tested it but I
believe './hadrian/build -j "*.*.ghc.link.opts = -latomic"' will fail as
well in your case.

Best,

-- 
Ilias



More information about the Pkg-haskell-maintainers mailing list