Skip to content

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

Merged
mtjhrc merged 1 commit intocontainers:mainfrom
aford173:fork/fix-cross-compile-build
Mar 31, 2026
Merged

Fix cross-compilation of build.rs for aarch64 target#607
mtjhrc merged 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.

Copy link
Copy Markdown
Collaborator

@dorindabassey dorindabassey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@mtjhrc
Copy link
Copy Markdown
Collaborator

mtjhrc commented Mar 31, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the build script in src/vmm/build.rs to determine the target architecture using the CARGO_CFG_TARGET_ARCH environment variable instead of a compile-time configuration attribute. The review feedback suggests using the matches! macro to make the environment variable check more concise and idiomatic.

Copy link
Copy Markdown
Collaborator

@mtjhrc mtjhrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, verified to fix the issue. Thanks!

@mtjhrc mtjhrc merged commit 7c5292c into containers:main Mar 31, 2026
11 checks passed
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.

4 participants