Commit 1d104f75 authored by Nicolai Hähnle's avatar Nicolai Hähnle
Browse files

Build fix: Turn off _GLIBCXX_DEBUG based on a compile check

Summary:
Enabling _GLIBCXX_DEBUG (implied by LLVM_ENABLE_EXPENSIVE_CHECKS) causes
std::min_element (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

Reviewers: tstellar, hans, serge-sans-paille

Differential Revision: https://reviews.llvm.org/D75199
parent f5ad93d2
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -77,7 +77,22 @@ endif()

if(LLVM_ENABLE_EXPENSIVE_CHECKS)
  add_definitions(-DEXPENSIVE_CHECKS)

  # In some libstdc++ versions, std::min_element is not constexpr when
  # _GLIBCXX_DEBUG is enabled.
  CHECK_CXX_SOURCE_COMPILES("
    #define _GLIBCXX_DEBUG
    #include <algorithm>
    int main(int argc, char** argv) {
      static constexpr int data[] = {0, 1};
      constexpr const int* min_elt = std::min_element(&data[0], &data[2]);
      return 0;
    }" CXX_SUPPORTS_GLIBCXX_DEBUG)
  if(CXX_SUPPORTS_GLIBCXX_DEBUG)
    add_definitions(-D_GLIBCXX_DEBUG)
  else()
    add_definitions(-D_GLIBCXX_ASSERTIONS)
  endif()
endif()

string(TOUPPER "${LLVM_ABI_BREAKING_CHECKS}" uppercase_LLVM_ABI_BREAKING_CHECKS)