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
Copy file name to clipboardExpand all lines: text/3127-trim-paths.md
+21-7Lines changed: 21 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -73,8 +73,8 @@ This is undesirable for the following reasons:
73
73
## Handling sysroot paths
74
74
At the moment, paths to the source files of standard and core libraries, even when they are present, always begin with a virtual prefix in the form
75
75
of `/rustc/[SHA1 hash]/library`. This is not an issue when the source files are not present (i.e. when `rust-src` component is not installed), but
76
-
when a user installs `rust-src` they may want the path to their local copy of source files to be visible. Hence the default behaviour when `rust-src`
77
-
is installed should be to use the local path. These local paths should be then affected by path remappings in the usual way.
76
+
when a user installs `rust-src` they may want the path to their local copy of source files to be visible. Sometimes this is simply impossible as the path originated from the pre-compiled std and core and outside of rustc's control, but the local path should be used where possible.
77
+
Hence the default behaviour when `rust-src`is installed should be to use the local path. These local paths should be then affected by path remappings in the usual way.
78
78
79
79
## Preserving debuginfo to help debuggers
80
80
At the moment, `--remap-path-prefix` will cause paths to source files in debuginfo to be remapped. On platforms where the debuginfo resides in a
@@ -168,13 +168,12 @@ supplied *after* Cargo's own remapping.
168
168
169
169
## Changing handling of sysroot path in `rustc`
170
170
171
-
The virtualisation of sysroot files to `/rustc/[commit hash]/library/...` was done at compiler bootstrapping, specifically when
172
-
`remap-debuginfo = true` in `config.toml`. This is done for Rust distribution on all channels.
171
+
The remapping of sysroot paths to `/rustc/[commit hash]/library/...` was done when std and core libraries are compiled by Rust's release CI. Unless [`build-std`](https://doc.rust-lang.org/cargo/reference/unstable.html#build-std) is specified, these pre-compiled artifacts are used.
173
172
174
-
At `rustc` runtime (i.e. compiling some code), we try to correlate this virtual path to a real path pointing to the file on the local file system.
173
+
Most of the time, these paths are never handled by `rustc`, since they are in the debuginfo of pre-compiled binaries to be directly copied by the linker. However, sometimes (such as when compiling monomorphised functions), `rustc` does pick up these metadata. When this happens, `rustc` tries to correlate this virtual path to a real path pointing to the file on the local file system.
175
174
Currently the result is represented internally as if the path was remapped by a `--remap-path-prefix`, from local `rust-src` path to the virtual
176
-
path.
177
-
Only the virtual name is ever emitted for metadata or codegen. We want to change this behaviour such that, when `rust-src` source files can be
175
+
path`/rustc/[commit hash]/library/...`.
176
+
Only the virtual path is ever emitted for metadata or codegen. We want to change this behaviour such that, when `rust-src` source files can be
178
177
discovered, the virtual path is discarded and therefore the local path will be embedded, unless there is a `--remap-path-prefix` that causes this
179
178
local path to be remapped in the usual way.
180
179
@@ -259,3 +258,18 @@ or is it a part of the path; if the first `:` supplied belongs to the path then
259
258
260
259
In any case, future inclusion of this new syntax will not affect `--remap-path-scope` introduced in this RFC. Scopes specified in `--remap-path-scope`
261
260
will be used as default for all mappings, and explicit scopes for an individual mapping will take precedence on that mapping.
261
+
262
+
## Sysroot paths uniformity
263
+
Since some virtualised sysroot paths are hardcoded in the pre-compiled debuginfo, while the others can be resolved back to a local path with `rust-src`, the user may see them interleaved
264
+
```
265
+
0: rust_begin_unwind
266
+
at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:493:5
267
+
1: core::panicking::panic_fmt
268
+
at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/panicking.rs:92:14
269
+
2: core::result::unwrap_failed
270
+
at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/result.rs:1355:5
271
+
3: core::result::Result<T,E>::unwrap
272
+
at /home/jonas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
273
+
```
274
+
275
+
This is not very nice. It is infeasible to fix up the pre-compiled debuginfo before linking to fully remove the virtual paths, so demapping needs to happen when it is displayed (in this case, when the backtrace is printed). This is out of scope of this RFC but it may be something we want to do separately in the future.
0 commit comments