Repository navigation
feat(trim-paths): stabilize profile.trim-paths - #17488
Conversation
|
|
||
| /// Allow setting trim-paths in a profile to control the sanitisation of file paths in build outputs. | ||
| (unstable, trim_paths, "", "reference/unstable.html#profile-trim-paths-option"), | ||
| (stable, trim_paths, "1.101", "reference/profiles.html#trim-paths"), |
There was a problem hiding this comment.
Aimed at Rust 1.101
There was a problem hiding this comment.
Set it as draft as it shouldn't be merged before 1.101
There was a problem hiding this comment.
FCP will go past then anyways
|
r? @Muscraft rustbot has assigned @Muscraft. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
@weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This comment has been minimized.
This comment has been minimized.
### What does this PR try to resolve? This was found when addressing <rust-lang#17488 (comment)>: adding trim-paths env vars support in build-rs. Apparently the `unstable` Cargo feature in build-rs has been broken for a long while but nobody noticed. ### How to test and review this PR? New CI step should help verify it. 🤖 LLM disclosure: LLM helped me find new stable cfg name.
5def1e6 to
df6c6e7
Compare
Update cargo submodule 11 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..45c3aacf0e8dabdcdb6b7b518db100061d6367a7 2026-09-29 19:58:08 +0000 to 2026-10-06 16:29:08 +0000 - feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539) - feat(hints): support minimum optimization levels (rust-lang/cargo#17368) - Use trusted publishing for Cargo crates (rust-lang/cargo#17426) - feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488) - fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548) - fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329) - Improved testsuite file permissions cleanup (rust-lang/cargo#17547) - docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546) - Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531) - docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542) - feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
Update cargo submodule 11 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..45c3aacf0e8dabdcdb6b7b518db100061d6367a7 2026-09-29 19:58:08 +0000 to 2026-10-06 16:29:08 +0000 - feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539) - feat(hints): support minimum optimization levels (rust-lang/cargo#17368) - Use trusted publishing for Cargo crates (rust-lang/cargo#17426) - feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488) - fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548) - fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329) - Improved testsuite file permissions cleanup (rust-lang/cargo#17547) - docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546) - Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531) - docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542) - feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
Update cargo submodule 15 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..29c5daa1afc262323364e039bb70c83372cc702c 2026-09-29 19:58:08 +0000 to 2026-10-07 22:13:48 +0000 - test: mark requiring ssh for tests shelling out to it (rust-lang/cargo#17563) - chore(deps): update msrv (rust-lang/cargo#17532) - fix(rustdoc): suppress edition unspecified warnings (rust-lang/cargo#17557) - chore(deps): update cargo-semver-checks to v0.51.0 (rust-lang/cargo#17553) - feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539) - feat(hints): support minimum optimization levels (rust-lang/cargo#17368) - Use trusted publishing for Cargo crates (rust-lang/cargo#17426) - feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488) - fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548) - fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329) - Improved testsuite file permissions cleanup (rust-lang/cargo#17547) - docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546) - Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531) - docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542) - feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
Update cargo submodule 15 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..29c5daa1afc262323364e039bb70c83372cc702c 2026-09-29 19:58:08 +0000 to 2026-10-07 22:13:48 +0000 - test: mark requiring ssh for tests shelling out to it (rust-lang/cargo#17563) - chore(deps): update msrv (rust-lang/cargo#17532) - fix(rustdoc): suppress edition unspecified warnings (rust-lang/cargo#17557) - chore(deps): update cargo-semver-checks to v0.51.0 (rust-lang/cargo#17553) - feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539) - feat(hints): support minimum optimization levels (rust-lang/cargo#17368) - Use trusted publishing for Cargo crates (rust-lang/cargo#17426) - feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488) - fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548) - fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329) - Improved testsuite file permissions cleanup (rust-lang/cargo#17547) - docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546) - Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531) - docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542) - feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
Update cargo submodule 15 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..29c5daa1afc262323364e039bb70c83372cc702c 2026-09-29 19:58:08 +0000 to 2026-10-07 22:13:48 +0000 - test: mark requiring ssh for tests shelling out to it (rust-lang/cargo#17563) - chore(deps): update msrv (rust-lang/cargo#17532) - fix(rustdoc): suppress edition unspecified warnings (rust-lang/cargo#17557) - chore(deps): update cargo-semver-checks to v0.51.0 (rust-lang/cargo#17553) - feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539) - feat(hints): support minimum optimization levels (rust-lang/cargo#17368) - Use trusted publishing for Cargo crates (rust-lang/cargo#17426) - feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488) - fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548) - fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329) - Improved testsuite file permissions cleanup (rust-lang/cargo#17547) - docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546) - Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531) - docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542) - feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for rust-lang#166301, but this PR is otherwise unrelated to that issue.
bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for rust-lang#166301, but this PR is otherwise unrelated to that issue.
bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for rust-lang#166301, but this PR is otherwise unrelated to that issue.
Rollup merge of #166306 - Zalathar:trim-paths, r=Urgau bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for #166301, but this PR is otherwise unrelated to that issue.
bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for rust-lang/rust#166301, but this PR is otherwise unrelated to that issue.
bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta Cargo's `trim-paths` was stabilized in rust-lang/cargo#17488, so passing `-Ztrim-paths` will now trigger a warning in cargo 1.101, which is what we're using for our stage0 toolchain. ```text warning: flag `-Z trim-paths` has been stabilized in the 1.101 release, and is no longer necessary The `trim-paths` profile option is now always available. ``` This PR resolves that warning by no longer passing the unnecessary `-Ztrim-paths`. Path-trimming seems to only occur when `rust.remap-debuginfo` is true in bootstrap.toml, so the warning isn't seen in most local builds, but it can be seen in CI logs for dist jobs. --- Discovered while looking at CI logs for rust-lang/rust#166301, but this PR is otherwise unrelated to that issue.
…uillaumeGomez Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope # Stabilization report of `--remap-path-scope` in rustdoc and the `documentation` scope ## Summary `rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc. This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files. This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`. Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. Tracking issue: #155451. It's the last major part of the trim-paths feature. ### What is stabilized The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope). It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation ``` #### The `documentation` In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)). ## Implementation ### Major parts - #155357 - #151589 - #163956 - #164278 - #164279 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs) - [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`. There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. ### Outstanding FIXMEs There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc). Fixes #163896 Fixes #155451
…ustdoc, r=GuillaumeGomez Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope # Stabilization report of `--remap-path-scope` in rustdoc and the `documentation` scope ## Summary `rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc. This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files. This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`. Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. Tracking issue: rust-lang#155451. It's the last major part of the trim-paths feature. ### What is stabilized The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope). It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation ``` #### The `documentation` In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](rust-lang#163896)). ## Implementation ### Major parts - rust-lang#155357 - rust-lang#151589 - rust-lang#163956 - rust-lang#164278 - rust-lang#164279 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs) - [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`. There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. ### Outstanding FIXMEs There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc). Fixes rust-lang#163896 Fixes rust-lang#155451
…, r=Urgau debugger: stabilize trim-paths unremap file loading ## Stabilization report ### What is stabilized With trim-paths `object` scope and debuginfo on, Cargo writes `<artifact>.trim-paths.json`[^1] beside each final artifact. This "unremap" file, maps the remapped paths back to local ones. The file format and remapping rules are stabilized as part of FCP on Cargo side: rust-lang/cargo#17488 This stabilizes debugger script changes: `rust-gdb` and `rust-lldb` by default load `{gdb,lldb}_trim_paths.py`, which read the unremap files and apply them through GDB `substitute-path` or LLDB `target.source-map` to set up source file path substitutions. Note that we already apply an unremap for `/rustc/$RUSTC_COMMIT_HASH` paths, so it wouldn't be a new capability per se, just an extension of it. ### What changes * After stabilization, set `RUST_{GDB,LLDB}_TRIM_PATHS=0` to opt out. Before, it required `RUST_{GDB,LLDB}_TRIM_PATHS=unstable` to enable. * After stabilization, both scripts are shipped on all channels. Before, they were shipped only on nightly. ### Why we don't want to stabilize * This makes debugger scripts relying on Cargo-specific file format, inversing the dependency relation. * There is no integration test for them. (and debugger scripts actually don't have many tests) ### Docs See Cargo's the "Unremap files" section: <https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#unremap-files>. > The unremap file is in JSON format: > > * `v` carries the format version. > * `rust_version` and `workspace_root` are file-level metadata, namely the toolchain version and the workspace root. > * `remaps` is an array of records. Each record maps a sanitized path prefix in the artifact (`from`) back to the local path it replaced (`to`), ordered by the `from` prefix. Note that this follows the debugger substitution direction, which is the inverse of `--remap-path-prefix`. > > An example of the unremap file: > > ```json > { > "v": 1, > "rust_version": "1.96.0-nightly", > "workspace_root": "/home/me/app", > "remaps": [ > { "from": ".", "to": "/home/me/app" }, > { "from": "/cargo/build-dir", "to": "/home/me/app/target" }, > { "from": "/cargo/registry/6f17d22d3f0a95d1", "to": "/home/me/.cargo/registry/src/index.crates.io-6f17d22d3f0a95d1" }, > { "from": "/rustc/abc123", "to": "/home/me/.rustup/toolchains/nightly/lib/rustlib/src/rust" } > ] > } > ``` > > Since it is meant to be a debugging aid, it includes absolute paths of your system, so there is no artifact privacy guarantee. You might want to exclude `*.trim-paths.json` files when distributing artifacts. --- Should be shipped after <rust-lang#163881> (or along with that)
…uillaumeGomez Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope # Stabilization report of `--remap-path-scope` in rustdoc and the `documentation` scope ## Summary `rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc. This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files. This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`. Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. Tracking issue: #155451. It's the last major part of the trim-paths feature. ### What is stabilized The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope). It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation ``` #### The `documentation` In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)). ## Implementation ### Major parts - #155357 - #151589 - #163956 - #164278 - #164279 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs) - [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`. There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. ### Outstanding FIXMEs There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc). Fixes #163896 Fixes #155451
…ustdoc, r=GuillaumeGomez Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope # Stabilization report of `--remap-path-scope` in rustdoc and the `documentation` scope ## Summary `rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc. This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files. This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`. Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. Tracking issue: rust-lang#155451. It's the last major part of the trim-paths feature. ### What is stabilized The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope). It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation ``` #### The `documentation` In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](rust-lang#163896)). ## Implementation ### Major parts - rust-lang#155357 - rust-lang#151589 - rust-lang#163956 - rust-lang#164278 - rust-lang#164279 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs) - [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`. There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. ### Outstanding FIXMEs There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc). Fixes rust-lang#163896 Fixes rust-lang#155451
…, r=Urgau debugger: stabilize trim-paths unremap file loading ## Stabilization report ### What is stabilized With trim-paths `object` scope and debuginfo on, Cargo writes `<artifact>.trim-paths.json`[^1] beside each final artifact. This "unremap" file, maps the remapped paths back to local ones. The file format and remapping rules are stabilized as part of FCP on Cargo side: rust-lang/cargo#17488 This stabilizes debugger script changes: `rust-gdb` and `rust-lldb` by default load `{gdb,lldb}_trim_paths.py`, which read the unremap files and apply them through GDB `substitute-path` or LLDB `target.source-map` to set up source file path substitutions. Note that we already apply an unremap for `/rustc/$RUSTC_COMMIT_HASH` paths, so it wouldn't be a new capability per se, just an extension of it. ### What changes * After stabilization, set `RUST_{GDB,LLDB}_TRIM_PATHS=0` to opt out. Before, it required `RUST_{GDB,LLDB}_TRIM_PATHS=unstable` to enable. * After stabilization, both scripts are shipped on all channels. Before, they were shipped only on nightly. ### Why we don't want to stabilize * This makes debugger scripts relying on Cargo-specific file format, inversing the dependency relation. * There is no integration test for them. (and debugger scripts actually don't have many tests) ### Docs See Cargo's the "Unremap files" section: <https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#unremap-files>. > The unremap file is in JSON format: > > * `v` carries the format version. > * `rust_version` and `workspace_root` are file-level metadata, namely the toolchain version and the workspace root. > * `remaps` is an array of records. Each record maps a sanitized path prefix in the artifact (`from`) back to the local path it replaced (`to`), ordered by the `from` prefix. Note that this follows the debugger substitution direction, which is the inverse of `--remap-path-prefix`. > > An example of the unremap file: > > ```json > { > "v": 1, > "rust_version": "1.96.0-nightly", > "workspace_root": "/home/me/app", > "remaps": [ > { "from": ".", "to": "/home/me/app" }, > { "from": "/cargo/build-dir", "to": "/home/me/app/target" }, > { "from": "/cargo/registry/6f17d22d3f0a95d1", "to": "/home/me/.cargo/registry/src/index.crates.io-6f17d22d3f0a95d1" }, > { "from": "/rustc/abc123", "to": "/home/me/.rustup/toolchains/nightly/lib/rustlib/src/rust" } > ] > } > ``` > > Since it is meant to be a debugging aid, it includes absolute paths of your system, so there is no artifact privacy guarantee. You might want to exclude `*.trim-paths.json` files when distributing artifacts. --- Should be shipped after <rust-lang#163881> (or along with that)
Rollup merge of #163895 - Urgau:stabilize-remap-path-scope-rustdoc, r=GuillaumeGomez Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope # Stabilization report of `--remap-path-scope` in rustdoc and the `documentation` scope ## Summary `rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc. This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files. This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`. Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. Tracking issue: #155451. It's the last major part of the trim-paths feature. ### What is stabilized The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope). It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation ``` #### The `documentation` In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)). ## Implementation ### Major parts - #155357 - #151589 - #163956 - #164278 - #164279 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs) - [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs) - [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs) - [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`. There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. ### Outstanding FIXMEs There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc). Fixes #163896 Fixes #155451
Rollup merge of #163910 - weihanglo:trim-paths-stabilization, r=Urgau debugger: stabilize trim-paths unremap file loading ## Stabilization report ### What is stabilized With trim-paths `object` scope and debuginfo on, Cargo writes `<artifact>.trim-paths.json`[^1] beside each final artifact. This "unremap" file, maps the remapped paths back to local ones. The file format and remapping rules are stabilized as part of FCP on Cargo side: rust-lang/cargo#17488 This stabilizes debugger script changes: `rust-gdb` and `rust-lldb` by default load `{gdb,lldb}_trim_paths.py`, which read the unremap files and apply them through GDB `substitute-path` or LLDB `target.source-map` to set up source file path substitutions. Note that we already apply an unremap for `/rustc/$RUSTC_COMMIT_HASH` paths, so it wouldn't be a new capability per se, just an extension of it. ### What changes * After stabilization, set `RUST_{GDB,LLDB}_TRIM_PATHS=0` to opt out. Before, it required `RUST_{GDB,LLDB}_TRIM_PATHS=unstable` to enable. * After stabilization, both scripts are shipped on all channels. Before, they were shipped only on nightly. ### Why we don't want to stabilize * This makes debugger scripts relying on Cargo-specific file format, inversing the dependency relation. * There is no integration test for them. (and debugger scripts actually don't have many tests) ### Docs See Cargo's the "Unremap files" section: <https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#unremap-files>. > The unremap file is in JSON format: > > * `v` carries the format version. > * `rust_version` and `workspace_root` are file-level metadata, namely the toolchain version and the workspace root. > * `remaps` is an array of records. Each record maps a sanitized path prefix in the artifact (`from`) back to the local path it replaced (`to`), ordered by the `from` prefix. Note that this follows the debugger substitution direction, which is the inverse of `--remap-path-prefix`. > > An example of the unremap file: > > ```json > { > "v": 1, > "rust_version": "1.96.0-nightly", > "workspace_root": "/home/me/app", > "remaps": [ > { "from": ".", "to": "/home/me/app" }, > { "from": "/cargo/build-dir", "to": "/home/me/app/target" }, > { "from": "/cargo/registry/6f17d22d3f0a95d1", "to": "/home/me/.cargo/registry/src/index.crates.io-6f17d22d3f0a95d1" }, > { "from": "/rustc/abc123", "to": "/home/me/.rustup/toolchains/nightly/lib/rustlib/src/rust" } > ] > } > ``` > > Since it is meant to be a debugging aid, it includes absolute paths of your system, so there is no artifact privacy guarantee. You might want to exclude `*.trim-paths.json` files when distributing artifacts. --- Should be shipped after <#163881> (or along with that)
View all comments
Stabilization report:
profile.trim-pathsResolves #12137
Resolves rust-lang/rust#111540
RFC: https://rust-lang.github.io/rfcs/3127-trim-paths.html
What is stabilized
The rustc side
--remap-path-scopewas already stabilized in Rust 1.95 via rust-lang/rust#147611This stabilizes the Cargo side:
profile.<name>.trim-paths = "none" | "object" | "all"in both manifest and config
--remap-path-{prefix,scope}.The exact remap prefixes still stay unspecified.
<artifact>.trim-paths.json(schema v1),which is emitted beside final artifacts when debuginfo is on.
CARGO_TRIM_PATHS_SCOPEandCARGO_TRIM_PATHS_REMAPfor build scripts.When this is merged and sync in rust-lang/rust,
we'll also stabilize
rust-gdbandrust-lldbunremap loaders.RUST_GDB_TRIM_PATHS=unstableandRUST_LLDB_TRIM_PATHS=unstableare not needed anymore.See doc for details:
cargo/doc/book/src/reference/unstable.md
Lines 1441 to 1645 in 8814ead
What is not stabilized / included
--remap-path-scopevalues in rustc (macro,diagnostics,debuginfo,coverage),boolean values, and comma-separated list options.
These are removed in fix(trim-paths)!: limit options to
none|object|all#17432.They can come back later when needed.
RFC originall proposed to set
releaseto"object".This is left for future when this is more adopted and battle-tested.
We have loose stability guarantee for changing profile settings anyway.
__CARGO_RUSTC_BOOTSTRAP_WS_REMAP.This stays as an internal thing between rustc bootstrap and cargo
(see feat(trim-paths): honor workspace prefix override from env #17349, fix(trim-paths): custom workspace-relative member paths remap #17366)
documentationscope.This will be integrated in the future incrementally
when those scopes and features are stable.
However, in practice,
rustc bootstrap and debugger depend on the stabilized shape,
so any change needs careful coordination with them.
build-rsAPI for the two build script variables: deferred, non-blocking.Doors closed
.trim-paths.jsonand the v1 schema.CARGO_TRIM_PATHS_SCOPEandCARGO_TRIM_PATHS_REMAP.Post-RFC changes
split-debuginfoscopes,and Cargo followed and stopped caring split debuginfo.
<name>-<version>.In fix(trim-paths): unambiguous and reversible remap rules #17302 we chose workspace members relative remap,
so debuggers resolve workspace sources with zero configuration.
The RFC worried that relative paths only work when running from the right directory,
and symbolication tools need a second process for joining workspace relative paths.
THe unremap file has
workspace_root, so the join is fairly mechanical.Remap prefixes are unspecified anyway,
so we can still change if it turns out not ideal.
for helping debugging find sources,
as well as our keeping remap rules unspecified.
The RFC had no answer about this.
CARGO_TRIM_PATHS_REMAPbuild script env is new.It lets build scripts forward the same rules to C/C++ compilers to flags like
-fmacro-prefix-map.cc-rshas integrated that since feat: inherit path remap rules from cargo trim-paths cc-rs#1794.Feedback
trim-pathsvia bootstrap: leverage cargo trim-paths rust#161049 since 2026-09-02.
This exercises the sysroot remap and the workspace prefix override in rust-lang/rust CI.
cc-rsforwards the remap rules to C/C++ compiler since 1.3.0: https://github.com/rust-lang/cc-rs/releases/tag/cc-v1.3.0Known limitations
This sanitization is best-effort. See
cargo/doc/book/src/reference/unstable.md
Lines 1603 to 1626 in 8814ead
Implementation
History
-Ztrim-pathsCARGO_TRIM_PATHSfor build scriptstrim-pathsfrom different profilesOSOandSOcannot be trimmedbuild.build-dir--remap-path-scopestabilized in 1.95-nightlyCARGO_TRIM_PATHS_REMAPfor build.rs/cargo/depsfallback sourcesnone|object|allbuild-rssupportTest coverage
"object"with everysplit-debuginfomode"all"diagnostics remapping for rustc and rustdoccargo clean, JSON messages-Zbuild-stdbacktraces show/rustc/<hash>pathsFollow-ups after stabilization
Absolute paths of workspace and
CARGO_HOMEstill get into-Cmetadata/-Cextra-filename/fingerprints.With
trim-paths = "object"we might be able to also trim paths in those places.releasetrim-pathsin built-in profiles #17586src/etc/gdb_trim_paths.pyandsrc/etc/lldb_trim_paths.pydebugger: stabilize trim-paths unremap file loading rust#163910build-rsaddingCARGO_TRIM_PATHS_SCOPEandCARGO_TRIM_PATHS_REMAPsupport feat(build-rs): trim-paths inputs #17491cargo docand doc artifacts #17555🤖 LLM disclosure: impl history was generated. heading was generated. meats are human-written.