diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -64,8 +64,10 @@ endif() if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "No build type selected, default to Debug") - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)" FORCE) + message(STATUS "No build type selected, default to Release with assertions enabled. Use -DCMAKE_BUILD_TYPE=Debug to build with debug info") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) + # If the user don't pass build type we should default to enable assertions. + set(ASSERTIONS_DEFAULT ON) endif() # Side-by-side subprojects layout: automatically set the @@ -467,12 +469,14 @@ option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF) option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON) -if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) - option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) -else() - option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) +# Always default Assertions to ON when in Debug +if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set(ASSERTIONS_DEFAULT ON) endif() +include(CMakeDependentOption) +cmake_dependent_option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON ASSERTIONS_DEFAULT OFF) + option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) # While adding scalable vector support to LLVM, we temporarily want to diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -69,6 +69,13 @@ Changes to building LLVM ------------------------ +* Default CMAKE_BUILD_TYPE has changed from Debug to Release in order to make + the default build smaller, faster and less prone to running out of RAM when + linking. +* LLVM_ENABLE_ASSERTIONS is now enabled when CMAKE_BUILD_TYPE is omitted or + CMAKE_BUILD_TYPE is set to Debug. Setting CMAKE_BUILD_TYPE to Release will + disable assertions. You can also override by passing -DLLVM_ENABLE_ASSERTIONS=ON/OFF + Changes to TableGen -------------------