Skip to content

Commit cbcb1df

Browse files
committed
Current working directory -> current package
1 parent 16edfb2 commit cbcb1df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

text/3127-trim-paths.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ trim-paths = "none"
127127

128128
The default release profile setting (`object`) sanitises only the paths in emitted executable or library files. It always affects paths from macros such as panic messages, and in debug information
129129
only if they will be embedded together with the binary (the default on platforms with ELF binaries, such as Linux and windows-gnu),
130-
but will not touch them if they are in separate files (the default on Windows MSVC and macOS). But the path to these separate files are sanitised.
130+
but will not touch them if they are in separate files (the default on Windows MSVC and macOS). But the paths to these separate files are sanitised.
131131

132132
If `trim-paths` is not `none` or `false`, then the following paths are sanitised if they appear in a selected scope:
133133

134134
1. Path to the source files of the standard and core library (sysroot) will begin with `/rustc/[rustc commit hash]`.
135135
E.g. `/home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs` ->
136136
`/rustc/fe72845f7bb6a77b9e671e6a4f32fe714962cec4/library/core/src/result.rs`
137-
2. Path to the working directory will be stripped. E.g. `/home/username/crate/src/lib.rs` -> `src/lib.rs`.
138-
3. Path to packages outside of the working directory will be replaced with `[package name]-[version]`. E.g. `/home/username/deps/foo/src/lib.rs` -> `foo-0.1.0/src/lib.rs`
137+
2. Path to the current package will be stripped. E.g. `/home/username/crate/src/lib.rs` -> `src/lib.rs`.
138+
3. Path to dependency packages will be replaced with `[package name]-[version]`. E.g. `/home/username/deps/foo/src/lib.rs` -> `foo-0.1.0/src/lib.rs`
139139

140140
When a path to the source files of the standard and core library is *not* in scope for sanitisation, the emitted path will depend on if `rust-src` component
141141
is present. If it is, then some paths will point to the copy of the source files on your file system; if it isn't, then they will
@@ -157,16 +157,16 @@ If `trim-paths` is `none` (`false`), no extra flag is supplied to `rustc`.
157157

158158
If `trim-paths` is anything else, then its value is supplied directly to `rustc`'s `--remap-path-scope` option, along with two `--remap-path-prefix` arguments:
159159
- From the path of the local sysroot to `/rustc/[commit hash]`.
160-
- If the compilation unit is under the working directory, from the the working directory absolute path to empty string.
161-
If it's outside the working directory, from the absolute path of the package root to `[package name]-[package version]`.
160+
- For the the current package (where the current working directory is in), from the the absolute path of the package root to empty string.
161+
For other packages, from the absolute path of the package root to `[package name]-[package version]`.
162162

163163
The default value of `trim-paths` is `object` for release profile. As a result, panic messages (which are always embedded) are sanitised. If debug information is embedded, then they are sanitised; if they are split then they are kept untouched, but the paths to these split files are sanitised.
164164

165165
Some interactions with compiler-intrinsic macros need to be considered:
166166
1. Path (of the current file) introduced by [`file!()`](https://doc.rust-lang.org/std/macro.file.html) *will* be remapped. **Things may break** if
167167
the code interacts with its own source file at runtime by using this macro.
168168
2. Path introduced by [`include!()`](https://doc.rust-lang.org/std/macro.include.html) *will* be remapped, given that the included file is under
169-
the current working directory or a dependency package.
169+
the current package or a dependency package.
170170

171171
If the user further supplies custom `--remap-path-prefix` arguments via `RUSTFLAGS`
172172
or similar mechanisms, they will take precedence over the one supplied by `trim-paths`. This means that the user-defined remapping arguments must be
@@ -286,7 +286,7 @@ There has been an issue (https://github.com/rust-lang/rust/issues/40552) asking
286286
release builds. It has, over the past 4 years, gained a decent amount of popular support. The remapping rule proposed here is very simple to
287287
implement.
288288

289-
Path to sysroot crates are specially handled by `rustc`. Due to this, the behaviour we currently have is that all such paths are virtualised.
289+
Paths to sysroot crates are specially handled by `rustc`. Due to this, the behaviour we currently have is that all such paths are virtualised.
290290
Although good for privacy and reproducibility, some people find it a hindrance for debugging: https://github.com/rust-lang/rust/issues/85463.
291291
Hence the user should be given control on if they want the virtual or local path.
292292

@@ -303,7 +303,7 @@ the behaviour of `--remap-path-prefix=all` and the stable `--remap-path-prefix`,
303303
- `macro` is primarily meant for panic messages embedded in binaries.
304304
- `diagnostics` is unlikely to be used on its own as it only affects console outputs, but is required for completeness. See [#87745](https://github.com/rust-lang/rust/issues/87745).
305305
- `unsplit-debuginfo` is used to sanitise debuginfo embedded in binaries.
306-
- `split-debuginfo` is used to sanitise debuginfo separate from binaries. This is may be used when debuginfo files are separate and the author
306+
- `split-debuginfo` is used to sanitise debuginfo separate from binaries. This may be used when debuginfo files are separate and the author
307307
still wants to distribute them.
308308
- `split-debuginfo-path` is used to sanitise the path embedded in binaries pointing to separate debuginfo files. This is likely needed in all
309309
contexts where `unsplit-debuginfo` is used, but it's technically a separate piece of information inserted by the linker, not rustc.
@@ -332,7 +332,7 @@ the other for only debuginfo: https://reproducible-builds.org/docs/build-path/.
332332
in specific directories for these paths to work. [For instance](https://github.com/rust-lang/rust/issues/87825#issuecomment-920693005), if the
333333
absolute path to the `.pdb` file is sanitised to the relative `target/release/foo.pdb`, then the binary must be invoked under the crate root as
334334
`target/release/foo` to allow the correct backtrace to be displayed.
335-
- Should we treat the current working directory the same as other packages? We could have one fewer remapping rule by remapping all
335+
- Should we treat the current package the same as other packages? We could have one fewer remapping rule by remapping all
336336
package roots to `[package name]-[version]`. A minor downside to this is not being able to `Ctrl+click` on paths to files the user is working
337337
on from panic messages.
338338
- Will these cover all potentially embedded paths? Have we missed anything?

0 commit comments

Comments
 (0)