-
Notifications
You must be signed in to change notification settings - Fork 294
Description
I've tried installing c2rust on Alpine Linux, and run into build failures that could not be fixed just by adding new packages.
Reproducing
by means of Docker (but should be the same on any other virtualization or native):
$ docker run --rm -it --network=host alpine
$ apk update
$ apk add clang clang-libs cmake make clang llvm g++ gcc llvm13-dev llvm13-static musl-dev patch clang-dev patch clang-static rustup
$ apk add ncurses-dev zlib-dev libffi-dev
$ rustup-init
$ source $HOME/.cargo/env
$ cargo install --locked c2rust
The second apk line is not needed immediately, but at later stages after applying a patch.
(Alternatively, build from git -- same result).
Output
[...]
thread 'main' panicked at 'Unable to find libclang: "the `libclang` shared library at /usr/lib/libclang.so.13.0.1 could not be opened: Dynamic loading not supported"', /root/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2144:31
[...]
Further references
There is ongoing work to package c2rust for alpine, and @maribu has experimental fixes in a patch at https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/41287/diffs#diff-content-e7a5df424a0722085783354ec4640b08da0b9312 (essentially, building the bindgen dependency statically). When applying these, building continues a bit further (the second apk add line above installed the relevant dependencies), but then segfaults -- possibly due to statically and dynamically linked symbols being present at the same time. Maybe what it'd need here is a more general switch that makes everything either staticlally or dynamically linked, but I don't know how complicated that'd be.
(By the way, the referenced patches also manually apply the latest fixes to LLVM-15 (which can be dropped once #690 is done hint hint); the package aims at the edge release of alpine, whereas the above reproducing lines work on Alpine 3.16, which still has clang 13.)
wasmer had similar troubles at wasmerio/wasmer#1766 and fixed them differently in wasmerio/wasmer@5962d3f. Maybe that's a more fruitful approach, but I haven't really found out whether that's a real fix or it just disables something that'd break on musl.