-
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
rustc: Fix regression where jemalloc isn't used #57287
Conversation
9c95ff4
to
5265c31
Compare
(rust_highfive has picked a reviewer for you, use r? to override) |
@bors: try |
rustc: Fix regression where jemalloc isn't used In #56986 the linkage of jemalloc to the compiler was switched from the driver library to the rustc binary to ensure that only rustc itself uses jemalloc. In doing so, however, it turns out jemalloc wasn't actually linked in at all! None of the symbols were referenced so the static library wasn't used. This means that jemalloc wasn't pulled in at all. This commit performs a bit of a dance to reference jemalloc symbols, attempting to pull it in despite LLVM's optimizations. Closes #57115
☀️ Test successful - status-travis |
@rust-timer build 3550c27 |
Success: Queued 3550c27 with parent ec19464, comparison URL. |
So my take on this:
It seems surprising to me that there is no more elegant way to do this. I'm willing therefore to r+ though I might prefer if somebody else who was closer to the whole linking story did so, since maybe they will have another idea. (e.g., @petrochenkov is asking good questions here). |
Also, the try build is ready, not sure what use you had in mind, @alexcrichton ? |
The most elegant way to do this without looking like a hack is probably to use linker flags directly, but actually doing that in Rust would look like more of a hack unfortunately. We don't have that level of control over how things are built to know what's where on the command line, so I've found symbol references to be much more flexible. Also sorry should have mentioned, but I'd like to do a perf run to confirm that this actually fixes the regression this claims to fix. |
(I'd also like to add more comments in the code about the hacks here code-wise, was just waiting on perf) |
Finished benchmarking try commit 3550c27 |
5265c31
to
cd05e6a
Compare
Yay regression is indeed fixed! I've added some comments, and perhaps in addition to @petrochenkov @michaelwoerister may want to take a look? |
In rust-lang#56986 the linkage of jemalloc to the compiler was switched from the driver library to the rustc binary to ensure that only rustc itself uses jemalloc. In doing so, however, it turns out jemalloc wasn't actually linked in at all! None of the symbols were referenced so the static library wasn't used. This means that jemalloc wasn't pulled in at all. This commit performs a bit of a dance to reference jemalloc symbols, attempting to pull it in despite LLVM's optimizations. Closes rust-lang#57115
cd05e6a
to
ccbf28e
Compare
Other crates that want to use static jemalloc will have to do something like this as well? |
In theory, yes, but in practice it isn't much of a problem. Almost all Rust code that isn't rustc is built with all Rust code statically linked, so the references to the jemalloc symbols will come through things like libstd or just bland |
Some update: apparently I misremembered the details, command line and attribute behave identically (that's good). The difference was that |
From my experience at least creating a composable system where libraires can specify linkage and whatnot is insanely hard to say the least and likely downright impossible. We do our best when we can and otherwise just try to fix things when a bug comes up. We're definitely not consistent though :( |
@bors r+ Since it seems like @petrochenkov doesn't have any blocking objections, I'm going to r+ here for now. Feel free to r- or r? someone else though. |
📌 Commit ccbf28e has been approved by |
rustc: Fix regression where jemalloc isn't used In #56986 the linkage of jemalloc to the compiler was switched from the driver library to the rustc binary to ensure that only rustc itself uses jemalloc. In doing so, however, it turns out jemalloc wasn't actually linked in at all! None of the symbols were referenced so the static library wasn't used. This means that jemalloc wasn't pulled in at all. This commit performs a bit of a dance to reference jemalloc symbols, attempting to pull it in despite LLVM's optimizations. Closes #57115
☀️ Test successful - status-appveyor, status-travis |
In #56986 the linkage of jemalloc to the compiler was switched from the
driver library to the rustc binary to ensure that only rustc itself uses
jemalloc. In doing so, however, it turns out jemalloc wasn't actually
linked in at all! None of the symbols were referenced so the static
library wasn't used. This means that jemalloc wasn't pulled in at all.
This commit performs a bit of a dance to reference jemalloc symbols,
attempting to pull it in despite LLVM's optimizations.
Closes #57115