fix(trim-paths)!: limit options to none|object|all - #17432
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| > [!NOTE] | ||
| > For forward compatibility, | ||
| > build scripts should accept a comma-separated list of scopes. | ||
| * `CARGO_TRIM_PATHS_REMAP` --- The `<from>=<to>` path remap pairs Cargo passes to the compiler, |
There was a problem hiding this comment.
Aside: do we support this yet in build-rs?
There was a problem hiding this comment.
Sure! I am still thinking about a reasonable API.
My hope is that popular helper build dep dependencies use them, like cc-rs which already supports. Application build scripts likely don't need this. cc-rs likely has covered 95% of the use cases (including cmake-rs which takes cc-rs as a dependency).
| `trim-paths` is a profile setting which enables and controls the sanitization of file paths in build outputs. | ||
| It takes the following values: | ||
|
|
||
| - `"none"` --- disable path sanitization | ||
| - `"macro"` --- sanitize paths in the expansion of `std::file!()` macro. | ||
| This is where paths in embedded panic messages come from | ||
| - `"diagnostics"` --- sanitize paths in printed compiler diagnostics | ||
| - `"object"` --- sanitize paths in compiled executables or libraries | ||
| - `"all"` --- sanitize paths in all possible locations | ||
| The `trim-paths` option controls path sanitization in build outputs. | ||
| It uses rustc's [`--remap-path-scope`] to control the scope where paths are sanitized, | ||
| while Cargo supplies the path-prefix mappings described in the [remapping rules]. | ||
|
|
||
| It also takes an array with the combinations of `"macro"`, `"diagnostics"`, and `"object"`. | ||
| The valid options are `"none"`, `"object"`, and `"all"`. | ||
| `"none"` disables sanitization. | ||
| The other values select the corresponding rustc remapping scope. |
There was a problem hiding this comment.
This looks like we are removing the docs that distinguish between object and all
There was a problem hiding this comment.
I tried to minimize this to avoid duplicating docs on rustc side. Oour profile doc is mixed. For strip and split-debuginfo we don't have docs for each, while for debug and opt-level we do enumerate them. Do you think this worth explicit docs and also talking about use cases in Cargo doc?
There was a problem hiding this comment.
Okay, after reading other comments
- fix(trim-paths)!: limit options to
none|object|all#17432 (comment) - fix(trim-paths)!: limit options to
none|object|all#17432 (comment)
I think we should have some minimal docs for each options, which I think can address most of doc issues.
There was a problem hiding this comment.
Updated. I hope that clarifies things.
| This is where paths in embedded panic messages come from | ||
| - `"diagnostics"` --- sanitize paths in printed compiler diagnostics | ||
| - `"object"` --- sanitize paths in compiled executables or libraries | ||
| - `"all"` --- sanitize paths in all possible locations |
There was a problem hiding this comment.
Does r-a or any other tool need a heads up that with all, diagnostics won't point to valid files?
There was a problem hiding this comment.
We should document issue and perhaps put a warning as precaution. And yes good idea when stabilizing we should let tool authors know about it
| while Cargo supplies the path-prefix mappings described in the [remapping rules]. | ||
|
|
||
| It also takes an array with the combinations of `"macro"`, `"diagnostics"`, and `"object"`. | ||
| The valid options are `"none"`, `"object"`, and `"all"`. |
There was a problem hiding this comment.
If we're looking to drop things, what are the use cases for having both object and all?
There was a problem hiding this comment.
object, like you have mentioned, preserves certain debuggability and local development experience.
all is more fore hermetic builds to sanitize as many locations as possible. One of the biggest difference is metadata output. Metadadta in in dylib and proc-macors are only remapped in the all scope. When I test this with some caching service, without remapping all for proc-macros, the artifact checksum mismatches and cache missed. See rust-lang/rust#159621
c72071f to
0480619
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
0480619 to
e7c7688
Compare
Update cargo submodule 9 commits in b2e9d5f9db3fb1c454ab84f10c16508984a266e2..3c0b534756e166d12eb9fd2e1abfe5b42ac6101e 2026-09-02 14:49:16 +0000 to 2026-09-04 17:03:10 +0000 - fix(trim-paths)!: limit options to `none|object|all` (rust-lang/cargo#17432) - fix(git): Apply pr hint to git-fetch-with-cli (rust-lang/cargo#17437) - fix(git): Make PR dep note cloer to our style guide (rust-lang/cargo#17436) - docs: clarify cargo vendor source config option (rust-lang/cargo#17435) - docs(trim-paths): workspace remap begins with `.` (rust-lang/cargo#17433) - docs: Switch from "target triple" to "target tuple" (rust-lang/cargo#17430) - docs(trim-paths): add limitations and polish (rust-lang/cargo#17425) - fix(git): Simplify error message (rust-lang/cargo#17429) - chore(deps): update rust crate base64 to 0.23.0 (rust-lang/cargo#17418)
Update cargo submodule 9 commits in b2e9d5f9db3fb1c454ab84f10c16508984a266e2..3c0b534756e166d12eb9fd2e1abfe5b42ac6101e 2026-09-02 14:49:16 +0000 to 2026-09-04 17:03:10 +0000 - fix(trim-paths)!: limit options to `none|object|all` (rust-lang/cargo#17432) - fix(git): Apply pr hint to git-fetch-with-cli (rust-lang/cargo#17437) - fix(git): Make PR dep note cloer to our style guide (rust-lang/cargo#17436) - docs: clarify cargo vendor source config option (rust-lang/cargo#17435) - docs(trim-paths): workspace remap begins with `.` (rust-lang/cargo#17433) - docs: Switch from "target triple" to "target tuple" (rust-lang/cargo#17430) - docs(trim-paths): add limitations and polish (rust-lang/cargo#17425) - fix(git): Simplify error message (rust-lang/cargo#17429) - chore(deps): update rust crate base64 to 0.23.0 (rust-lang/cargo#17418)
Update cargo submodule 9 commits in b2e9d5f9db3fb1c454ab84f10c16508984a266e2..3c0b534756e166d12eb9fd2e1abfe5b42ac6101e 2026-09-02 14:49:16 +0000 to 2026-09-04 17:03:10 +0000 - fix(trim-paths)!: limit options to `none|object|all` (rust-lang/cargo#17432) - fix(git): Apply pr hint to git-fetch-with-cli (rust-lang/cargo#17437) - fix(git): Make PR dep note cloer to our style guide (rust-lang/cargo#17436) - docs: clarify cargo vendor source config option (rust-lang/cargo#17435) - docs(trim-paths): workspace remap begins with `.` (rust-lang/cargo#17433) - docs: Switch from "target triple" to "target tuple" (rust-lang/cargo#17430) - docs(trim-paths): add limitations and polish (rust-lang/cargo#17425) - fix(git): Simplify error message (rust-lang/cargo#17429) - chore(deps): update rust crate base64 to 0.23.0 (rust-lang/cargo#17418)
Update cargo submodule 9 commits in b2e9d5f9db3fb1c454ab84f10c16508984a266e2..3c0b534756e166d12eb9fd2e1abfe5b42ac6101e 2026-09-02 14:49:16 +0000 to 2026-09-04 17:03:10 +0000 - fix(trim-paths)!: limit options to `none|object|all` (rust-lang/cargo#17432) - fix(git): Apply pr hint to git-fetch-with-cli (rust-lang/cargo#17437) - fix(git): Make PR dep note cloer to our style guide (rust-lang/cargo#17436) - docs: clarify cargo vendor source config option (rust-lang/cargo#17435) - docs(trim-paths): workspace remap begins with `.` (rust-lang/cargo#17433) - docs: Switch from "target triple" to "target tuple" (rust-lang/cargo#17430) - docs(trim-paths): add limitations and polish (rust-lang/cargo#17425) - fix(git): Simplify error message (rust-lang/cargo#17429) - chore(deps): update rust crate base64 to 0.23.0 (rust-lang/cargo#17418)
What does this PR try to resolve?
This limits profile
trim-pathsoptions to onlynone,object, andall.For other scopes and boolean values, we can add it in the future when needed.
This is a stabilization preparation for
-Ztrim-paths.See #12137 (comment).
How to test and review this PR?
Also rewrote the profile trim-paths doc a bit but not extremely satisfied.
Please help proofread.