~dscharrer/arx/master

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • Committer: Daniel Scharrer
  • Date: 2022-01-12 20:35:52 UTC
  • Revision ID: git-v1:c134113478ac30a030b9e62aafba59bd08ca380f
CMake: Don't use __builtin_unreachable() with GCC 9.0-9.4 and 10.0-10.3

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
704
704
        endif()
705
705
        check_builtin(ARX_HAVE_BUILTIN_ASSUME_ALIGNED   "__builtin_assume_aligned")
706
706
        check_builtin(ARX_HAVE_BUILTIN_TRAP             "__builtin_trap")
707
 
        check_builtin(ARX_HAVE_BUILTIN_UNREACHABLE      "__builtin_unreachable")
 
707
        if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
 
708
           ((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.5") OR
 
709
            (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.4")))
 
710
                message(STATUS "Not using __builtin_unreachable() with unpatched GCC 9/10 due to a compiler bug https://arx.vg/1600")
 
711
        else()
 
712
                check_builtin(ARX_HAVE_BUILTIN_UNREACHABLE      "__builtin_unreachable")
 
713
        endif()
708
714
        check_builtin(ARX_HAVE_BUILTIN_EXPECT           "__builtin_expect")
709
715
        
710
716
        if(WIN32)