Sample Header Ad - 728x90

How do I build a statically linked copy of xz-utils?

1 vote
1 answer
75 views
I'm trying to build a statically linked copy of xz-utils, such that the xz do not have dependencies on libc. I tried the usual way, which is to set LDFLAGS=-static, and works for most other packages out there. In the case of xz-utils, however, the binary is built successfully but it is statically linked, as can be seen here.
$ docker run --rm -it -v $PWD/downloads:/downloads --platform linux/amd64 alpine:3
/ # cd ~
~ # apk add build-base clang
...
~ # tar -xf /downloads/xz-5.8.1.tar.gz 
~ # PREFIX=/opt/xz-5.8.1
~ # cd xz-5.8.1/
~ # export CC=clang 
~ # export LDFLAGS=-static
~/xz-5.8.1 # LDFLAGS=-static CC=clang ./configure --prefix=$PREFIX --disable-nls --disable-doc --disable-microlzma
[See https://pastebin.com/Cj6ZX9sC] 
~/xz-5.8.1 # make -j4
[See https://pastebin.com/79wmN4zS] 
~/xz-5.8.1 # make install
[See https://pastebin.com/iCpCG3hQ] 
~/xz-5.8.1 # ldd /opt/xz-5.8.1/bin/xz
        /lib/ld-musl-x86_64.so.1 (0x7fe94c28b000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fe94c28b000)
How do I solve this?
Asked by rs3 (11 rep)
Apr 6, 2025, 02:32 PM
Last activity: Apr 6, 2025, 04:18 PM