Tracking Issue for trim-paths RFC 3127
Summary
RFC: #3127 Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-trim-paths-option Issues: https://github.com/rust-lang/cargo/labels/Z-trim-paths rustc tracking issue: https://github.com/rust-lang/rust/issues/111540
This adds a new profile setting (among other things) to control how paths are sanitized in the resulting binary.
Unresolved Issues
- [ ] Should make
--remap-path-prefixwork withrustdocand doctest?- Yes as rustdoc supports both
- https://github.com/rust-lang/rust/pull/107099
- https://github.com/rust-lang/rust/pull/128736
- [x] Integrate
--remap-path-prefixin rustdoc invocations (cargo doc) https://github.com/rust-lang/cargo/pull/14389 - [ ] Integrate
--remap-path-prefixand-Zremap-path-scopein doctest (cargo test --doc)
- Yes as rustdoc supports both
- [ ] Determine the remap rules: https://github.com/rust-lang/cargo/issues/13171
- [x] A cross-platform stable hash for
CARGO_HOMElayout? https://github.com/rust-lang/cargo/pull/14917- [x] On Windows the local path contains prefix component e.g.
C:/, which essentially results in a different hash result from what on other platforms. This is unlikely to be resolved. - [x] benchmark BLAKE3, BLAKE2s, and rustc-stable-hasher
- See result in https://github.com/rust-lang/cargo/pull/14116#issuecomment-2486293308
- rustc-stable-hash is on par with the original siphash, while blake3 is 2-3x slower. The total spent in stable hashing for a
cargo buildinvocation may be unimportant. It took 500μs-1500μs for buidling cargo itself.
- [x] On Windows the local path contains prefix component e.g.
- [x] A cross-platform stable hash for
- [ ] There should be some tests for Windows and macOS
- Be sure to consider the impact of back versus forward slashes, and whether or not that will work with either.
Future Extensions
No response
About tracking issues
Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Implementation history
- https://github.com/rust-lang/cargo/pull/12625
- https://github.com/rust-lang/cargo/pull/12900
- https://github.com/rust-lang/cargo/pull/12908
- https://github.com/rust-lang/cargo/pull/14389
- https://github.com/rust-lang/cargo/pull/14908
- https://github.com/rust-lang/cargo/pull/15614
Last status update I'm aware of
https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/trim-paths.20testing/near/401425246
Is this working on Linux, well enough that we could ship it for Linux without promising macOS support?
This is the latest status of it on rustc side: https://github.com/rust-lang/rust/issues/111540#issuecomment-2014748609, which the new remap rule in the conclusion is implemented. I've updated the unresolved issues section in this tracking issue.
Status update:
- This change https://github.com/rust-lang/rust/pull/107099 should make
-Ztrim-pathsalso work for rustdoc - A stable hasher extracting from rustc is on its way. See also
- https://github.com/rust-lang/compiler-team/issues/755
- https://github.com/rust-lang/rustc-stable-hash/pull/1
https://github.com/rust-lang/rust/pull/107099 is just merged, so should be able to support for rustdoc.
Edit: need to adjust cargo to pass --remap-path-prefix to rustdoc invocations.
Updated:
- doctest has supported remapping: https://github.com/rust-lang/rust/pull/122450
- rustdoc diagnostics hasn't: https://github.com/rust-lang/rust/issues/69264#issuecomment-2261945619
That potentially blocks this, if we would like to see -Ztrim-paths supports also for rustdoc invocations.
Updated:
- doctest has supported remapping: Simplify trim-paths feature by merging all debuginfo options together rust#122450
- rustdoc diagnostics hasn't: rustdoc: use remap-path-prefix rust#69264 (comment)
That potentially blocks this, if we would like to see
-Ztrim-pathssupports also for rustdoc invocations.
both of those linked are closed/merged what is left blocking to get trimpaths working?
both of those linked are closed/merged what is left blocking to get trimpaths working?
@liciana24 There are some unresolved issues listed in the PR description I just updated.
It should minimally work. Any feedback of it not working?
status?
@lina9992006 Just posted benchmark results here for different stable hash algorithms: https://github.com/rust-lang/cargo/pull/14116#issuecomment-2486293308
If you'd like to move this forward, here are areas we need helps:
- Resolving issues mentioned in the PR description.
- Testing out the current implementation and provide feedback.
why is hashing relevant here?
A stable cross-platform hash algorithm helps -Ztrim-paths finding sources from the same path when debugging. See https://github.com/rust-lang/cargo/issues/13171#issuecomment-1864899037 and other comments around.