Skip to content

Commit

Permalink
fix: copy PDBs for EFI targets
Browse files Browse the repository at this point in the history
EFI also uses the PE format with .pdb files, and rustc generates them,
but Cargo does not copy them out of target/*/deps. This is an oversight,
so this PR fixes it.

Related: rust-osdev/uefi-rs#289
Related: #5179
  • Loading branch information
lf- committed Sep 18, 2023
1 parent 4c10811 commit 629d1f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl TargetInfo {
// the names to match.
should_replace_hyphens: false,
})
} else if target_triple.ends_with("-msvc") {
} else if target_triple.ends_with("-msvc") || target_triple.ends_with("-uefi") {
ret.push(FileType {
suffix: ".pdb".to_string(),
prefix: prefix.clone(),
Expand Down
29 changes: 29 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5311,6 +5311,35 @@ fn uplift_pdb_of_bin_on_windows() {
assert!(!p.target_debug_dir().join("d.pdb").exists());
}

#[cargo_test]
fn uplift_pdb_of_bin_for_efi() {
let p = project()
.file(
"src/main.rs",
r#"
#![no_std]
#![no_main]
#[panic_handler]
fn panicked(_: &core::panic::PanicInfo) -> ! {
loop {}
}
#[no_mangle]
extern "C" fn efi_main() -> ! {
loop {}
}
"#,
)
.build();

p.cargo("build --target x86_64-unknown-uefi").run();
assert!(p
.build_dir()
.join("x86_64-unknown-uefi/debug/foo.pdb")
.is_file());
}

#[cargo_test]
#[cfg(target_os = "linux")]
fn uplift_dwp_of_bin_on_linux() {
Expand Down

0 comments on commit 629d1f8

Please sign in to comment.