-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Rust 1.59 using linux-musl and PIE #94364
Comments
@amircodota I'm figuring out if your issue it reproducible with something as minimal as a hello world, something like :
(if it helps to diagnose the issue) |
@apiraino I seriously doubt it. This is a pretty complex multi-crate workspace, with many dependencies, some of which contain c and c++ code. I'm pasting a full output of the error - maybe ot would help zero in of the issue
|
@apiraino What I am really looking for is a workaround. I think 1.59 changed the default relocation-model of musl. If you guys can provide instructions on how to set the relevant flags so that it behaves the same as 1.58, I think that would be good enough :-) |
From the error message it seems that musl itself is not compiled with |
hmmm... Interesting. I am using cross to compile musl, and I have a custom Dockerfile, that is built from the cross base docker image for musl. Let me see if I can reproduce on simple code using cross |
using cross on a brand new
Maybe this would give a clue? Here's how to reproduce
|
You don't need to use cross to target musl, you can just install the target using If this works then you should report a bug in cross instead. |
I can't reproduce this in cross,
|
Yes, this is indeed something with my custom cross docker image. I'm investigating on my end. |
Posting an update here - in case someone else runs into this issue too. I was using a custom cross docker image which added some depndencies to the cross base image. In the Dockerfile I had the following line
The reason was one of the crates I was using needed libstdc++.a, which does not come bundled with the rust target, but does exist in the above directory in the cross docker image. This worked fine until rust 1.59.0, where the musl target changed to use PIE by default, and so my docker image was no longer working. The solution was simple - just copy libstddc++.a to a different directory, and add that directory to the linker search path.
Thanks everyone for the help |
I think I'm having a similar issue, although I don't see any |
@horacimacias I'll try to exaplin in a little more detail what was the issue for me - hopefully this can help you figure out your case. In my case I had a custom docker image, based off This image already comes bundled with musl static and shared libraries under In my case, I needed to link against some static libraries that were not included in with the rust musl target (in my case it was libstdc++.a, but there are other libraries that might be relevant). To fix that, I added the following environment variable to my custom dockerfile
This worked fine until rust 1.59.0, where the musl target is compiled with different flags, causing linkage errors.
The bottom line is that you want to make sure you link against the musl libc that comes bundled with your rust target, and not with some other musl libc that happens to exist somewhere in your docker image. Hope this helps :-) |
it does help, thanks. thanks! |
Thanks @amircodota I have been pulling my hairs out for almost a complete day and I couldn't figure out the issue. Your hint was really helpful. In my case I was using a custom cross image as well and I was installing additional libraries into the Instead of copying the files, I decided to use a different prefix when compiling these libraries (openssl, zlib and pq). I think this might be easier, because this will also set the correct paths in the Here is an example that compiles fine, maybe it is useful for others when they experience the same and find this GitHub issue:
(The Protobuf compiler is actually not needed in this example, but I will need it for my code later on).
[package]
name = "test"
version = "1.0.0"
[dependencies]
openssl = "*"
diesel = { version = "2.0", features = [
"postgres",
] }
extern crate openssl;
#[macro_use]
extern crate diesel;
fn main() {
println!("hello");
} |
I'm trying to upgrade our codebase to rust 1.59.0. It compiles fine on 1.58.0.
For linux targets, we compile using the x86_64-unknown-linux-musl target.
But with 1.59.0, I'm getting many such errors
Followed by this
I'm guessing this has to do with this change.
I tried compiling with both
-C relocation-model=pie
andrelocation-model=static
but it did not seem to change much.Any advice?
The text was updated successfully, but these errors were encountered: