Skip to content

Commit

Permalink
Auto merge of #8123 - ehuss:fix-windows-pdb-dash, r=alexcrichton
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 17, 2020
2 parents b04345c + 3acd15e commit 1638705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ impl TargetInfo {
suffix: ".pdb".to_string(),
prefix: prefix.clone(),
flavor: FileFlavor::DebugInfo,
should_replace_hyphens: false,
// rustc calls the linker with underscores, and the
// filename is embedded in the executable.
should_replace_hyphens: true,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4178,6 +4178,7 @@ fn uplift_pdb_of_bin_on_windows() {
let p = project()
.file("src/main.rs", "fn main() { panic!(); }")
.file("src/bin/b.rs", "fn main() { panic!(); }")
.file("src/bin/foo-bar.rs", "fn main() { panic!(); }")
.file("examples/c.rs", "fn main() { panic!(); }")
.file("tests/d.rs", "fn main() { panic!(); }")
.build();
Expand All @@ -4186,6 +4187,8 @@ fn uplift_pdb_of_bin_on_windows() {
assert!(p.target_debug_dir().join("foo.pdb").is_file());
assert!(p.target_debug_dir().join("b.pdb").is_file());
assert!(p.target_debug_dir().join("examples/c.pdb").exists());
assert!(p.target_debug_dir().join("foo-bar.exe").is_file());
assert!(p.target_debug_dir().join("foo_bar.pdb").is_file());
assert!(!p.target_debug_dir().join("c.pdb").exists());
assert!(!p.target_debug_dir().join("d.pdb").exists());
}
Expand Down

0 comments on commit 1638705

Please sign in to comment.