Skip to content

Commit 7c5292c

Browse files
Adam Fordmtjhrc
authored andcommitted
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 <adam.ford@anodize.com>
1 parent 3fc7d1c commit 7c5292c

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/vmm/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
fn main() {
2-
#[cfg(target_arch = "aarch64")]
3-
{
2+
if std::env::var("CARGO_CFG_TARGET_ARCH").as_deref() == Ok("aarch64") {
43
let edk2_binary_path = std::env::var("KRUN_EDK2_BINARY_PATH").unwrap_or_else(|_| {
54
format!(
65
"{}/../../edk2/KRUN_EFI.silent.fd",

0 commit comments

Comments
 (0)