diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -77,7 +77,13 @@ if(LLVM_ENABLE_EXPENSIVE_CHECKS) add_definitions(-DEXPENSIVE_CHECKS) - add_definitions(-D_GLIBCXX_DEBUG) + + # With gcc 9's STL, std::min is not constexpr when _GLIBCXX_DEBUG is enabled. + if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND + (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9) AND + (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))) # optimistic assumption about gcc 10 + add_definitions(-D_GLIBCXX_DEBUG) + endif() endif() string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)