-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: allow static linking to libasound #10
Comments
A quick googling yields this result, might be helpful? https://stackoverflow.com/questions/61934997/undefined-reference-to-stat-time64-when-cross-compiling-rust-project-on-mu |
Thanks for the pointer! This suggests that changing I am building with Buildroot 2021.08, which has Musl 1.22 and Rust 1.54. I have just spotted that Buildroot doesn't build the rust-std libraries itself, it downloads them from https://static.rust-lang.org/dist/rust-std-1.54.0-armv7-unknown-linux-musleabihf.tar.xz and looking at the contained In which case, while alsa-sys could add support for static linking now, it might not be useful until rust-lang/rust#72274 is completed. |
Feel free to add a PR that adds support for static linking, I suppose this would be implemented as a feature not enabled by default? |
Right, I wasn't sure how to do this, but a feature flag makes sense. When I get some time I will do a PR. |
any updates on this? |
abandon trying to compile to musl, the alsa-sys crate does not support static linking so that's a bust diwic/alsa-sys#10
@AnthonyMichaelTDM Not to my knowledge. The other binding I maintain - https://github.com/diwic/dbus-rs - someone contributed a way to download the libdbus C code and cross compile it with the rest of the code. That might be an option here as well, if someone wants to do the work? |
This worked for me: sudo apt-get install crossbuild-essential-arm64 clang
rustup target add aarch64-unknown-linux-gnu
PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo buil
d --target aarch64-unknown-linux-gnu |
I am trying to build an embedded audio project using cpal, alsa-rs and alsa-sys. The target OS has an old GLibc and it might be tricky to upgrade. Building a static linked binary would be ideal.
At present alsa-sys hardwires
statik(false)
in build.rs so there's no way to static link.I experimented with changing this to
static(true)
and building with armv7-unknown-linux-musleabihf toolchain. Something goes wrong with the link at this point, and various link errors appear like these:I experimented with adding
-lc
or removing-nodefaultlibs
from the generated linkline and got other errors suggesting double linking against libc.This is the limit of my expertise, just reporting the issue in case someone else has been looking into the same thing.
The text was updated successfully, but these errors were encountered: