-
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
give rustc_driver users a chance to overwrite the default sysroot #122993
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
The Miri subtree was changed cc @rust-lang/miri |
a715bad
to
d5c7ac0
Compare
@@ -1604,25 +1608,34 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { | |||
}) | |||
} | |||
|
|||
let real_rust_source_base_dir = sess.real_rust_source_base_dir(); |
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.
This is the only place where real_rust_source_base_dir
gets called. Should I just move that logic into this file?
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.
Also, should I be worried about perf here? We now re-compute real_rust_source_base_dir
each time imported_source_file
gets called. Not sure what would be the right place for a cache though.
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.
Before #84233 this got computed after the config
callback, in build_session
. That would be a lot better. But it seems that was changed for good reasons.
d5c7ac0
to
dedcc8b
Compare
I tried to follow but I don't have the context to review this r? compiler |
FWIW this is blocking |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
give rustc_driver users a chance to overwrite the default sysroot and then use that in Miri. This lets us get rid of an annoying arg-patching hack, and may help with rust-lang/miri#3404. Unfortunately the computation of `real_rust_source_base_dir` depended on knowing the default sysroot, so I had to move that around a bit. I have no idea how all this `Session` and `Options` stuff works so I hope this makes sense.
I guess this is now doing file system accesses in the middle of some rustc code that is probably in a query? Which is probably not okay as queries are supposed to be pure?
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
FWIW we're going with a different solution for rust-lang/miri#3404 for now. So while cleaning up the |
cc @nnethercote since you recently did adjacent refactors |
That turns out not to work currently, it is blocked on cuviper/autocfg#26. We have another work-around for rust-lang/miri#3404 (just change what rustdoc does), but I think I'd still like to get rid of the argument-parsing-sysroot hack in the Miri driver, which will need either something like this PR (letting the |
Finished benchmarking commit (92652ed): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Warning ⚠: The following benchmark(s) failed to build:
Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 671.665s -> 897.895s (33.68%) |
Hey I think I get the award for the biggest perf regression ever 😂 |
Yes, that would be a problem. Maybe rust/compiler/rustc_interface/src/queries.rs Lines 161 to 171 in dda2372
|
Hm... yeah, maybe, though that does sound quite complicated.^^ (to someone with no experience with adding new queries, and this 'feed' stuff seems quite sketchy) Before #84233 we had a simple cache in the |
For options we have |
Yeah a |
I can offer to implement the "real_rust_source_base_dir to query" change in a separate PR. However, I wouldn't be able to get to that before tomorrow. |
Adding the query is not the issue, the problem I see is that most of our decoding infra uses |
This is not urgent any more, rustdoc got patched to avoid the problematic arg-passing cases. And I think for handling So... it may not be worth doing all that work just for this PR.
We can just precompute it into the session. That's what happened before #84233. But somehow that was a problem wrt incremental builds or so. |
Yeah, all of the
That sounds like a bug to me because it circumvents dependency tracking. Maybe I'm missing something? |
Since it's not urgent. Let's block it on my unfinished refactor @rustbot blocked |
@@ -1604,25 +1608,34 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { | |||
}) | |||
} | |||
|
|||
let real_rust_source_base_dir = sess.real_rust_source_base_dir(); |
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.
This fn called a lot, you should wrap real_rust_source_base_dir into some once_cell.
Replace some `CrateStore` trait methods with hooks. Just like with the `CrateStore` trait, this avoids the cyclic definition issues with `CStore` being defined after TyCtxt, but needing to be used in TyCtxt. This is work towards unblocking rust-lang#122993 (the next step is giving `Span` deserialization access to the `TyCtxt`)
Replace some `CrateStore` trait methods with hooks. Just like with the `CrateStore` trait, this avoids the cyclic definition issues with `CStore` being defined after TyCtxt, but needing to be used in TyCtxt. This is work towards unblocking rust-lang#122993 (the next step is giving `Span` deserialization access to the `TyCtxt`)
I'm going to close this PR, I think rust-lang/miri#3411 is an easier way to handle this and may even be nicer -- it makes all the Miri sysroot handling very explicit by just checking how the Miri driver is invoked. |
and then use that in Miri.
This lets us get rid of an annoying arg-patching hack, and may help with rust-lang/miri#3404.
Unfortunately the computation of
real_rust_source_base_dir
depended on knowing the default sysroot, so I had to move that around a bit. I have no idea how all thisSession
andOptions
stuff works so I hope this makes sense.