mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix: add ENABLE_BASELINE support for ARM64 to fix crash on older CPUs
This fixes #26556 where Bun crashes with "Illegal instruction" on older ARM64 CPUs (ARMv8.0-A without LSE support) like Cortex-A53, Exynos 9611, and AWS a1 instances. The fix adds: 1. ENABLE_BASELINE option for ARM64 in Options.cmake 2. -moutline-atomics flag for ARM64 baseline builds in CompilerFlags.cmake which generates runtime-detected atomic implementations 3. Baseline suffix for ARM64 WebKit downloads in SetupWebKit.cmake Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,19 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM|arm64|ARM64|aarch64|AARCH64")
|
||||
elseif(WIN32)
|
||||
# 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)
|
||||
if(ENABLE_BASELINE)
|
||||
# Baseline: ARMv8.0-A compatible, use outline atomics for LSE compatibility
|
||||
register_compiler_flags(/clang:-march=armv8-a+crc /clang:-moutline-atomics)
|
||||
else()
|
||||
register_compiler_flags(/clang:-march=armv8-a+crc /clang:-mtune=ampere1)
|
||||
endif()
|
||||
else()
|
||||
register_compiler_flags(-march=armv8-a+crc -mtune=ampere1)
|
||||
if(ENABLE_BASELINE)
|
||||
# Baseline: ARMv8.0-A compatible, use outline atomics for LSE compatibility
|
||||
register_compiler_flags(-march=armv8-a+crc -moutline-atomics)
|
||||
else()
|
||||
register_compiler_flags(-march=armv8-a+crc -mtune=ampere1)
|
||||
endif()
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64")
|
||||
if(ENABLE_BASELINE)
|
||||
|
||||
@@ -99,6 +99,8 @@ 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")
|
||||
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older ARM64 CPUs (e.g. ARMv8.0-A without LSE)" DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# Disabling logs by default for tests yields faster builds
|
||||
|
||||
@@ -84,6 +84,10 @@ if(LINUX AND ABI STREQUAL "musl")
|
||||
set(WEBKIT_SUFFIX "-musl")
|
||||
endif()
|
||||
|
||||
if(ENABLE_BASELINE)
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}-baseline")
|
||||
endif()
|
||||
|
||||
if(DEBUG)
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}-debug")
|
||||
elseif(ENABLE_LTO)
|
||||
|
||||
Reference in New Issue
Block a user