Skip to content

Commit

Permalink
CMake: Don't use __builtin_unreachable() with GCC 9.0-9.4 and 10.0-10.3
Browse files Browse the repository at this point in the history
These compilers are known to miscompile the save loading code due to
a bug in the variable range information gained from these hints.
This bug was fixed in GCC 11 and has now been backported to the 9 and
10 branches.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97953
Fixes: issue #1600
(cherry picked from commit c134113)
  • Loading branch information
dscharrer committed Apr 2, 2022
1 parent 7c2a8a6 commit d86bb8a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -721,7 +721,13 @@ else(MSVC)
endif()
check_builtin(ARX_HAVE_BUILTIN_ASSUME_ALIGNED "__builtin_assume_aligned")
check_builtin(ARX_HAVE_BUILTIN_TRAP "__builtin_trap")
check_builtin(ARX_HAVE_BUILTIN_UNREACHABLE "__builtin_unreachable")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.5") OR
(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.4")))
message(STATUS "Not using __builtin_unreachable() with unpatched GCC 9/10 due to a compiler bug https://arx.vg/1600")
else()
check_builtin(ARX_HAVE_BUILTIN_UNREACHABLE "__builtin_unreachable")
endif()
if(NOT ARX_HAVE_CXX11_ALIGNOF)
check_builtin(ARX_HAVE_GCC_ALIGNOF "__alignof__")
endif()
Expand Down

0 comments on commit d86bb8a

Please sign in to comment.