Skip to content

Fix cross-compilation of build.rs for aarch64 target#607

Open
aford173 wants to merge 1 commit intocontainers:mainfrom
aford173:fork/fix-cross-compile-build
Open

Fix cross-compilation of build.rs for aarch64 target#607
aford173 wants to merge 1 commit intocontainers:mainfrom
aford173:fork/fix-cross-compile-build

Conversation

@aford173
Copy link
Copy Markdown

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.

@slp
Copy link
Copy Markdown
Collaborator

slp commented Mar 27, 2026

@aford173 thanks for the PR! please sign the commit to satisfy the DCO test.

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>
@aford173 aford173 force-pushed the fork/fix-cross-compile-build branch from ca4cf4c to 0275772 Compare March 27, 2026 17:16
@aford173
Copy link
Copy Markdown
Author

@slp - Sorry about that. It should be updated now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants