quickjs
quickjs copied to clipboard
Support CC_FOR_BUILD for cross-compilation
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_BUILDand buildhost-qjscusing the native compiler - Add
HOST_CFLAGSandHOST_LDFLAGSto avoid passing target-specific flags (like-mcpu=power8) to the host compiler - Skip building examples when cross-compiling (they require running
qjscto generate target executables)
Testing
Tested cross-compiling for osx-arm64 and linux-ppc64le from x86_64 build machines.
@copilot