-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Nightlies since 2017-07-20 break when linking some libraries targeting Musl #43486
Comments
Interesting. Do you have some build logs? Not currently at a computer. Musl has had support for full RELRO for a few years, but it's certainly possible that it's related. Will look into it when I get to a computer. |
https://gist.github.com/golddranks/45f156e611adbcea24574e0dddaccaef Here are the logs. On the previous nightly it links the same code without problems. |
Hm, seems that the logs there don't show that the |
Nominating for a priority and assignee from the compiler team. |
Btw. some of my comments may seem confused: here the problem seems to manifest when it's apparently trying to run/load the compiler plugin. I think I had earlier some code that refused to link and that showed a better error message than the testcase code. I'll see if I can find that example tomorrow. |
I get the same when I set |
(from your dockerfile) This is not true - compiler plugins need to be compatible with the compiler, which means they link against the system libc (which is glibc on debian). As a rule of thumb, you should basically never set So it's not really a surprise that
So wait, why did this 'work' previously? Well, this comment is helpful: "Full RELRO makes the dynamic linker resolve all symbols at startup". So, although I've not verified this, my strong suspicion is that Why did I put 'work' in quotes above? Whether you can get away with this kind of thing is purely down to chance, and even if it compiles you can get pretty terrible subtle corruptions in data due to libc mismatches. It's good that you've hit this, because it means you now know there's a problem. No perfect solution immediately springs to mind. Fundamentally you need two versions of |
Ah, the pkg-config-rs-can't cross issue. I've had a note about it in meta-rust for a while as it seemed likely we'd hit it there. Likely solution is to allow 2 |
Discussed in the compiler team meeting. @alexcrichton will kindly take a look at it |
Ok looking into this, here's some thoughts.
So to me the bug can be boiled down to two things:
I would personally close this as "not a bug". The bug is in For fixing
|
I think that @aidanhs' explanation makes a lot of sense. I think that I'll have some time during the weekend to tweak the image and test a bit. If the compiler got just stricter about linking upfront, then it just surfaced a bug that was all along there. |
Oh, good catch. I think the note about pkg-config not supporting cross-compiles still applies, though isn't relevant to this issue. |
Ok I'm going to close this in that case, but @golddranks if you need help updating please just let me know! |
So, to fix the build environment, I have to install a glibc version of libpq too, and get the build script of the If I enable the (Ping @sgrif, TL;DR: When cross-compiling diesel, libpq-sys is built twice, for both the host and the target. The build script of |
@golddranks yes you'll have to have both, and the build script will need to be updated to ensure it finds the right one when configured for the appropriate target |
@alexcrichton or @aidanhs do you happen to know about -fPIE, -fPIC and -pie flags? GCC on Debian Stretch produces position independent code by default, and while fixing the Docker image I use for building, I also updated the distro from Jessie to Stretch. After much of churn, and the the C libraries built without flags "-fPIE -pie" refusing to build or link because of relocations, I managed to build stuff by adding those flags, but the Rust binary produced against the libraries is dynamically loaded even though all the libraries are linked statically:
For now, I can just downgrade to Jessie if I want a fully static binary, but if you have any idea how to build static Rust binaries on Stretch, I'd be happy to hear that, since at some point, older versions of Debian will be old and unsupported. |
Your binary is statically linked, but has a As it happens I think #40113 will fix this (well, depending on what it looks like when it gets merged!), but in the meantime you should be able to create a file called
and then use the |
#40113 landed and is in the newest nightly. I tried to build with the combination: nightly-2018-08-24 + Debian Stretch + native libraries compiled and linked with "-fPIE -pie" flags. This time, it doesn't link the binary: Combination nightly-2018-08-24 + Debian Jessie without the "-fPIE -pie" similarly refuses to link, with the same error message. So the new nightly seems to be broken WRT static musl builds. Like noted above, the combination nightly-2018-08-21 + Debian Stretch + "-fPIE -pie" flags did link, but produced a binary with This thread is offtopic for this so I'll create a new issue. Edit. Here: #44069 |
In my experience, this breaks builds that try to link the crate
libpq-sys
when targeting Musl. I haven't confirmed any other libraries breaking.This is a stable-to-nightly regression. The exact breakage happens between nightlies
2017-07-19
and2017-07-20
. Here's a comparison between the commits that the two nightlies were built from: 83c659e...582af6e I haven't yet looked at the commits.Here's a test case that runs in a docker container. See the scripts
build_musl_breaks.sh
andbuild_musl_works.sh
: https://github.com/golddranks/diesel_musl_testcaseThe containers use this docker image: https://github.com/golddranks/rust_musl_docker
The text was updated successfully, but these errors were encountered: