mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Copy .pdb
files to target
directory
`.pdb` files are for windows debug info (unlike on linux, debug info is in a separate file). Windows executable actually hard-code paths to `.pdb` files, so debugging mvsc rust programs works even without this patch. However, if you want to distribute the executable to other machines, you'd better distribute both `foo.exe` and `foo.pdb`, because absolute paths won't work on another machine. Having same-named .pdb file alongside the binary would work though. closes #4960
This commit is contained in:
parent
e540fd157c
commit
9c0d3f2980
@ -1326,13 +1326,17 @@ fn add_target_specific_suffixes(
|
||||
ret.push((".wasm".to_string(), TargetFileType::Normal, true));
|
||||
}
|
||||
|
||||
// rust-lang/cargo#4490
|
||||
// - only uplift *.dSYM for binaries.
|
||||
// rust-lang/cargo#4490, rust-lang/cargo#4960
|
||||
// - only uplift debuginfo for binaries.
|
||||
// tests are run directly from target/debug/deps/
|
||||
// and examples are inside target/debug/examples/ which already have *.dSYM next to them
|
||||
// and examples are inside target/debug/examples/ which already have symbols next to them
|
||||
// so no need to do anything.
|
||||
if target_triple.contains("-apple-") && *target_kind == TargetKind::Bin {
|
||||
ret.push((".dSYM".to_string(), TargetFileType::DebugInfo, false));
|
||||
if *target_kind == TargetKind::Bin {
|
||||
if target_triple.contains("-apple-") {
|
||||
ret.push((".dSYM".to_string(), TargetFileType::DebugInfo, false));
|
||||
} else if target_triple.ends_with("-msvc") {
|
||||
ret.push((".pdb".to_string(), TargetFileType::DebugInfo, false));
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
|
@ -4179,6 +4179,33 @@ fn uplift_dsym_of_bin_on_mac() {
|
||||
assert_that(&p.bin("d.dSYM"), is_not(existing_dir()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uplift_pdb_of_bin_on_windows() {
|
||||
if !cfg!(all(target_os = "windows", target_env = "msvc")) {
|
||||
return
|
||||
}
|
||||
let p = project("foo")
|
||||
.file("Cargo.toml", r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
"#)
|
||||
.file("src/main.rs", "fn main() { panic!(); }")
|
||||
.file("src/bin/b.rs", "fn main() { panic!(); }")
|
||||
.file("examples/c.rs", "fn main() { panic!(); }")
|
||||
.file("tests/d.rs", "fn main() { panic!(); }")
|
||||
.build();
|
||||
|
||||
assert_that(
|
||||
p.cargo("build").arg("--bins").arg("--examples").arg("--tests"),
|
||||
execs().with_status(0)
|
||||
);
|
||||
assert_that(&p.target_debug_dir().join("foo.pdb"), existing_file());
|
||||
assert_that(&p.target_debug_dir().join("b.pdb"), existing_file());
|
||||
assert_that(&p.target_debug_dir().join("c.pdb"), is_not(existing_file()));
|
||||
assert_that(&p.target_debug_dir().join("d.pdb"), is_not(existing_file()));
|
||||
}
|
||||
|
||||
// Make sure that `cargo build` chooses the correct profile for building
|
||||
// targets based on filters (assuming --profile is not specified).
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user