Skip to content

[lld] Not creating fully statically linked binaries on Alpine Linux #137510

Closed
@benz0li

Description

@benz0li

Your environment

Which OS do you use? Alpine Linux 3.21.3

Which version of LLVM do you use and how did you install it? Version 18. Installed using apk.

Expected behaviour

E.g. building https://github.com/jgm/pandoc using cabal update && cabal build --enable-executable-static --ghc-options '-optl-pthread' pandoc-cli in quay.io/benz0li/ghc-musl:9.10.1-int-native (big-integer backend: native; default linker: ld.bfd):

ldd /tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc
/lib/ld-musl-aarch64.so.1: /tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc: Not a valid dynamic program

---

file /tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc
/tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=0f5f5dfdb712dcea7d9322a55303eb37486d114d, with debug_info, not stripped

Actual behaviour

When using a GHC musl image with ld.lld as default linker1:

ldd /tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc
	/lib/ld-musl-aarch64.so.1 (0xffff9e133000)

---

file /tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc
/tmp/pandoc/dist-newstyle/build/aarch64-linux/ghc-9.10.1/pandoc-cli-3.6.4/x/pandoc/build/pandoc/pandoc: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[xxHash]=a31bd72d4c384ddd, with debug_info, not stripped

Footnotes

  1. docker build --build-arg GHC_NATIVE_BIGNUM=1 -t ghc-musl:9.10.1-int-native-lld -f dockerfiles/9.10.1.Dockerfile .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions