feat(build): add ARM64 baseline build support for older CPUs

Add ARM64 baseline build option similar to x86_64 baseline builds. This enables
Bun to run on older ARM64 CPUs like Cortex-A53 (used in Amlogic S905X) that
don't support all ARMv8.1+ features.

Changes:
- Add ENABLE_BASELINE option for ARM64 (Linux only, macOS always uses apple_m1)
- Use -march=armv8-a -mtune=cortex-a53 for baseline instead of -march=armv8-a+crc -mtune=ampere1
- Use Zig's cortex_a35 CPU target for baseline builds
- Add linux-aarch64-baseline and linux-aarch64-musl-baseline toolchains

Fixes #26544

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2026-01-29 06:15:11 +00:00
parent fc4624c672
commit d1d0669a3e
5 changed files with 25 additions and 0 deletions

View File

@@ -25,6 +25,10 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM|arm64|ARM64|aarch64|AARCH64")
# Windows ARM64: use /clang: prefix for clang-cl, skip for MSVC cl.exe subprojects
# These flags are only understood by clang-cl, not MSVC cl.exe
register_compiler_flags(/clang:-march=armv8-a+crc /clang:-mtune=ampere1)
elseif(ENABLE_BASELINE)
# Baseline ARM64: target ARMv8-A without optional extensions for older CPUs like Cortex-A53
# See https://github.com/oven-sh/bun/issues/26544
register_compiler_flags(-march=armv8-a -mtune=cortex-a53)
else()
register_compiler_flags(-march=armv8-a+crc -mtune=ampere1)
endif()

View File

@@ -99,6 +99,9 @@ endif()
if(ARCH STREQUAL "x64")
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older CPUs (e.g. disables AVX, AVX2)" DEFAULT OFF)
elseif(ARCH STREQUAL "aarch64" AND LINUX)
# ARM64 baseline only supported on Linux; macOS always uses apple_m1, Windows ARM64 doesn't support baseline yet
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older ARM64 CPUs (e.g. Cortex-A53)" DEFAULT OFF)
endif()
# Disabling logs by default for tests yields faster builds

View File

@@ -683,6 +683,10 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM|arm64|ARM64|aarch64|AARCH64")
# Windows ARM64: use a specific CPU with NEON support
# Zig running under x64 emulation would detect wrong CPU with "native"
set(ZIG_CPU "cortex_a76")
elseif(ENABLE_BASELINE)
# Baseline ARM64: target Cortex-A35 for older CPUs like Cortex-A53
# See https://github.com/oven-sh/bun/issues/26544
set(ZIG_CPU "cortex_a35")
else()
set(ZIG_CPU "native")
endif()

View File

@@ -0,0 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ENABLE_BASELINE ON)
set(ABI gnu)
set(CMAKE_C_COMPILER_WORKS ON)
set(CMAKE_CXX_COMPILER_WORKS ON)

View File

@@ -0,0 +1,7 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(ENABLE_BASELINE ON)
set(ABI musl)
set(CMAKE_C_COMPILER_WORKS ON)
set(CMAKE_CXX_COMPILER_WORKS ON)