From 3acd15eb47dbe3770d21b0c8591af83011799e19 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 16 Apr 2020 18:02:47 -0700 Subject: [PATCH] Fix pdb uplift when executable has dashes. --- src/cargo/core/compiler/build_context/target_info.rs | 4 +++- tests/testsuite/build.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index aed188ea2bf..45ffd7f4cc4 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -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, }) } } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index abe60a13fcd..ce8cc06a2c2 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -4201,6 +4201,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(); @@ -4209,6 +4210,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()); }