diff options
| author | bors <bors@rust-lang.org> | 2022-05-18 12:45:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-18 12:45:44 +0000 |
| commit | 936eba3b348e65b658b60218cc9237f02abdbeb4 (patch) | |
| tree | 170ce02aaa1fca72948775fc8adaccf2952f82e7 /src/test/codegen | |
| parent | e5732a21711e7cefa6eb22e1790406b269d6197a (diff) | |
| parent | 6411fef3aba5ba54a02b54b171b4e9bc83687ce9 (diff) | |
| download | rust-936eba3b348e65b658b60218cc9237f02abdbeb4.tar.gz rust-936eba3b348e65b658b60218cc9237f02abdbeb4.zip | |
Auto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwco
--remap-path-prefix: Fix duplicated path components in debuginfo This PR fixes an issue with `--remap-path-prefix` where path components could appear twice in the remapped version of the path (e.g. https://github.com/rust-lang/rust/issues/78479). The underlying problem was that `--remap-path-prefix` is often used to map an absolute path to something that looks like a relative path, e.g.: ``` --remap-path-prefix=/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io", ``` and relative paths in debuginfo are interpreted as being relative to the compilation directory. So if Cargo invokes the compiler with `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0/src/lib.rs` as input and `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0` as the compiler's working directory, then debuginfo will state that the working directory was `crates.io/some_crate-0.1.0` and the file is question was `crates.io/some_crate-0.1.0/src/lib.rs`, which combined gives the path: ``` crates.io/some_crate-0.1.0/crates.io/some_crate-0.1.0/src/lib.rs ``` With this PR the compiler will detect this situation and set up debuginfo in LLVM in a way that makes it strip the duplicated path components when emitting DWARF. The PR also extracts the logic for making remapped paths absolute into a common helper function that is now used by debuginfo too (instead of just during crate metadata generation).
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/remap_path_prefix/main.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/codegen/remap_path_prefix/main.rs b/src/test/codegen/remap_path_prefix/main.rs index b13d576295c..381f11ff1ef 100644 --- a/src/test/codegen/remap_path_prefix/main.rs +++ b/src/test/codegen/remap_path_prefix/main.rs @@ -22,7 +22,7 @@ fn main() { } // Here we check that local debuginfo is mapped correctly. -// CHECK: !DIFile(filename: "/the/src/remap_path_prefix/main.rs", directory: "/the/cwd" +// CHECK: !DIFile(filename: "/the/src/remap_path_prefix/main.rs", directory: "" // And here that debuginfo from other crates are expanded to absolute paths. // CHECK: !DIFile(filename: "/the/aux-src/remap_path_prefix_aux.rs", directory: "" |
