Skip to content

Commit dd6b7c7

Browse files
committed
fix(trim-paths): explicit remap to current dir .
In https://github.com/rust-lang/rust/blob/87e1447aa/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs#L856 when the remap result of `work_dir` is an empty string, LLVM won't generate some symbols for root debuginfo node. For example, `N_SO` and `N_OSO` on macOS, or `DW_AT_comp_dir` on Linux when debuginfo is splitted. Precisely, it is observed that when the `DIFile` of compile unit was provied with an empty compilation `Directory` string, LLVM would not emit those symbols for the root DI node. This behavior is not desired, resulting in corrupted debuginfo and degrading debugging experience. This is might not be a bug of `--remap-path-prefix` in rustc, since `-fdebug-prefix-map` in clang 16 could have the same result (`DW_AT_comp_dir` is gone when `work_dir` is remapped to an empty string). However, in gcc 12 `fdebug-prefix-map` will return an absolute work_dir when an empty string occurs. To not bother whether this needs to be fixed in rustc or not, let's fix it by always appending an explicit `.` when `--remap-path-prefix` remaps to relative workspace root a.k.a. where rustc is invoking. For more on gcc/clang remap options, see https://reproducible-builds.org/docs/build-path/
1 parent 5a1ae7a commit dd6b7c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ fn trim_paths_args(
12301230
// * path dependencies outside workspace root directory
12311231
if is_local && pkg_root.strip_prefix(ws_root).is_ok() {
12321232
remap.push(ws_root);
1233-
remap.push("="); // empty to remap to relative paths.
1233+
remap.push("=."); // remap to relative rustc work dir explicitly
12341234
} else {
12351235
remap.push(pkg_root);
12361236
remap.push("=");

0 commit comments

Comments
 (0)