-
Notifications
You must be signed in to change notification settings - Fork 483
Static compilation of rust binaries using musl #390
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
Comments
rules_rust/util/process_wrapper/system_posix.cc Lines 160 to 162 in 09ec54c
|
also |
sudo apt-get install musl-dev takes care of that error, but left me with:
|
I'm getting the same error, seems that edit: When running ldd on the
On Fedora 33, my libc.so is an ld script that looks in two places for static and dynamic libs, which I assume cannot be read properly for some reason. Changing this to a symlink to a 'correct' library (do not try this at home) and setting
We can now at least see the libs getting linked!
Seems that |
I have the same problem, and I try https://github.com/duarten/rust-bazel-cross. But it seems that it produces a non-static link binary. So is there any method to static link by using musl? |
I've been experimenting with cross-compiling to musl a bit but I reached a blocker when combining with cargo-raze. Currently For a trivial "hello world" you can work around this with patching rules_rust or by defining the toolchain manually like this: https://github.com/duarten/rust-bazel-cross/blob/main/build/toolchains/BUILD.bazel#L42 However, when using dependencies via cargo raze which require libc you get build files like this, and a bunch of errors about a missing libc crate dependency
The targets supported by cargo-raze are defined here https://github.com/google/cargo-raze/blob/main/impl/src/util.rs#L29, but since it implicitly depends on the platform existing in |
Is there any progress? I tried with the current version of rules_rust and still face the same issues... |
This PR provides documentation of Bazelmod and several code examples that addresses a number of issues related to Bazelmod. Preview of the documentation: https://github.com/marvin-hansen/rules_rust/blob/main/docs/crate_universe_bzlmod.md First and foremost it paves the way for a meaningful update the Bazelmod documentation that references these and existing code examples. This touches at least the following issues: * #2670 * #2181 The compile_opt example addresses or resolves: * #515 * #2701 The musl_cross_compilling example addresses or resolves * #390 * #276 The oci_container does not relate to any open issue, although the tokio example in it gives a nice end to end example so this definitely helps those looking for something non-trivial. The proto example addresses or resolves: * #2668 * #302 * #2534 * Possibly a few more if I were to search longer Formalities * I've signed the CLA * I've signed all commits --------- Signed-off-by: Marvin Hansen <[email protected]> Co-authored-by: Daniel Wagner-Hall <[email protected]>
Hiya, this is more a platform for discussion than anything else. I wanted to post this issue here because I'm interested in contributing to it, but I wanted some guidance first.
TL;DR: I'd like to be able to statically link rust binaries by compiling with musl.
Following the instructions here: https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html , it seems the
x86_64-unknown-linux-musl
target is what I should be using.I've tried compiling the
examples
workspace with the following:But this has resulted in output like the following:
Is this expected behavior? Where should I start looking if I was interested in adding support for compilation against this alternative C library?
The text was updated successfully, but these errors were encountered: