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

aarch64-unknown-linux-musl use -lunwind, but my embedded system has no unwind #118400

Closed
Sword-Destiny opened this issue Nov 28, 2023 · 5 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-linux Operating system: Linux O-musl Target: The musl libc

Comments

@Sword-Destiny
Copy link
Contributor

I got error when cross compile aarch64-unknown-linux-musl target。

          ld.lld: error: unable to find library -lunwind
          clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

my embedded system have no unwind lib

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 28, 2023
@Sword-Destiny
Copy link
Contributor Author

I set panic = "abort" in Cargo.toml, why still -lunwind exists?

@Jules-Bertholet
Copy link
Contributor

@rustbot label A-linkage C-bug O-AArch64 O-linux O-musl

@rustbot rustbot added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-linux Operating system: Linux O-musl Target: The musl libc labels Nov 28, 2023
@Sword-Destiny
Copy link
Contributor Author

the aarch64-unknown-linux-musl target use crt-static=true as default.
to avoid this error, We can add -Ctarget-feature=-crt-static in rustflags

@Sword-Destiny
Copy link
Contributor Author

the aarch64-unknown-linux-musl target use crt-static=true as default. to avoid this error, We can add -Ctarget-feature=-crt-static in rustflags

I think this the reason why -lunwind been added automatically.

at the file:
https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/base/linux_musl.rs

    // These targets statically link libc by default
    base.crt_static_default = true;

and the final compiler command line will contains this:

 "-Wl,-Bstatic" "-lunwind" "-lc"

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 29, 2023
@Ragnt
Copy link

Ragnt commented Feb 13, 2024

This is still a problem. You currently cannot build static libraries for musl targets unless you have a custom toolchain that includes libunwind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-linux Operating system: Linux O-musl Target: The musl libc
Projects
None yet
Development

No branches or pull requests

5 participants