Uh oh!
There was an error while loading. Please reload this page.
rustbuild: Build libstd with ThinLTO - #45529
Conversation
This commit moves the standard library to get compiled with multiple codegen units and ThinLTO like the compiler itself. This I would hope is the last major step towards closing out rust-lang#45320
alexcrichton
commented
Oct 25, 2017
cc #45400, which enabled this for rustc |
alexcrichton
commented
Oct 25, 2017
Mark-Simulacrum
commented
Oct 25, 2017
@bors r+ |
bors
commented
Oct 25, 2017
📌 Commit 578feb5 has been approved by |
bors
commented
Oct 27, 2017
⌛ Testing commit 578feb5 with merge e462ee9c3d8c56966579d0c9c861617e9f162f86... |
bors
commented
Oct 27, 2017
💔 Test failed - status-travis |
kennytm
commented
Oct 27, 2017
Cannot link Errors from mipsel-unknown-linux-gnuErrors from mips64el-unknown-linux-gnuabi64 |
alexcrichton
commented
Oct 30, 2017
I've been trying to debug this locally and figure out what's going on. I wasn't able to reproduce until I was able to reproduce. Then I found out it's nondeterministic. That's... oh boy. |
alexcrichton
commented
Oct 30, 2017
Ok so... Investigation so far: First I wanted to rule out a "trivial bug" in ThinLTO or LLVM. Let's start with this source code: #![feature(thread_local)]#[thread_local]staticmutFOO:u32 = 3;fnfoo() -> &'staticu32{unsafe{&*(&Aas*const_)}}pubmod a {pubfnbar() -> u32{*super::foo()}}Compile that with: Next up we search through the output files for our thread local Ok so far so good. One IR file imports one IR file exports. ThinLTO inlined the constant/function call across module boundaries. Despite all that we retain Next up let's take a look at the object files: Ok still looking good. One object defines a So that rules out to me at least any casual oversight. Let's take a look at the test case in question. As I mentioned above it's nondeterministic, but I managed to catch a failure. A failure right now leaves a bunch of I rigged up a script to decode Intersting! LLVM IR checks out as one module is importing a Aha! Sure enough one object file has Next up is to figure out why if the LLVM module looks correct the object file looks incorrect. That... smells like an LLVM bug? A data race? Who knows! |
alexcrichton
commented
Oct 30, 2017
Dohoho the plot thickens! Turns out in a successful build there's not two object files. The one that has the "bad reference" didn't have the object file in the successful build, presumably optimized out? Desires for deterministic builds aside, that raised an interesting question. I compiled the program above for And so aha! Looks like the mipsel backend is deterministically not handling |
alexcrichton
commented
Oct 30, 2017
And it keeps going... Note that if we don't pass It looks like this is also related to Smells a lot like an LLVM bug... |
alexcrichton
commented
Oct 30, 2017
I've opened an upstream LLVM bug, and I don't think there's much we can do about this in the meantime, so here's to praying that gets a response in the next few days. |
@alexcrichton Would changing MIPS to use 1 CGU without ThinLTO workaround the bug? The TLS problem not only affects this PR but also #45187 and #45472. |
michaelwoerister
commented
Oct 31, 2017
Interesting. As far as I know our builds are pretty deterministic. At least the number of object files should always be the same. |
michaelwoerister
commented
Oct 31, 2017
That's some awesome debugging there, @alexcrichton, like reading a detective story I also think we should just default to one CGU on the affected platforms. |
alexcrichton
commented
Oct 31, 2017
@kennytm oh I had no idea that this was affecting other PRs! I'll implement a fix pronto. @michaelwoerister yeah I'm not entirely certain where the nondeterminism is coming from. It's probably coming from something in ThinLTO, I may do a pass to make sure we're at least feeding things to LLVM in a deterministic order. |
Discovered in rust-lang#45529 it looks like cross-module TLS imports aren't quite working today, especially with `hidden` visibility which mostly comes up with multiple codegen units. As a result this completely disables compiling with ThinLTO and multiple codegen units on MIPS when bootstrapping. cc rust-lang#45654, the tracking issue for this
alexcrichton
commented
Oct 31, 2017
rustbuild: Don't build with ThinLTO on MIPS Discovered in #45529 it looks like cross-module TLS imports aren't quite working today, especially with `hidden` visibility which mostly comes up with multiple codegen units. As a result this completely disables compiling with ThinLTO and multiple codegen units on MIPS when bootstrapping. cc #45654, the tracking issue for this
This commit moves the standard library to get compiled with multiple codegen
units and ThinLTO like the compiler itself. This I would hope is the last major
step towards closing out #45320