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
- (non-blocking) Should make
--remap-path-prefixwork withrustdocand doctest?- Yes as rustdoc supports both
- 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)
- Determine the remap rules: https://github.com/rust-lang/cargo/issues/13171
- A cross-platform stable hash for
CARGO_HOMElayout? https://github.com/rust-lang/cargo/pull/14917- 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. - 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.
- This is the final remap rules: https://github.com/rust-lang/cargo/pull/17302
- To help user to unremap back, an unremap file is added as an companion files of binaries: https://github.com/rust-lang/cargo/pull/17303
- On Windows the local path contains prefix component e.g.
- A cross-platform stable hash for
- Should workspace member paths in trimmed artifacts stay relative, or get a virtual prefix like dependencies?
- Relative keeps the common case easy, for example, debuggers resolve workspace sources with zero configuration
- Relative also introduces a second mechanism for consumers (prefix substitution vs. relative-join). For example, symbolication pipelines need two code paths https://github.com/rust-lang/cargo/pull/17366#issuecomment-5303319051
- Non-blocking as we have unremap file
.trim-paths.jsonlrecordsworkspace_root. - Ask about this trade-off during call-for-testing
- There should be some tests for Windows and macOS
- windows-gnu https://github.com/rust-lang/cargo/pull/17221/
- windows-msvc https://github.com/rust-lang/cargo/pull/15621
- macOS https://github.com/rust-lang/cargo/pull/13118
- Be sure to consider the impact of back versus forward slashes, and whether or not that will work with either
- As of 84a7a403847019436b99266e592464a495d316da, GDB accepts either; CDB requires backslashes
- Support
CARGO_TRIM_PATHS_SCOPEandCARGO_TRIM_PATHS_REMAPin build-rs crate - Unremap files
- (non-blocking) Currently Cargo only generates unremap files for root units. Should this be extended to artifact dependencies? https://github.com/rust-lang/cargo/pull/17303#discussion_r3706646233
- The schema of the unremap file. See https://github.com/rust-lang/cargo/pull/17303#discussion_r3706668858
- (non-blocking) Interact with
-Zroot-dir - (non-blocking) build-rs new API for
CARGO_TRIM_PATHS_REMAPandCARGO_TRIM_PATHS_SCOPE
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
- https://github.com/rust-lang/cargo/pull/17104
- https://github.com/rust-lang/cargo/pull/17302
- https://github.com/rust-lang/cargo/pull/17303
- https://github.com/rust-lang/cargo/pull/17337
- https://github.com/rust-lang/cargo/pull/17338
- https://github.com/rust-lang/cargo/pull/17349
- https://github.com/rust-lang/cargo/pull/17366
- https://github.com/rust-lang/cargo/pull/17424
- https://github.com/rust-lang/cargo/pull/17425
- https://github.com/rust-lang/cargo/pull/17432
- https://github.com/rust-lang/cargo/pull/17476
Source: rust-lang/cargo