-z pack-relative-relocs unsupported by ld.gold (sometimes picked as LD)
Description:
Haskell packages with C components, most significantly the GHC bindists, but also network, time, unix fail to configure when LDFLAGS
contains pack-relative-relocs
(ie since !6 (merged)).
This is especially noticeable in packages building Haskell tools statically using stack
, eg graphmod-git. If the appropriate ghc
is not installed in the stack cache, it will try to install the bindist there, which involves running ./configure
. When LDFLAGS
contains pack-relative-relocs
, this will failed to determine machine word size
.
Two confounding factors to consider for this case:
-
$XDG_DATA_HOME/stack
can't contain the appropriate GHC (or it won't exercise this codepath) -- this can be managed by setting--stack-root
to some temporary directory -
LDFLAGS
is only given the export attribute inbuild()
, not inprepare()
-- this initially confused me into thinking that the issue was only instack build
vsstack setup
, hence the initial report tostack
upstream, when this is more of a GHC+Arch Linux bug.Note this gives a workaround to this bug for now -- add
stack setup && stack build --only-dependencies
toprepare()
to prebuild the dependencies withoutLDFLAGS
set (since the root packages are generally less fragile in this respect than the dependencies)
In other cases, the problem is that ld.gold
doesn't support pack-relative-relocs
, but the package wants to link using it -- confirmed this is the case for network, see network.log.
Additional info:
- package version(s):
autoconf 2.72-1
,binutils 2.42-2
,pacman 6.1.0-3
(cabal
andstack
are provisioned throughghcup
and are red herrings here -- I can reproduce the errors manually, see manual-ghc.log) - config and/or log file: network.log stack-ghc.log manual-ghc.log
- link to upstream bug report, if any: ghc#24565 stack#6525 cabal#9828 previously raised here in a closed MR
Steps to reproduce:
In all of the below, first run export LDFLAGS='-Wl,-z,pack-relative-relocs'
-
For
manual-ghc.log
:aria2c --dir . 'https://downloads.haskell.org/~ghc/9.6.4/ghc-9.6.4-x86_64-fedora33-linux.tar.xz' --checksum=sha-256=6fd5574c66ecd67024de4cd6f1b3dd5d39dbe9abe10f627271ae0e322ad40fc8 --out ghc-9.6.4 tar xJf ghc-9.6.4 cd ghc-9.6.4-x86_64-unknown-linux ./configure
-
For
stack-ghc.log
:cd "$(mktemp -d)" stack setup --verbose --stack-root "$(mktemp -d)"
-
For
network.log
:git clone https://github.com/haskell/network cabal configure cabal build