Skip to content

Commit 1638705

Browse files
committed
Auto merge of #8123 - ehuss:fix-windows-pdb-dash, r=alexcrichton
Fix pdb uplift when executable has dashes. Windows `.pdb` files were not being uplifted for executables with dashes in their name. `rustc` calls the linker with the crate name (with underscores), which creates a pdb with underscores. Cargo renames the executable (`foo_bar.exe` to `foo-bar.exe`), and it was expecting the pdb to have the same form, but it doesn't. Note: There shouldn't be any effect for using a debugger. Because the pdb path is embedded in the executable, the debugger was already looking in the `deps/` folder. Uplifting is only useful if you want to copy the exe/pdb pair to some other machine. In that case, it looks in the same directory as the `exe` for the pdb file. Fixes #8117
2 parents b04345c + 3acd15e commit 1638705

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ impl TargetInfo {
292292
suffix: ".pdb".to_string(),
293293
prefix: prefix.clone(),
294294
flavor: FileFlavor::DebugInfo,
295-
should_replace_hyphens: false,
295+
// rustc calls the linker with underscores, and the
296+
// filename is embedded in the executable.
297+
should_replace_hyphens: true,
296298
})
297299
}
298300
}

tests/testsuite/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,6 +4178,7 @@ fn uplift_pdb_of_bin_on_windows() {
41784178
let p = project()
41794179
.file("src/main.rs", "fn main() { panic!(); }")
41804180
.file("src/bin/b.rs", "fn main() { panic!(); }")
4181+
.file("src/bin/foo-bar.rs", "fn main() { panic!(); }")
41814182
.file("examples/c.rs", "fn main() { panic!(); }")
41824183
.file("tests/d.rs", "fn main() { panic!(); }")
41834184
.build();
@@ -4186,6 +4187,8 @@ fn uplift_pdb_of_bin_on_windows() {
41864187
assert!(p.target_debug_dir().join("foo.pdb").is_file());
41874188
assert!(p.target_debug_dir().join("b.pdb").is_file());
41884189
assert!(p.target_debug_dir().join("examples/c.pdb").exists());
4190+
assert!(p.target_debug_dir().join("foo-bar.exe").is_file());
4191+
assert!(p.target_debug_dir().join("foo_bar.pdb").is_file());
41894192
assert!(!p.target_debug_dir().join("c.pdb").exists());
41904193
assert!(!p.target_debug_dir().join("d.pdb").exists());
41914194
}

0 commit comments

Comments
 (0)