Skip to content

Commit fec94eb

Browse files
committed
fix(docker): allow build scripts to dlopen libclang in Alpine musl
In Alpine, Rust build scripts are compiled for the musl host target which defaults to static linking. Static musl binaries cannot dlopen, causing bindgen to fail when loading libclang.so for z3 FFI generation. Set CARGO_HOST_RUSTFLAGS="-C target-feature=-crt-static" so build scripts are dynamically linked (can dlopen) while the target CLI binary stays static.
1 parent e7bdfad commit fec94eb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

deploy/docker/Dockerfile.cli-musl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ ARG CARGO_TARGET_CACHE_SCOPE=default
1717

1818
ENV PATH="/usr/local/cargo/bin:${PATH}"
1919
ENV LIBCLANG_PATH="/usr/lib"
20+
# Build scripts (build.rs) are compiled for the host, which in Alpine defaults
21+
# to static musl linking. Static musl binaries cannot dlopen, so bindgen fails
22+
# to load libclang.so. Disabling crt-static for host builds makes build scripts
23+
# dynamically linked while keeping the target CLI binary fully static.
24+
ENV CARGO_HOST_RUSTFLAGS="-C target-feature=-crt-static"
2025

2126
WORKDIR /build
2227

0 commit comments

Comments
 (0)