Skip to content

-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 in build(), not in prepare() -- this initially confused me into thinking that the issue was only in stack build vs stack setup, hence the initial report to stack 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 to prepare() to prebuild the dependencies without LDFLAGS 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:

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
Edited by Gesh
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information