-
Notifications
You must be signed in to change notification settings - Fork 500
Wrong program interpreter requested on musl targets #635
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
I'm not convinced that it's cc-rs's domain/responsibility. To specify the dynamic linker that is. cc-rs merely compiles object modules, and linking is performed by rustc. One can wonder if cc-rs could [and then if it actually should] help steering rustc to target-specific linker, but as far as I can tell it doesn't interfere with this process. I would suggest treating musl as any other cross-compile target and specify
|
I think requiring users to specify this in .cargo/config.toml is not right. The problem clearly occurs when C++ code is linked. Rust is not responsible for linking C++ as is Cargo, cc is responsible for handling proper C++ linkage. EDIT: You cannot rely on everyone customizing their config.toml every time they work on must based systems, this crate should just work no matter what target is used as long as the target supports C++. EDIT2: If this is impossible at least consider showing an error message earlier in the build process to avoid generating broken unusable binaries. |
Yet it's the way it is. Try to cross-compile for any target and you'll see.
cc-rs does tell rustc to link with C++ run-time library, but doesn't tell which linker to use. The choice is rustc's. [Do note that I'm not in position to change anything, I merely describe the state of affairs.]
What defines a musl-based system? If there are systems where musl is the default (or only?) libc run-time, then the expectation would be that default |
That's exactly what I meant, If musl is the only libc (which is the case on Postmarket OS aarch64) then cc should instruct rustc to use the proper linker instead of continuing with the default one and generate a broken binary which is the current state. If there are both libc and musl available let rustc choose what it prefers by default. |
But that's not what I meant. I didn't mean that cc-rs crate would have to do anything special, but that the default linker used by rustc would "know" what to do without rustc doing anything special. In other words nobody would have to instruct anybody about anything on a musl-based system. Or maybe more specifically on a system that can actually be classified as musl-based. Just in case, the misunderstanding arose from the fact that when I wrote " |
If I get it right, that means you should open an issue on rustc... |
It means that someone might choose to open an issue with rustc. Just in case, as implied above, I personally have no plans for doing anything beyond describing the way things are. |
So that means you're fine with the current state which is generating broken binaries... EDIT: I just did it |
I think this is definately a problem with the CC crate! On musl targets, rustc assumes static linking. The cc crate should provide a way to enable linking with the static build of the c++ library. On musl systems, a static build of the C++ library is already available under EDIT: Just hacked something together and I can conclude that cc crate can do something which is not hacky at all. Basically this crate can do similar than for Android: println!("cargo:rustc-link-search=native=/usr/lib");
println!("cargo:rustc-link-lib=static=stdc++"); Once these 2 lines are manually emitted from the build script rustc no longer requests the wrong interpreter because the entire program gets linked statically. |
The cc crate requests /lib/ld-linux-aarch64.so.1 as a program interpreter on musl targets when some c++ code is built. Instead the cc crate should request /lib/ld-musl-aarch64.so.1.
The text was updated successfully, but these errors were encountered: