-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Stabilize -Zremap-path-scope
#147611
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
Open
Urgau
wants to merge
3
commits into
rust-lang:master
Choose a base branch
from
Urgau:stablize-remap-path-scope
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+183
−93
Open
Stabilize -Zremap-path-scope
#147611
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1377,10 +1377,35 @@ bitflags::bitflags! { | |||||
const DIAGNOSTICS = 1 << 1; | ||||||
/// Apply remappings to debug information | ||||||
const DEBUGINFO = 1 << 3; | ||||||
/// Apply remappings to coverage information | ||||||
const COVERAGE = 1 << 4; | ||||||
|
||||||
/// An alias for `macro` and `debuginfo`. This ensures all paths in compiled | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// executables or libraries are remapped but not elsewhere. | ||||||
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits(); | ||||||
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits() | Self::COVERAGE.bits(); | ||||||
} | ||||||
} | ||||||
|
||||||
pub(crate) fn parse_remap_path_scope( | ||||||
early_dcx: &EarlyDiagCtxt, | ||||||
matches: &getopts::Matches, | ||||||
) -> RemapPathScopeComponents { | ||||||
if let Some(v) = matches.opt_str("remap-path-scope") { | ||||||
let mut slot = RemapPathScopeComponents::empty(); | ||||||
for s in v.split(',') { | ||||||
slot |= match s { | ||||||
"macro" => RemapPathScopeComponents::MACRO, | ||||||
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS, | ||||||
"debuginfo" => RemapPathScopeComponents::DEBUGINFO, | ||||||
"coverage" => RemapPathScopeComponents::COVERAGE, | ||||||
"object" => RemapPathScopeComponents::OBJECT, | ||||||
"all" => RemapPathScopeComponents::all(), | ||||||
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"), | ||||||
} | ||||||
} | ||||||
slot | ||||||
} else { | ||||||
RemapPathScopeComponents::all() | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -1420,18 +1445,18 @@ pub fn host_tuple() -> &'static str { | |||||
|
||||||
fn file_path_mapping( | ||||||
remap_path_prefix: Vec<(PathBuf, PathBuf)>, | ||||||
unstable_opts: &UnstableOptions, | ||||||
remap_path_scope: &RemapPathScopeComponents, | ||||||
) -> FilePathMapping { | ||||||
FilePathMapping::new( | ||||||
remap_path_prefix.clone(), | ||||||
if unstable_opts.remap_path_scope.contains(RemapPathScopeComponents::DIAGNOSTICS) | ||||||
if remap_path_scope.contains(RemapPathScopeComponents::DIAGNOSTICS) | ||||||
&& !remap_path_prefix.is_empty() | ||||||
{ | ||||||
FileNameDisplayPreference::Remapped | ||||||
} else { | ||||||
FileNameDisplayPreference::Local | ||||||
}, | ||||||
if unstable_opts.remap_path_scope.is_all() { | ||||||
if remap_path_scope.is_all() { | ||||||
FileNameEmbeddablePreference::RemappedOnly | ||||||
} else { | ||||||
FileNameEmbeddablePreference::LocalAndRemapped | ||||||
|
@@ -1473,6 +1498,7 @@ impl Default for Options { | |||||
cli_forced_codegen_units: None, | ||||||
cli_forced_local_thinlto_off: false, | ||||||
remap_path_prefix: Vec::new(), | ||||||
remap_path_scope: RemapPathScopeComponents::all(), | ||||||
real_rust_source_base_dir: None, | ||||||
real_rustc_dev_source_base_dir: None, | ||||||
edition: DEFAULT_EDITION, | ||||||
|
@@ -1499,7 +1525,7 @@ impl Options { | |||||
} | ||||||
|
||||||
pub fn file_path_mapping(&self) -> FilePathMapping { | ||||||
file_path_mapping(self.remap_path_prefix.clone(), &self.unstable_opts) | ||||||
file_path_mapping(self.remap_path_prefix.clone(), &self.remap_path_scope) | ||||||
} | ||||||
|
||||||
/// Returns `true` if there will be an output file generated. | ||||||
|
@@ -1940,6 +1966,14 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> { | |||||
"Remap source names in all output (compiler messages and output files)", | ||||||
"<FROM>=<TO>", | ||||||
), | ||||||
opt( | ||||||
Stable, | ||||||
Opt, | ||||||
"", | ||||||
"remap-path-scope", | ||||||
"Defines which scopes of paths should be remapped by `--remap-path-prefix`", | ||||||
"<macro,diagnostics,debuginfo,object,all>", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
), | ||||||
opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"), | ||||||
]; | ||||||
options.extend(verbose_only.into_iter().map(|mut opt| { | ||||||
|
@@ -2838,6 +2872,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M | |||||
let externs = parse_externs(early_dcx, matches, &unstable_opts); | ||||||
|
||||||
let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches, &unstable_opts); | ||||||
let remap_path_scope = parse_remap_path_scope(early_dcx, matches); | ||||||
|
||||||
let pretty = parse_pretty(early_dcx, &unstable_opts); | ||||||
|
||||||
|
@@ -2901,7 +2936,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M | |||||
early_dcx.early_fatal(format!("Current directory is invalid: {e}")); | ||||||
}); | ||||||
|
||||||
let file_mapping = file_path_mapping(remap_path_prefix.clone(), &unstable_opts); | ||||||
let file_mapping = file_path_mapping(remap_path_prefix.clone(), &remap_path_scope); | ||||||
let working_dir = file_mapping.to_real_filename(&working_dir); | ||||||
|
||||||
let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals; | ||||||
|
@@ -2938,6 +2973,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M | |||||
cli_forced_codegen_units: codegen_units, | ||||||
cli_forced_local_thinlto_off: disable_local_thinlto, | ||||||
remap_path_prefix, | ||||||
remap_path_scope, | ||||||
real_rust_source_base_dir, | ||||||
real_rustc_dev_source_base_dir, | ||||||
edition, | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/doc/unstable-book/src/compiler-flags/remap-path-scope.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This test makes sure that the files used in the coverage are remapped by `--remap-path-prefix` | ||
// and the `coverage` <- `object` scope. | ||
|
||
//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope | ||
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped | ||
// | ||
//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage | ||
//@[with_object_scope] compile-flags: --remap-path-scope=object | ||
//@[with_macro_scope] compile-flags: --remap-path-scope=macro | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/coverage/remap-path-prefix.with_coverage_scope.cov-map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Function name: remap_path_prefix::main | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 01, 00, 0a, 01, 00, 0c, 00, 0d] | ||
Number of files: 1 | ||
- file 0 => remapped/remap-path-prefix.rs | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 10) | ||
- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) | ||
Highest counter ID seen: c0 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Function name: remap_path_prefix::main | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 01, 00, 0a, 01, 00, 0c, 00, 0d] | ||
Number of files: 1 | ||
- file 0 => $DIR/remap-path-prefix.rs | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 10) | ||
- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) | ||
Highest counter ID seen: c0 | ||
|
12 changes: 12 additions & 0 deletions
12
tests/coverage/remap-path-prefix.with_macro_scope.coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LL| |// This test makes sure that the files used in the coverage are remapped by `--remap-path-prefix` | ||
LL| |// and the `coverage` <- `object` scope. | ||
LL| | | ||
LL| |//@ revisions: with_remap with_coverage_scope with_object_scope with_macro_scope | ||
LL| |//@ compile-flags: --remap-path-prefix={{src-base}}=remapped | ||
LL| |// | ||
LL| |//@[with_coverage_scope] compile-flags: --remap-path-scope=coverage | ||
LL| |//@[with_object_scope] compile-flags: --remap-path-scope=object | ||
LL| |//@[with_macro_scope] compile-flags: --remap-path-scope=macro | ||
LL| | | ||
LL| 1|fn main() {} | ||
|
10 changes: 10 additions & 0 deletions
10
tests/coverage/remap-path-prefix.with_object_scope.cov-map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Function name: remap_path_prefix::main | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 01, 00, 0a, 01, 00, 0c, 00, 0d] | ||
Number of files: 1 | ||
- file 0 => remapped/remap-path-prefix.rs | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 10) | ||
- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) | ||
Highest counter ID seen: c0 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Function name: remap_path_prefix::main | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 01, 00, 0a, 01, 00, 0c, 00, 0d] | ||
Number of files: 1 | ||
- file 0 => remapped/remap-path-prefix.rs | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 10) | ||
- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) | ||
Highest counter ID seen: c0 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Thanks for driving the stabilization!
"There are no outstanding bugs" probably?
Don't want to block the stabilization. However, this sounds a bit odd that there is no major use cases beyond Cargo and rustc is heading toward stabilization alone. That may imply t-cargo should review again whether
--remap-path-scope
is useful and cover what they want at least (of course this is on me as I worked on Cargo side of this)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.
As far as I know
--remap-path-scope
has no bugs. We have test for all the scopes, with/without dependency and with mixed scopes between crates.It doesn't really surprises me that there are no public use of it. It's quite a pain currently to setup
--remap-path-prefix
and-Zremap-path-scope
in Cargo, as there is currently no support for it, which is what we are trying to solve. I suspect most users are usingRUSTFLAGS
which I don't think is typically committed.Well, be able to see the not-remapped paths in diagnostics is quite nice thing.
The RFC specifically states that the default should be
object
for therelease
profile.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 meant the "no" is missing in the original PR description.
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.
The other thing is that do we want to stabilize all options all at once. I remember that the RFC said we could optionally stabilize some of them. I am not sure whether
macros
anddebuginfo
standalone are useful, as well asdiagnostics
. The most useful thing as you mentioned is probablyobject
and the original behaviorall
.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 don't know that
macros
ordebuginfo
would need to be useful on their own to be worth stabilising, we're able to support them relatively straightforwardly and they may be useful in combination with other options.