[PATCH] D124153: [CMake] Change default CMAKE_BUILD_TYPE to Release

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 05:56:09 PDT 2022


thieta updated this revision to Diff 424169.
thieta added a comment.

Enable assertions by default in no CMAKE_BUILD_TYPE is specified


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124153/new/

https://reviews.llvm.org/D124153

Files:
  llvm/CMakeLists.txt
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===================================================================
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -69,6 +69,10 @@
 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.
+
 Changes to TableGen
 -------------------
 
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124153.424169.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220421/f9720c1a/attachment.bin>


More information about the llvm-commits mailing list