-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Overhaul filename handling for cross-compiler consistency #149709
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
base: main
Are you sure you want to change the base?
Conversation
This is preparation for the filename handling overhaul where having access to the working directory is mandatory.
This is done in order to simplify the filename overhaul and those places don't need to the embeddable path anyway.
|
Some changes occurred in coverage instrumentation. cc @Zalathar These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred to the CTFE machinery The Miri subtree was changed cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in compiler/rustc_codegen_gcc |
This comment has been minimized.
This comment has been minimized.
268f9ac to
2dc3531
Compare
|
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
|
@bors try |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
Overhaul filename handling for cross-compiler consistency
|
⌛ Trying commit 2dc3531 with merge 98a0a37… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/19988364169 |
This comment has been minimized.
This comment has been minimized.
2dc3531 to
d5be1b8
Compare
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
d5be1b8 to
21ea4d2
Compare
This comment has been minimized.
This comment has been minimized.
21ea4d2 to
7ab8c59
Compare
This comment has been minimized.
This comment has been minimized.
7ab8c59 to
b91c3d0
Compare
This comment has been minimized.
This comment has been minimized.
b91c3d0 to
b954e1f
Compare
This comment has been minimized.
This comment has been minimized.
This commit refactors `SourceMap` and most importantly `RealFileName` to make it self-contained in order to achieve cross-compiler consistency. This is achieved: - by making `RealFileName` immutable - by only having `SourceMap::to_real_filename` create `RealFileName` - by also making `RealFileName` holds it's working directory, it's embeddable name and the remapped scopes - by making most `FileName` and `RealFileName` methods take a scope as an argument In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed. The scopes type `RemapPathScopeComponents` was moved from `rustc_session::config` to `rustc_span`. The previous system for scoping the local/remapped filenames `RemapFileNameExt::for_scope` is no longer useful as it's replaced by methods on `FileName` and `RealFileName`.
And use the diagnostic method for diagnostic paths.
We can't completely remove it as it's needed for incr comp but direct consumers towards `SourceMap::working_dir` instead.
b954e1f to
62464ef
Compare
This PR overhauls the way we handle filenames in the compiler and
rmetain order to achieve achieve cross-compiler consistency (ie. having the same path no matter if the filename was created in the current compiler session or is coming fromrmeta).This is required as some parts of the compiler rely on consistent paths for the soundness of generated code (see #148328).
In order to achieved consistency multiple steps are being taken by this PR:
RealFileNameimmutableSourceMap::to_real_filenamecreateRealFileNameRealFileNamecan be created from anyPathand are remapped afterwards, which creates consistency issueRealFileNameholds it's working directory, embeddable name and the remapped scopesSession, to know the current(!) scopes and cwd, which is invalid as they may not be equal to the scopes used when creating the filenameIn order for
SourceMap::to_real_filenameto know which scopes to applyFilePathMappingnow takes the current remapping scopes to apply, which makesFileNameDisplayPreferenceand company useless and are removed.This PR is split-up in multiple commits (unfortunately not atomic), but should help review the changes.
Unblocks #147611
Fixes #148328
cc @RalfJung @oli-obk
r? @davidtwco