Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stabilization report of
--remap-path-scope
Summary
RFC 3127 trim-paths aims to improve the current status of sanitizing paths emitted by the compiler via the
--remap-path-prefix=FROM=TO
command line flag, by offering a profile setting namedtrim-paths
in Cargo to sanitize absolute paths introduced during compilation that may be embedded in the compiled binary executable or library.As part of that RFC the compiler was asked to add the
--remap-path-scope
command-line flag to control the scoping of how paths get remapped in the resulting binary.Tracking:
What is stabilized
The rustc
--remap-path-scope
flag is being stabilized by this PR. It defines which scopes of paths should be remapped by--remap-path-prefix
.This flag accepts a comma-separated list of values and may be specified multiple times, in which case the scopes are aggregated together.
The valid scopes are:
macro
- apply remappings to the expansion ofstd::file!()
macro. This is where paths in embedded panic messages come fromdiagnostics
- apply remappings to printed compiler diagnosticsdebuginfo
- apply remappings to debug informationsobject
- apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias formacro,debuginfo
.all
(default) - an alias for all of the above, also equivalent to supplying only--remap-path-prefix
without--remap-path-scope
.Example
What isn't stabilized
None of the Cargo facility is being stabilized in this stabilization PR, only the
--remap-path-scope
flag inrustc
is being stabilized.Design
RFC history
Answers to unresolved questions
There are no unresolved questions regarding
--remap-path-scope
.(The tracking issue list a bunch of unresolved questions but they are for
--remap-path-prefix
or the bigger picturetrim-paths
in Cargo and are not related the functionality provided by--remap-path-scope
.)Post-RFC changes
The RFC described more scopes, in particularly regarding split debuginfo. Those scopes where removed after analysis by
michaelwoerister
of all the possible combinations in #111540 (comment).Nightly extensions
There are no nightly extensions.
Doors closed
We are committing to having to having a flag that control which paths are being remapped based on a "scope".
Feedback
Call for testing
No call for testing has been done per se but feedback has been received on both the rust-lang/rust and rust-lang/cargo tracking issue.
The feedback was mainly related to deficiencies in our best-effort
--remap-path-prefix
implementation, in particular regarding linkers added paths, which does not change anything for--remap-path-scope
.Nightly use
Except for Cargo unstable
trim-paths
there doesn't appear any committed use on GitHub.Implementation
Major parts
rust/compiler/rustc_session/src/config.rs
Lines 1373 to 1384 in b3f8586
rust/compiler/rustc_session/src/session.rs
Line 1526 in b3f8586
rust/compiler/rustc_span/src/lib.rs
Lines 352 to 372 in b3f8586
Coverage
tests/run-make/split-debuginfo/rmake.rs
tests/ui/errors/remap-path-prefix.rs
tests/ui/errors/remap-path-prefix-macro.rs
tests/run-make/remap-path-prefix-dwarf/rmake.rs
tests/run-make/remap-path-prefix/rmake.rs
tests/ui/errors/remap-path-prefix-diagnostics.rs
Outstanding bugs
There are outstanding bugs regarding
--remap-path-scope
.Outstanding FIXMEs
There are no FIXME regarding
--remap-path-scope
in it-self.Tool changes
rustdoc
has support for--remap-path-prefix
, it should probably also get support for--remap-path-scope
, although rustdoc maybe want to adapt the scopes for it's use (replacedebuginfo
withdocumentation
for example).History
-Zremap-path-scope
rmeta handling #139550-Zremap-path-scope
tests with dependency #140716Acknowledgments
@rustbot labels +T-compiler +needs-fcp +F-trim-paths
r? @davidtwco