-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use protected visibility when building rustc #131634
base: master
Are you sure you want to change the base?
Conversation
Multiple atomic commits in a single PR are totally fine, that's easier to review and better for history anyway (the way you have this PR is ideal imo). We definitely don't want a bunch of back and forth WIP-style commits that make changes just to undo them or fix things up, but there is no 1PR=1commit rule like LLVM. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use protected visibility when LLD feature is enabled and enable it when building rustc rust-lang/compiler-team#782 I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR. I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled. r? lqd
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (6ad0952): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.2%, secondary -3.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -3.3%, secondary -7.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary -0.3%, secondary -0.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 783.66s -> 778.727s (-0.63%) |
I was expecting we'd only do this when using lld by default on stable. Just using a different default linker on nightly has bitten us at least once in the recent past, and I didn't think we'd want the 2 configs to drift even more. But if others are fine with it, so am I. Cool, as expected these results match bjorn's old prototype I mentioned in the MCP. However, could you explain a bit about the intent? Did you want to change visibility when using lld in general, or when using
It's very much welcomed in general, however in this case I think we may need to extract the second commit in another PR: the exact handling of |
Perf. results look great! 🎉 The bootstrap change is a bit drive-by, though. We should finally refactor the way we handle LLD in bootstrap, I'll try to priotize it soon-ish. That's partially orthogonal to this PR, though. I wonder if we should first enable this only for the compiler itself? Both to separate the perf. effect on the compiler from the perf. effect on the binaries, and also to test it for a while on nightly on the compiler before we enable it by default for all binaries compiled by a nightly compiler. |
My intent was primarily, at least initially to use protected visibility for rustc-driver. Not tying it to LLD and flagging it on for just rustc initially sounds sensible to me. One thing I'm not sure about though is whether that means I'll need to wait until |
I would only do it for stage 2, we already do a bunch of optimizations on stage 2 only anyway, e.g. PGO and BOLT. So when building stage 2 rustc, I'd just forcefully set the -Zdefault-visibility flag. |
bootstrap uses beta and IIRC for stage-dependent flags, it should be done in bootstrap, e.g. around here (similarly to @rustbot author |
src/bootstrap/src/utils/helpers.rs
Outdated
@@ -428,7 +428,7 @@ pub fn linker_flags( | |||
) -> Vec<String> { | |||
let mut args = vec![]; | |||
if !builder.is_lld_direct_linker(target) && builder.config.lld_mode.is_used() { | |||
args.push(String::from("-Clink-arg=-fuse-ld=lld")); | |||
args.push(String::from("-Zlinker-features=+lld")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep building the standard library with default visibility as CI will build with lld, but the end user may then use this version of the standard library with ld.bfd. For librustc_driver.so it is completely fine though. Same for tools and codegen backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point. I suspect that means that parts of the standard library that make it into the dylib, will unfortunately still have default visibility, but there might not be much we can do about that in the short term - unless we were to build a copy of the standard library specifically for use in rustc_driver that used protected visibility, then distribute a copy of the standard library that used default visibility. I guess that'd be like building the compiler with -Zbuild-std
and -Zdefault-visibility=protected
.
1e1bf2b
to
977730b
Compare
This PR modifies If appropriate, please update |
This comment has been minimized.
This comment has been minimized.
977730b
to
1441a82
Compare
As suggested, I've updated this PR so that LLD is no longer involved. I now just set I added a flag |
Please update PR name. |
1441a82
to
d1f7f68
Compare
This PR modifies If appropriate, please update |
I decided that I didn't like the flag, so I've changed it so that now it only adds a new option to [rust]
use-protected-symbols = true This new option defaults to true if I haven't updated @rustbot ready |
As I’m not on t-bootstrap, r? Kobzol |
rust-lang/compiler-team#782
I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.
I contemplated trying to enable protected visibility for more cases when LLD will be used other than just
-Zlinker-features=+lld
, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.r? lqd