Skip to content

Support CC_FOR_BUILD for cross-compilation#484

Open
chrisburr wants to merge 1 commit intobellard:masterfrom
chrisburr:cross-compile-cc-for-build
Open

Support CC_FOR_BUILD for cross-compilation#484
chrisburr wants to merge 1 commit intobellard:masterfrom
chrisburr:cross-compile-cc-for-build

Conversation

@chrisburr
Copy link

Summary

Add support for cross-compilation environments that set CC_FOR_BUILD to specify the build machine compiler, complementing the existing CROSS_PREFIX approach.

Motivation

When cross-compiling (e.g., building arm64 binaries on x86_64), the build needs to run qjsc to generate repl.c. The current CROSS_PREFIX mechanism works when the cross-compiler follows the <prefix>gcc naming convention, but many cross-compilation environments set CC directly and provide CC_FOR_BUILD for the native compiler.

Changes

  • Detect CC_FOR_BUILD and build host-qjsc using the native compiler
  • Add HOST_CFLAGS and HOST_LDFLAGS to avoid passing target-specific flags (like -mcpu=power8) to the host compiler
  • Skip building examples when cross-compiling (they require running qjsc to generate target executables)

Testing

Tested cross-compiling for osx-arm64 and linux-ppc64le from x86_64 build machines.

Add support for cross-compilation environments that set CC_FOR_BUILD
to specify the build machine compiler. This complements the existing
CROSS_PREFIX approach and enables building host-qjsc with the native
compiler when CC targets a different architecture.
@dofaromg
Copy link

@copilot

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