You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`trim-path` is a profile setting which can be set to either `true` or `false`. This is enabled by default when you do a release build,
75
+
`trim-paths` is a profile setting which can be set to either `true` or `false`. This is enabled by default when you do a release build,
76
76
such as via `cargo build --release`. You can also manually override it by specifying this option in `Cargo.toml`:
77
77
```toml
78
78
[profile.dev]
79
-
trim-path = true
79
+
trim-paths = true
80
80
81
81
[profile.release]
82
-
trim-path = false
82
+
trim-paths = false
83
83
```
84
84
85
-
With `trim-path` option enabled, the compilation process will not introduce any absolute paths into the build output. Instead, paths containing
85
+
With `trim-paths` option enabled, the compilation process will not introduce any absolute paths into the build output. Instead, paths containing
86
86
certain prefixes will be replaced with something stable by the following rules:
87
87
88
88
1. Path to the source files of the standard and core library will begin with `/rustc/[rustc version]`.
@@ -94,18 +94,18 @@ certain prefixes will be replaced with something stable by the following rules:
94
94
If using MSVC toolchain, path to the .pdb file containing debug information are be embedded as the file name of the .pdb file only, wihtout any path
95
95
information.
96
96
97
-
With `trim-path` option disabled, the embedding of path to the source files of the standard and core library will depend on if `rust-src` component is present. If it is, then the real path pointing to a copy of the source files on your file system will be embedded; if it isn't, then they will
98
-
show up as `/rustc/[rustc version]/library/...` (just like when `trim-path` is enabled). Paths to all other source files will not be affected.
97
+
With `trim-paths` option disabled, the embedding of path to the source files of the standard and core library will depend on if `rust-src` component is present. If it is, then the real path pointing to a copy of the source files on your file system will be embedded; if it isn't, then they will
98
+
show up as `/rustc/[rustc version]/library/...` (just like when `trim-paths` is enabled). Paths to all other source files will not be affected.
99
99
100
100
Note that this will not affect any hard-coded paths in the source code.
We only need to change the behaviour for `Test` and `Build` compile modes.
107
107
108
-
If `trim-path` is enabled, Cargo will emit two `--remap-path-prefix` arguments to `rustc` for each compilation unit. One mapping is from the path of
108
+
If `trim-paths` is enabled, Cargo will emit two `--remap-path-prefix` arguments to `rustc` for each compilation unit. One mapping is from the path of
109
109
the local sysroot to `/rustc/[rust version]`. The other mapping depends on if the package containing the compilation unit is under the working
110
110
directory. If it is, then the mapping is from the absolute path to the working directory to `.`. If it's outside the working directory, then the
111
111
mapping is from the absolute path of the package root to `[package name]-[package version]`.
@@ -118,7 +118,7 @@ Some interactions with compiler-intrinstic macros need to be considered, though
118
118
the current working directory or a dependency package.
119
119
120
120
If the user further supplies custom `--remap-path-prefix` arguments via `RUSTFLAGS` or similar mechanisms, they will take precedence over the one
121
-
supplied by `trim-path`. This means that the user-defined `--remap-path-prefix`s must be supplied *after* Cargo's own remapping.
121
+
supplied by `trim-paths`. This means that the user-defined `--remap-path-prefix`s must be supplied *after* Cargo's own remapping.
122
122
123
123
Additionally, when using MSVC linker, Cargo should emit `/PDBALTPATH:%_PDB%` to the linker via `-C link-arg`. This makes the linker embed
124
124
only the file name of the .pdb file without the path to it.
@@ -133,21 +133,21 @@ Only the virtual name is ever emitted for metadata or codegen. We want to change
133
133
discovered, the virtual path is discarded and therefore will be embedded unless being remapped by `--remap-path-prefix` in the usual way. The relevant part of the code is here:
We would also like to change the virtualisation of sysroot to `/rustc/[rustc version]/library/...`, instead of the rustc commit hash. This is shorter and more helpful as an identifier, and makes `trim-path` easier to implement: to make the embedded path the same whether or not `rust-src` is installed, we need to emit the same sysroot virutalisation as was done during bootstrapping. Getting the version number is easier than getting the commit hash. The relevant part of the code is here: https://github.com/rust-lang/rust/blob/d8af907491e20339e41d048d6a32b41ddfa91dfe/src/bootstrap/lib.rs#L831-L834
136
+
We would also like to change the virtualisation of sysroot to `/rustc/[rustc version]/library/...`, instead of the rustc commit hash. This is shorter and more helpful as an identifier, and makes `trim-paths` easier to implement: to make the embedded path the same whether or not `rust-src` is installed, we need to emit the same sysroot virutalisation as was done during bootstrapping. Getting the version number is easier than getting the commit hash. The relevant part of the code is here: https://github.com/rust-lang/rust/blob/d8af907491e20339e41d048d6a32b41ddfa91dfe/src/bootstrap/lib.rs#L831-L834
137
137
138
138
# Drawbacks
139
139
[drawbacks]: #drawbacks
140
140
141
-
With `trim-path` enabled, if the `debug` option is simultaneously not `false` (it is turned off by default under `release` profile), paths in
141
+
With `trim-paths` enabled, if the `debug` option is simultaneously not `false` (it is turned off by default under `release` profile), paths in
142
142
debuginfo will also be remapped. Debuggers will no longer be able to automatically discover and load source files outside of the working directory.
143
143
This can be remidated by [debugger features](https://lldb.llvm.org/use/map.html#miscellaneous) remapping the path back to a filesystem path.
144
144
145
145
The user also will not be able to `Ctrl+click` on any paths provided in panic messages or backtraces outside of the working directory. But
146
146
there shouldn't be any confusion as the combination of pacakge name and version can be used to pinpoint the file.
147
147
148
-
As mentioned above, `trim-path` may break code that relies on `file!()` to evaluate to an accessible path to the file. Hence enabling
148
+
As mentioned above, `trim-paths` may break code that relies on `file!()` to evaluate to an accessible path to the file. Hence enabling
149
149
it by default for release builds may be a technically breaking change. Occurances of such use should be extremely rare but should be investigated
150
-
via a Crater run. In case this breakage is unacceptable, `trim-path` can be made an opt-in option rather than default in any build profile.
150
+
via a Crater run. In case this breakage is unacceptable, `trim-paths` can be made an opt-in option rather than default in any build profile.
0 commit comments