From 02757727efb2dfe24d5dae14279ea03241f78088 Mon Sep 17 00:00:00 2001 From: Adam Ford Date: Tue, 24 Mar 2026 09:58:04 -0500 Subject: [PATCH] Fix cross-compilation of build.rs for aarch64 target Build scripts may run on the host architecture, not the target. When cross-compiling from x86_64 to aarch64, #[cfg(target_arch = "aarch64")] evaluates to false in the build script, causing KRUN_EDK2_BINARY_PATH to not be set at compile time: error: environment variable `KRUN_EDK2_BINARY_PATH` not defined at compile time --> src/vmm/src/builder.rs:104:44 | 104 | static EDK2_BINARY: &[u8] = include_bytes!(env!("KRUN_EDK2_BINARY_PATH")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use CARGO_CFG_TARGET_ARCH environment variable instead, which reflects the actual target architecture regardless of the host. Signed-off-by: Adam Ford --- src/vmm/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vmm/build.rs b/src/vmm/build.rs index 3898b61c7..dbaac85af 100644 --- a/src/vmm/build.rs +++ b/src/vmm/build.rs @@ -1,6 +1,5 @@ fn main() { - #[cfg(target_arch = "aarch64")] - { + if std::env::var("CARGO_CFG_TARGET_ARCH").as_deref() == Ok("aarch64") { let edk2_binary_path = std::env::var("KRUN_EDK2_BINARY_PATH").unwrap_or_else(|_| { format!( "{}/../../edk2/KRUN_EFI.silent.fd",