From 5a48fa9e0850f045a4069d8e487def9f3e1e47a3 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Thu, 29 Jan 2026 13:06:25 +0000 Subject: [PATCH] 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 --- cmake/CompilerFlags.cmake | 14 ++++++++++++-- cmake/Options.cmake | 2 ++ cmake/tools/SetupWebKit.cmake | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index bf1e7f8eef..798866cbf1 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -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) diff --git a/cmake/Options.cmake b/cmake/Options.cmake index 47e8e55457..fd143cb23a 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -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 diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index 2275644005..2a45023da3 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -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)