From 629d1f86b01d52dbc048f12bf54a89607c4f3922 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Mon, 18 Sep 2023 11:15:19 -0700 Subject: [PATCH] fix: copy PDBs for EFI targets 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: https://github.com/rust-osdev/uefi-rs/issues/289 Related: https://github.com/rust-lang/cargo/pull/5179 --- .../compiler/build_context/target_info.rs | 2 +- tests/testsuite/build.rs | 29 +++++++++++++++++++ 2 files changed, 30 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 555a41b75441..c3b3dd48a11a 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -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(), diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 3c650ca52135..8b425d04a500 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -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() {