-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Improve -Zremap-path-scope tests with dependency
#140716
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
Conversation
jieyouxu
left a comment
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, these are very nice 💙
|
@bors r+ rollup |
…=jieyouxu Improve `-Zremap-path-scope` tests with dependency This PR greatly improves our coverage of `-Zremap-path-scope` for diagnostic paths and macros with dependencies. r? `@jieyouxu` (since we talked about it)
Rollup of 15 pull requests Successful merges: - rust-lang#138736 (Sanitizers target modificators) - rust-lang#140260 (Only prefer param-env candidates if they remain non-global after norm) - rust-lang#140523 (Better error message for late/early lifetime param mismatch) - rust-lang#140579 (Remove estebank from automated review assignment) - rust-lang#140641 (detect additional uses of opaques after writeback) - rust-lang#140711 (Do not discard constraints on overflow if there was candidate ambiguity) - rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency) - rust-lang#140755 ([win][arm64] Disable various DebugInfo tests that don't work on Arm64 Windows) - rust-lang#140756 ([arm64] Pointer auth test should link with C static library statically) - rust-lang#140758 ([win][arm64] Disable MSVC Linker 'Arm Hazard' warning) - rust-lang#140759 ([win][arm64] Disable std::fs tests that require symlinks) - rust-lang#140762 (rustdoc-json: Remove newlines from attributes) - rust-lang#140764 (style: Never break within a nullary function call `func()` or a unit literal `()`) - rust-lang#140769 (Add `DefPathData::OpaqueLifetime` to avoid conflicts for remapped opaque lifetimes) - rust-lang#140773 (triagebot: Better message for changes to `tests/rustdoc-json`) r? `@ghost` `@rustbot` modify labels: rollup
…=jieyouxu Improve `-Zremap-path-scope` tests with dependency This PR greatly improves our coverage of `-Zremap-path-scope` for diagnostic paths and macros with dependencies. r? ``@jieyouxu`` (since we talked about it)
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency) - rust-lang#140732 (make it possible to run in-tree rustfmt with `x run rustfmt`) - rust-lang#140736 (trait selection: check `&` before suggest remove deref) - rust-lang#140755 ([win][arm64] Disable various DebugInfo tests that don't work on Arm64 Windows) - rust-lang#140756 ([arm64] Pointer auth test should link with C static library statically) - rust-lang#140758 ([win][arm64] Disable MSVC Linker 'Arm Hazard' warning) - rust-lang#140759 ([win][arm64] Disable std::fs tests that require symlinks) r? `@ghost` `@rustbot` modify labels: rollup
e534797 to
f959039
Compare
|
@bors try |
…try> Improve `-Zremap-path-scope` tests with dependency This PR greatly improves our coverage of `-Zremap-path-scope` for diagnostic paths and macros with dependencies. r? `@jieyouxu` (since we talked about it) try-job: x86_64-msvc-1
|
☀️ Try build successful - checks-actions |
|
Removed the @bors r=jieyouxu |
…=jieyouxu Improve `-Zremap-path-scope` tests with dependency This PR greatly improves our coverage of `-Zremap-path-scope` for diagnostic paths and macros with dependencies. r? ``@jieyouxu`` (since we talked about it) try-job: x86_64-msvc-1
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#140095 (Eliminate `word_and_empty` methods.) - rust-lang#140341 (Clarify black_box warning a bit) - rust-lang#140684 (Only include `dyn Trait<Assoc = ...>` associated type bounds for `Self: Sized` associated types if they are provided) - rust-lang#140707 (Structurally normalize in range pattern checking in HIR typeck) - rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency) - rust-lang#140800 (Make `rustdoc-tempdir-removal` run-make tests work on other platforms than linux) - rust-lang#140802 (Add release notes for 1.87.0) - rust-lang#140811 (Enable triagebot note functionality for rust-lang/rust) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#140716 - Urgau:improve-remap_scope-tests, r=jieyouxu Improve `-Zremap-path-scope` tests with dependency This PR greatly improves our coverage of `-Zremap-path-scope` for diagnostic paths and macros with dependencies. r? `@jieyouxu` (since we talked about it) try-job: x86_64-msvc-1
…twco Stabilize `-Zremap-path-scope` # 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 named `trim-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: - rust-lang#111540 ### 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 of `std::file!()` macro. This is where paths in embedded panic messages come from - `diagnostics` - apply remappings to printed compiler diagnostics - `debuginfo` - apply remappings to debug informations - `coverage` - apply remappings to coverage informations - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`. - `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. #### Example ```sh # With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped. rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs ``` ### What isn't stabilized None of the Cargo facility is being stabilized in this stabilization PR, only the `--remap-path-scope` flag in `rustc` is being stabilized. ## Design ### RFC history - [RFC3127 - trim-paths](https://rust-lang.github.io/rfcs/3127-trim-paths.html) ### Answers to unresolved questions > What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions. 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 picture `trim-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 rust-lang#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 > Has a "call for testing" been done? If so, what feedback was received? 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 > Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative. Except for Cargo unstable `trim-paths` there doesn't appear any committed use [on GitHub](https://github.com/search?q=%22--remap-path-scope%22+NOT+path%3A%2F%5Esrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F+NOT+path%3A%2F%5Etext%5C%2F%2F+NOT+path%3A%2F%5Erust%5C%2Fsrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Esrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Ecollector%5C%2Fcompile-benchmarks%5C%2Fcargo-0%5C.87%5C.1%5C%2Fsrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F&type=code). ## Implementation ### Major parts - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/config.rs#L1373-L1384 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/session.rs#L1526 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_span/src/lib.rs#L352-L372 ### Coverage - [`tests/run-make/split-debuginfo/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/split-debuginfo/rmake.rs#L7) - [`tests/ui/errors/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix.rs#L4) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-macro.rs#L1-L4) - [`tests/run-make/remap-path-prefix-dwarf/rmake.rs `](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix-dwarf/rmake.rs) - [`tests/run-make/remap-path-prefix/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix/rmake.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs > What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not. There are no outstanding bugs regarding `--remap-path-scope`. ### Outstanding FIXMEs > What FIXMEs are still in the code for that feature and why is it OK to leave them there? There are no FIXME regarding `--remap-path-scope` in it-self. ### Tool changes > What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues. - rustdoc (both JSON, HTML and doctest) - `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 (replace `debuginfo` with `documentation` for example). ## History > List issues and PRs that are important for understanding how we got here. - rust-lang#115214 - rust-lang#122450 - rust-lang#139550 - rust-lang#140716 ## Acknowledgments > Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this *not* think it should be stabilized right now? We'd like to hear about that if so. - @cbeuw - @michaelwoerister - @weihanglo - @Urgau @rustbot labels +T-compiler +needs-fcp +F-trim-paths r? @davidtwco
Rollup merge of #147611 - stablize-remap-path-scope, r=davidtwco Stabilize `-Zremap-path-scope` # 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 named `trim-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: - #111540 ### 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 of `std::file!()` macro. This is where paths in embedded panic messages come from - `diagnostics` - apply remappings to printed compiler diagnostics - `debuginfo` - apply remappings to debug informations - `coverage` - apply remappings to coverage informations - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`. - `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. #### Example ```sh # With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped. rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs ``` ### What isn't stabilized None of the Cargo facility is being stabilized in this stabilization PR, only the `--remap-path-scope` flag in `rustc` is being stabilized. ## Design ### RFC history - [RFC3127 - trim-paths](https://rust-lang.github.io/rfcs/3127-trim-paths.html) ### Answers to unresolved questions > What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions. 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 picture `trim-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 > Has a "call for testing" been done? If so, what feedback was received? 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 > Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative. Except for Cargo unstable `trim-paths` there doesn't appear any committed use [on GitHub](https://github.com/search?q=%22--remap-path-scope%22+NOT+path%3A%2F%5Esrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F+NOT+path%3A%2F%5Etext%5C%2F%2F+NOT+path%3A%2F%5Erust%5C%2Fsrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Esrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Ecollector%5C%2Fcompile-benchmarks%5C%2Fcargo-0%5C.87%5C.1%5C%2Fsrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F&type=code). ## Implementation ### Major parts - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/config.rs#L1373-L1384 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/session.rs#L1526 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_span/src/lib.rs#L352-L372 ### Coverage - [`tests/run-make/split-debuginfo/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/split-debuginfo/rmake.rs#L7) - [`tests/ui/errors/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix.rs#L4) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-macro.rs#L1-L4) - [`tests/run-make/remap-path-prefix-dwarf/rmake.rs `](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix-dwarf/rmake.rs) - [`tests/run-make/remap-path-prefix/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix/rmake.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs > What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not. There are no outstanding bugs regarding `--remap-path-scope`. ### Outstanding FIXMEs > What FIXMEs are still in the code for that feature and why is it OK to leave them there? There are no FIXME regarding `--remap-path-scope` in it-self. ### Tool changes > What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues. - rustdoc (both JSON, HTML and doctest) - `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 (replace `debuginfo` with `documentation` for example). ## History > List issues and PRs that are important for understanding how we got here. - #115214 - #122450 - #139550 - #140716 ## Acknowledgments > Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this *not* think it should be stabilized right now? We'd like to hear about that if so. - @cbeuw - @michaelwoerister - @weihanglo - @Urgau @rustbot labels +T-compiler +needs-fcp +F-trim-paths r? @davidtwco
Stabilize `-Zremap-path-scope` # 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 named `trim-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: - rust-lang/rust#111540 ### 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 of `std::file!()` macro. This is where paths in embedded panic messages come from - `diagnostics` - apply remappings to printed compiler diagnostics - `debuginfo` - apply remappings to debug informations - `coverage` - apply remappings to coverage informations - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`. - `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. #### Example ```sh # With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped. rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs ``` ### What isn't stabilized None of the Cargo facility is being stabilized in this stabilization PR, only the `--remap-path-scope` flag in `rustc` is being stabilized. ## Design ### RFC history - [RFC3127 - trim-paths](https://rust-lang.github.io/rfcs/3127-trim-paths.html) ### Answers to unresolved questions > What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions. 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 picture `trim-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 rust-lang/rust#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 > Has a "call for testing" been done? If so, what feedback was received? 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 > Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative. Except for Cargo unstable `trim-paths` there doesn't appear any committed use [on GitHub](https://github.com/search?q=%22--remap-path-scope%22+NOT+path%3A%2F%5Esrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F+NOT+path%3A%2F%5Etext%5C%2F%2F+NOT+path%3A%2F%5Erust%5C%2Fsrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Esrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Ecollector%5C%2Fcompile-benchmarks%5C%2Fcargo-0%5C.87%5C.1%5C%2Fsrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F&type=code). ## Implementation ### Major parts - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/config.rs#L1373-L1384 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/session.rs#L1526 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_span/src/lib.rs#L352-L372 ### Coverage - [`tests/run-make/split-debuginfo/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/split-debuginfo/rmake.rs#L7) - [`tests/ui/errors/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix.rs#L4) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-macro.rs#L1-L4) - [`tests/run-make/remap-path-prefix-dwarf/rmake.rs `](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix-dwarf/rmake.rs) - [`tests/run-make/remap-path-prefix/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix/rmake.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs > What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not. There are no outstanding bugs regarding `--remap-path-scope`. ### Outstanding FIXMEs > What FIXMEs are still in the code for that feature and why is it OK to leave them there? There are no FIXME regarding `--remap-path-scope` in it-self. ### Tool changes > What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues. - rustdoc (both JSON, HTML and doctest) - `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 (replace `debuginfo` with `documentation` for example). ## History > List issues and PRs that are important for understanding how we got here. - rust-lang/rust#115214 - rust-lang/rust#122450 - rust-lang/rust#139550 - rust-lang/rust#140716 ## Acknowledgments > Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this *not* think it should be stabilized right now? We'd like to hear about that if so. - @cbeuw - @michaelwoerister - @weihanglo - @Urgau @rustbot labels +T-compiler +needs-fcp +F-trim-paths r? @davidtwco
Stabilize `-Zremap-path-scope` # 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 named `trim-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: - rust-lang/rust#111540 ### 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 of `std::file!()` macro. This is where paths in embedded panic messages come from - `diagnostics` - apply remappings to printed compiler diagnostics - `debuginfo` - apply remappings to debug informations - `coverage` - apply remappings to coverage informations - `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`. - `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`. #### Example ```sh # With `object` scope only the build outputs will be remapped, the diagnostics won't be remapped. rustc --remap-path-prefix=$(PWD)=/remapped --remap-path-scope=object main.rs ``` ### What isn't stabilized None of the Cargo facility is being stabilized in this stabilization PR, only the `--remap-path-scope` flag in `rustc` is being stabilized. ## Design ### RFC history - [RFC3127 - trim-paths](https://rust-lang.github.io/rfcs/3127-trim-paths.html) ### Answers to unresolved questions > What questions were left unresolved by the RFC? How have they been answered? Link to any relevant lang decisions. 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 picture `trim-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 rust-lang/rust#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 > Has a "call for testing" been done? If so, what feedback was received? 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 > Do any known nightly users use this feature? Counting instances of `#![feature(FEATURE_NAME)]` on GitHub with grep might be informative. Except for Cargo unstable `trim-paths` there doesn't appear any committed use [on GitHub](https://github.com/search?q=%22--remap-path-scope%22+NOT+path%3A%2F%5Esrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F+NOT+path%3A%2F%5Etext%5C%2F%2F+NOT+path%3A%2F%5Erust%5C%2Fsrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Esrc%5C%2Fdoc%5C%2Funstable-book%5C%2Fsrc%5C%2Fcompiler-flags%5C%2F%2F+NOT+path%3A%2F%5Ecollector%5C%2Fcompile-benchmarks%5C%2Fcargo-0%5C.87%5C.1%5C%2Fsrc%5C%2Fcargo%5C%2Fcore%5C%2Fcompiler%5C%2F%2F&type=code). ## Implementation ### Major parts - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/config.rs#L1373-L1384 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_session/src/session.rs#L1526 - https://github.com/rust-lang/rust/blob/b3f8586fb1e4859678d6b231e780ff81801d2282/compiler/rustc_span/src/lib.rs#L352-L372 ### Coverage - [`tests/run-make/split-debuginfo/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/split-debuginfo/rmake.rs#L7) - [`tests/ui/errors/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix.rs#L4) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-macro.rs#L1-L4) - [`tests/run-make/remap-path-prefix-dwarf/rmake.rs `](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix-dwarf/rmake.rs) - [`tests/run-make/remap-path-prefix/rmake.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/run-make/remap-path-prefix/rmake.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/9725c4baacef19345e13f91b27e66e10ef5592ae/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs > What outstanding bugs involve this feature? List them. Should any block the stabilization? Discuss why or why not. There are no outstanding bugs regarding `--remap-path-scope`. ### Outstanding FIXMEs > What FIXMEs are still in the code for that feature and why is it OK to leave them there? There are no FIXME regarding `--remap-path-scope` in it-self. ### Tool changes > What changes must be made to our other tools to support this feature. Has this work been done? Link to any relevant PRs and issues. - rustdoc (both JSON, HTML and doctest) - `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 (replace `debuginfo` with `documentation` for example). ## History > List issues and PRs that are important for understanding how we got here. - rust-lang/rust#115214 - rust-lang/rust#122450 - rust-lang/rust#139550 - rust-lang/rust#140716 ## Acknowledgments > Summarize contributors to the feature by name for recognition and so that those people are notified about the stabilization. Does anyone who worked on this *not* think it should be stabilized right now? We'd like to hear about that if so. - @cbeuw - @michaelwoerister - @weihanglo - @Urgau @rustbot labels +T-compiler +needs-fcp +F-trim-paths r? @davidtwco
This PR greatly improves our coverage of
-Zremap-path-scopefor diagnostic paths and macros with dependencies.r? @jieyouxu (since we talked about it)
try-job: x86_64-msvc-1