Repository navigation
Conversation
|
cc @bjorn3
cc @rust-lang/miri
|
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
||
| fn init(&mut self, _sess: &EarlySession) -> CodegenBackendInit { | ||
| Default::default() | ||
| fn init(&mut self, _sess: &EarlySession) -> (CodegenBackendInit, TargetConfig) { |
There was a problem hiding this comment.
The 2nd commit refactors backend initialization by merging init and target_config. This is because the LLVM backend can avoid recomputing some data if it can take intermediate results from init and use them to construct target_config. This makes it so that base_llvm_features is actually finally called only once ever, which makes me very happy.
Maybe that means the two types should be merged as well, but I'd prefer to leave that to a future PR as it seems mostly orthogonal, logic-wise.
4262fd4 to
bc2cf69
Compare
|
r? @folkertdev |
|
|
This comment has been minimized.
This comment has been minimized.
bc2cf69 to
7721e8d
Compare
This comment has been minimized.
This comment has been minimized.
7721e8d to
01422ce
Compare
This comment has been minimized.
This comment has been minimized.
01422ce to
e00304e
Compare
This comment has been minimized.
This comment has been minimized.
| None, | ||
| &sess.target, | ||
| ); | ||
| let _ = native_codegen_backend.init(sess); |
There was a problem hiding this comment.
Why is removing the call to init here correct? That function takes &mut self so it might update the session.
There was a problem hiding this comment.
The call has been moved into MiriCodegenBackend::init, because it felt more natural to have it there.
There was a problem hiding this comment.
It's not clear locally how MiriCodegenBackend::init gets called (I guess in compiler/rustc_interface/src/interface.rs?), but I'll happily believe you wrt Miri code.
There was a problem hiding this comment.
MiriCodegenBackend is basically wrapping another codegen backend, so forwarding these calls makes most sense to me. I'm not sure why we previously went for eager initialization...
| // Typically we'll want more explicit settings to override the implicit ones, so: | ||
| // | ||
| // * Features from -Ctarget-cpu=*; are overridden by [^1] | ||
| // * Features implied by --target; are overridden by |
There was a problem hiding this comment.
does this mean "overridden by empty string"? it reads really weird?
There was a problem hiding this comment.
No, it means "overriden by the things listed later in this enumeration"
e00304e to
c9e3b90
Compare
| None, | ||
| &sess.target, | ||
| ); | ||
| let _ = native_codegen_backend.init(sess); |
There was a problem hiding this comment.
It's not clear locally how MiriCodegenBackend::init gets called (I guess in compiler/rustc_interface/src/interface.rs?), but I'll happily believe you wrt Miri code.
This comment has been minimized.
This comment has been minimized.
c9e3b90 to
687e034
Compare
687e034 to
ba6921e
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
b5fbf06 to
abea8b4
Compare
abea8b4 to
ddbf0a3
Compare
0c84573 to
d87e107
Compare
669da09 to
895f6ba
Compare
895f6ba to
c71ded2
Compare
|
@folkertdev looks like the GCC side is good. Anything else from your side? :) |
|
@bors r+ |
|
☔ The latest upstream changes (presumably #166567) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. This pull request was unapproved. |
View all comments
Currently, -Zllvm-target-feature takes precedence for populating
internal_target_features, but -Ctarget-feature takes precedence for what we actually tell LLVM. That's pretty bad, so this PR makes them consistent.I first wanted -Zllvm-target-feature to take precedence everywhere, as that was the intent in #160457. However, I don't see a good way to implement that: internal_target_features are computed by instantiating an actual LLVM data structure without -Ctarget-feature, querying which Rust target features that supports, and then applying -Ctarget-feature and its implications "manually". This is done to prevent backend implications from affecting
cfg(target_feature). But this means we can't really apply -Zllvm-target-feature after having done that as that would take us back down to the LLVM level. So instead, the precedence order is that all LLVM-level stuff comes first, and then -Ctarget-feature comes all the way at the end.Cc @folkertdev (reviewer of #160457), @nnethercote (recently did some refactoring of the backend init logic that is being further adjusted here)
Tracking issue: #157753