Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNightlies since 2017-07-20 break when linking some libraries targeting Musl #43486
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
https://gist.github.com/golddranks/45f156e611adbcea24574e0dddaccaef Here are the logs. On the previous nightly it links the same code without problems. |
This comment has been minimized.
This comment has been minimized.
|
Hm, seems that the logs there don't show that the |
Mark-Simulacrum
added
the
I-nominated
label
Jul 27, 2017
This comment has been minimized.
This comment has been minimized.
|
Nominating for a priority and assignee from the compiler team. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
I get the same when I set |
This comment has been minimized.
This comment has been minimized.
(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 |
This comment has been minimized.
This comment has been minimized.
|
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 |
lnicola
referenced this issue
Aug 8, 2017
Closed
link error with undefined reference to `main' on Arch #23
arielb1
assigned
alexcrichton
Aug 10, 2017
michaelwoerister
removed
the
I-nominated
label
Aug 10, 2017
arielb1
added
I-nominated
T-cargo
and removed
T-compiler
labels
Aug 10, 2017
This comment has been minimized.
This comment has been minimized.
|
Discussed in the compiler team meeting. @alexcrichton will kindly take a look at it |
arielb1
added
P-medium
P-high
and removed
I-nominated
P-medium
labels
Aug 10, 2017
This comment has been minimized.
This comment has been minimized.
|
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
|
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
Oh, good catch. I think the note about pkg-config not supporting cross-compiles still applies, though isn't relevant to this issue. |
This comment has been minimized.
This comment has been minimized.
|
Ok I'm going to close this in that case, but @golddranks if you need help updating please just let me know! |
alexcrichton
closed this
Aug 12, 2017
This comment has been minimized.
This comment has been minimized.
|
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
referenced this issue
Aug 21, 2017
Closed
Made pg_config path configurable per-target. #18
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
#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 |
golddranks commentedJul 26, 2017
•
edited
In my experience, this breaks builds that try to link the crate
libpq-syswhen 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-19and2017-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.shandbuild_musl_works.sh: https://github.com/golddranks/diesel_musl_testcaseThe containers use this docker image: https://github.com/golddranks/rust_musl_docker