<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/137510>137510</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lld not creating fully statically linked binaries on Alpine Linux
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
benz0li
</td>
</tr>
</table>
<pre>
### 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`](https://quay.io/repository/benz0li/ghc-musl) (default linker: `ld.bfd`):
```shell
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
```
\---
```shell
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 linker](https://github.com/benz0li/ghc-musl/blob/dd801c1966902e1cac20db228a5fd1110cb8692c/dockerfiles/9.10.1.Dockerfile):
```shell
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)
```
\---
```shell
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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVkuP5CYQ_jX0pWQL8Pvgg-fh7EqziZSRZrWnCAO22aHBMbinO78-wu55bWY3ymkSKZLlpstQVV9VfZ9gzqnBSFmj7AJlVzu2-NHOdSfNH1irXWfFqUY02R74YpcZpDmo2Zq9NB7hBuHm86j4CL_cgrBwsgssTqKkhUZPyki4UWY5QhJTEicv9x_k7JQ1YHu4ubn79OIwMCNgtA8glFhtyjjPtAblg9-780FSxvBx-yIFLE6ZAVCO2XSPchxvoZ5Tvz5OknspoJMjOyi7zNuO63iIoVuUFuH86P3kUNIg2iLaDsqPSxdzu0e0_TqE98SMsPw5Gmcd07BMgnkJiOaI5rDZVp8QRdKwTstIHiVf_Lp0nnnFIYqGkUd28soaB4gWYa2jyY-zZALRArZgEdcK5RiUgdCkHP--sFOsLKLtuU0h1ZFH-8VplDRVTHBMImV8ZJhXB4lyjLIrRMvX6J7dzHKyTnk7n972SStAtBSyZ4v2oJW5lzNKmoBfi7jrRYhAq-B5q3qOt8eNUmuEGy0EINr6_fRUQkRboZyPjHxw_qRliBwqhmjL2MzHPI10mJxzHhuop9OhJlES53GKaHt86fTRyZPhvHiR1TdJrmPSatWFt1gRR-cUYmdjsiJ93-STBn62HhgcmFYCxMmwveIwzXaY2f4NbNllFEXfaUavtHxvQH_XjXcu9vVNC3kadcrDze0FPHMX0Utofv0E58Dh76OOkcCR2y-3d4EJ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