[PATCH] D75199: Build fix: Turn off _GLIBCXX_DEBUG on gcc 9

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 10:55:01 PST 2020


nhaehnle created this revision.
nhaehnle added reviewers: tstellar, hans, serge-sans-paille.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.

Enabling _GLIBCXX_DEBUG (implied by LLVM_ENABLE_EXPENSIVE_CHECKS) causes
std::min (and presumably others) to no longer be constexpr, which in turn
causes the build to fail.

This seems like a bug in the GCC STL. This change works around it.

Change-Id: I5fc471caa9c4de3ef4e87aeeac8df1b960e8e72c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75199

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75199.246791.patch
Type: text/x-patch
Size: 789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/6f3842e4/attachment.bin>


More information about the llvm-commits mailing list