Skip to content
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

Building a static binary for armv6 or lower causes a dynamic link to libatomic. #1779

Closed
BlackDex opened this issue Jan 7, 2023 · 2 comments · Fixed by #1780
Closed

Building a static binary for armv6 or lower causes a dynamic link to libatomic. #1779

BlackDex opened this issue Jan 7, 2023 · 2 comments · Fixed by #1780

Comments

@BlackDex
Copy link
Contributor

BlackDex commented Jan 7, 2023

Hello there,

I'm running into an issue building a static library using a custom static build OpenSSL v3.
When the CARGO_CFG_TARGET_POINTER_WIDTH is 32, it will always link dynamically to libatomic.

This causes my static musl builds to fail, because it suddenly has a dynamic link to libatomic.
For my builds i add a RUSTFLAGS which contain the path directly to this library, for example RUSTFLAGS='-Clink-arg=/usr/local/musl/arm-unknown-linux-musleabi/lib/libatomic.a -Clink-arg=-s'

I didn't need this for OpenSSL before, but more because of MiMalloc which also links to libatomic under water.

Is there some way that you can add some check or an extra env check to not dynamically link libatomic in some cases?
That would solve my compile issue.

@sfackler
Copy link
Owner

sfackler commented Jan 8, 2023

This may not be necessary anymore - the associated OpenSSL issue has been closed:

// https://github.com/openssl/openssl/pull/15086
if version == Version::Openssl3xx
&& kind == "static"
&& (env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux"
|| env::var("CARGO_CFG_TARGET_OS").unwrap() == "android")
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
{
println!("cargo:rustc-link-lib=dylib=atomic");
}

@BlackDex
Copy link
Contributor Author

BlackDex commented Jan 8, 2023

Ah! Well i can confirm that commenting that part out on a armv6 cross build seems to work just fine, even without the atomic link.

I still need to add the link for MiMalloc though, but that is out of the scope of this crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants