-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
When building on Alpine (which is muslibc based), building Rust based RIOT applications fails:
--- stderr
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.60.1/src/lib.rs:2172:31
stack backtrace:
0: rust_begin_unwind
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/core/src/result.rs:1814:5
3: core::result::Result<T,E>::expect
4: core::ops::function::FnOnce::call_once
5: lazy_static::lazy::Lazy<T>::get::{{closure}}
6: std::sync::once::Once::call_once::{{closure}}
7: std::sync::once::Once::call_inner
at /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/library/std/src/sync/once.rs:434:21
8: std::sync::once::Once::call_once
9: <bindgen::ensure_libclang_is_loaded::LIBCLANG as core::ops::deref::Deref>::deref
10: bindgen::ensure_libclang_is_loaded
11: bindgen::Bindings::generate
12: bindgen::Builder::generate
13: build_script_build::main
14: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
make: *** [/tmp/RIOT/makefiles/cargo-targets.inc.mk:44: /tmp/RIOT/examples/rust-hello-world/bin/microbit-v2/target/thumbv7em-none-eabihf/release/librust_hello_world.a] Error 101
Reproducing
I've tested this inside the container set up per immunant/c2rust#724 with maribu's resolution (RUSTFLAGS=-Ctarget-feature=-crt-static cargo install --locked c2rust) with an extra of (the former is generally needed for RIOT, the latter target specific and make would have told us later anyway):
$ apk add git gcc-arm-none-eabi newlib-arm-none-eabi
$ rustup target add thumbv7em-none-eabihf
Then run (ideally after RIOT-OS/RIOT#18904 is in, or apply it manually):
$ make -C examples/rust-hello-world BOARD=microbit-v2
Towards fixing
When switching riot-sys's bindgen dependency to /static (btw, we don't really use the default features it seems...), the build script instead segfaults in a way similar to rust-lang/rust-bindgen#2333:
error: failed to run custom build command for `riot-sys v0.7.9 (/tmp/riot-sys)`
Caused by:
process didn't exit successfully: `/tmp/RIOT/examples/rust-hello-world/bin/microbit-v2/target/release/build/riot-sys-1835746e88917b5e/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
CC @maribu who originally found this.
[edit: more precise setup instructions]
Metadata
Metadata
Assignees
Labels
No labels