-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Error "cannot find -lunwind" when compiling static mips-unknown-linux-musl
#120655
Comments
@rustbot label -O-MIPS -O-musl -Zbuild-std |
@rustbot label +O-MIPS +O-musl |
libunwind is still required for aborting panics, because those still print backtraces. The std feature So I suppose there's a question of what you want to achieve here: Do you want a working |
I guess I'm less concerned about I'm more concerned (if that's the right word) about how to resolve the library path errors when cross-compiling and what rustc expects of me when using I'm not sure about "do you want a build that doesn't depend on libunwind", although I guess with |
This issue is timely for me because I'm doing the exact workflow as described above and getting the same results. I am also using https://github.com/richfelker/musl-cross-make to build a musl compiler, with the major difference for me that I'm targeting a different tier 3 platform, The project I'm trying to build is sccache.
[target.s390x-unknown-linux-musl]
rustflags = [
"-C", "target-feature=+crt-static",
"-C", "panic=abort",
"-L/opt/s390x-linux-musl/s390x-linux-musl/lib",
"-L/opt/s390x-linux-musl/lib/gcc/s390x-linux-musl/9.4.0/"
]
linker = "s390x-linux-musl-gcc"
ar = "s390x-linux-musl-gcc-ar"
[profile.release]
codegen-units = 1
lto = true
strip = true
panic = "abort"
export PATH="/opt/s390x-linux-musl/bin/:$PATH"
cargo build -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort --locked --bin sccache --features=openssl/vendored
I'm pretty new to the Rust ecosystem and most of my configuration in |
@aroberts87 fyi, |
Another question, for I guess with LTO and |
libc and libunwind for musl targets are packed in the rust-std component for the respective target, which for tier 3 targets doesn't exist at all. With panic=abort we still need libunwind for generating backtraces (which is what |
Is this a problem for every tier 3 target with std support? If not, how do they build libunwind? |
I think this is the file that introduces that The I see musl is special-cased in both places. I don't know why. |
This might be related to #61367 |
I guess if I could optionally pick to use my
|
I'm having these same issues. I'm racking my brain trying to figure out HOW rust is basically useless on mips with either uclibc (no method named |
There are a few problems: LLVM does not have a reliable MIPS backend, so we cannot have MIPS CI, or all work on the compiler and library grinds to a halt whenever a new LLVM MIPS bug is discovered. This happened enough for MIPS bugs to become a meme. We didn't just demote the targets immediately, we demoted them after the amount of pain was so high that everyone we relieved to see it happen. rust-lang/compiler-team#648 Most of the MIPS targets do not even have a target maintainer. Those, if they exist, are documented here: https://doc.rust-lang.org/nightly/rustc/platform-support.html. There are some other |
To be clear, my frustration isn't without understanding. I've been reading about the lack of LLVM support for MIPS and know there is only so much the compiler team can do. |
I forgot to copy paste a solution I found in
|
I don't get an error with building or running the Hello World testcase. I compiled Rust project with the following
I got to this config by consulting the
As you can see, nothing much was changed, I just found additional values that must be set in the |
I am using https://github.com/richfelker/musl-cross-make to generate a
mips-linux-musl
compiler to buildmips-unknown-linux-musl
, as it's tier 3 and needs-Zbuild-std
.First off, I needed to add a couple of
-L
to the config, in order to not haveCould not find crt0
problems. I don't know if this is a rustc bug, or a cross-compiler bug.However, the bug that I can't figure out, is that for static binaries(and/or
panic=abort
) it still needs the-lunwind
library. Nevertheless, It seems like this should be something it finds from the~/.rustup/toolchains/
, but nothing I try helpsrustc
find this library?I tried this code:
src/main.rs
:Cargo.toml
:.cargo/config
:I expected to see this happen: Statically compiled mips-musl binary with
-Zbuild-std
Instead, this happened:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: