From be32b0f252cc1be2a352f35b87cd2534e476ffc2 Mon Sep 17 00:00:00 2001 From: Angelos Oikonomopoulos Date: Tue, 17 Feb 2026 13:12:11 +0100 Subject: [PATCH] [JSC] Work around GCC miscompilation in testmasm https://bugs.webkit.org/show_bug.cgi?id=307056 Reviewed by Justin Michaud. It seems that GCC miscompiles the switch statement in testMoveConditionallyFloatingPointSameArg when -funswitch-loops is on (that's the case for -O3). The symptom is that we don't handle MacroAssembler::DoubleEqualAndOrdered (at least) and end up hitting the following RELEASE_ASSERT_NOT_REACHED();. Globally turn off this specific transformation when compiling with older versions of GCC, to avoid running into further hard-to-diagnose bugs. Canonical link: https://commits.webkit.org/307067@main --- Source/cmake/WebKitCompilerFlags.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/cmake/WebKitCompilerFlags.cmake b/Source/cmake/WebKitCompilerFlags.cmake index b913b5c72e09d..6bbb9900f5d2b 100644 --- a/Source/cmake/WebKitCompilerFlags.cmake +++ b/Source/cmake/WebKitCompilerFlags.cmake @@ -190,6 +190,16 @@ if (COMPILER_IS_GCC_OR_CLANG) WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wno-uninitialized) endif () + # Older GCC versions sometimes miscompile switches with that flag on. + # Observed in testMoveConditionallyFloatingPointSameArg (testmasm), turn it + # off throughout to avoid hard-to-diagnose bugs. + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + # This and later versions don't seem to exhibit the issue. + if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "14.0.1") + WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-fno-unswitch-loops) + endif () + endif () + WEBKIT_PREPEND_GLOBAL_CXX_FLAGS(-Wno-noexcept-type) # These GCC warnings produce too many false positives to be useful. We'll