diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -64,8 +64,15 @@ 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(FATAL_ERROR " +No build type selected. You need to pass -DCMAKE_BUILD_TYPE= in order to configure LLVM. +Available options are: + * -DCMAKE_BUILD_TYPE=Release - For an optimized build with no assertions or debug info. + * -DCMAKE_BUILD_TYPE=Debug - For an unoptimized build with assertions and debug info. + * -DCMAKE_BUILD_TYPE=RelWithDebInfo - For an optimized build with no assertions but with debug info. + * -DCMAKE_BUILD_TYPE=MinSizeRel - For a build optimized for size instead of speed. +Learn more about these options in our documentation at https://llvm.org/docs/CMake.html#cmake-build-type +") endif() # Side-by-side subprojects layout: automatically set the @@ -1252,11 +1259,11 @@ set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE) set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE) set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE) - set(BENCHMARK_ENABLE_WERROR ${LLVM_ENABLE_WERROR} CACHE BOOL + set(BENCHMARK_ENABLE_WERROR ${LLVM_ENABLE_WERROR} CACHE BOOL "Handle -Werror for Google Benchmark based on LLVM_ENABLE_WERROR" FORCE) # Since LLVM requires C++11 it is safe to assume that std::regex is available. set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE) - add_subdirectory(${LLVM_THIRD_PARTY_DIR}/benchmark + add_subdirectory(${LLVM_THIRD_PARTY_DIR}/benchmark ${CMAKE_CURRENT_BINARY_DIR}/third-party/benchmark) add_subdirectory(benchmarks) endif() diff --git a/llvm/docs/AdvancedBuilds.rst b/llvm/docs/AdvancedBuilds.rst --- a/llvm/docs/AdvancedBuilds.rst +++ b/llvm/docs/AdvancedBuilds.rst @@ -34,7 +34,7 @@ .. code-block:: console - $ cmake -G Ninja -DCLANG_ENABLE_BOOTSTRAP=On + $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_BOOTSTRAP=On $ ninja stage2 This command itself isn't terribly useful because it assumes default @@ -48,7 +48,7 @@ .. code-block:: console - $ cmake -G Ninja -DCLANG_ENABLE_BOOTSTRAP=On -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE" + $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_BOOTSTRAP=On -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE" $ ninja stage2 CMake options starting by ``BOOTSTRAP_`` will be passed only to the stage2 build. diff --git a/llvm/docs/GettingStarted.rst b/llvm/docs/GettingStarted.rst --- a/llvm/docs/GettingStarted.rst +++ b/llvm/docs/GettingStarted.rst @@ -48,7 +48,7 @@ * ``cd llvm-project`` * ``mkdir build`` * ``cd build`` - * ``cmake -G [options] ../llvm`` + * ``cmake -G -DCMAKE_BUILD_TYPE= [options] ../llvm`` Some common build system generators are: @@ -665,7 +665,7 @@ .. code-block:: console - % cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/install/path + % cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE= -DCMAKE_INSTALL_PREFIX=/install/path [other options] SRC_ROOT Compiling the LLVM Suite Source Code @@ -677,7 +677,7 @@ .. code-block:: console - % cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=type SRC_ROOT + % cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE= -DCMAKE_BUILD_TYPE=type SRC_ROOT Between runs, CMake preserves the values set for all options. CMake has the following build types defined: @@ -784,7 +784,7 @@ .. code-block:: console - % cmake -G "Unix Makefiles" SRC_ROOT + % cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release SRC_ROOT The LLVM build will create a structure underneath *OBJ_ROOT* that matches the LLVM source tree. At each level where source files are present in the source diff --git a/llvm/docs/HowToCrossCompileLLVM.rst b/llvm/docs/HowToCrossCompileLLVM.rst --- a/llvm/docs/HowToCrossCompileLLVM.rst +++ b/llvm/docs/HowToCrossCompileLLVM.rst @@ -145,13 +145,13 @@ .. code-block:: bash - $ cmake -G Ninja + $ cmake -G Ninja -DCMAKE_BUILD_TYPE= If you're using Clang as the cross-compiler, run: .. code-block:: bash - $ CC='clang' CXX='clang++' cmake -G Ninja + $ CC='clang' CXX='clang++' cmake -G Ninja -DCMAKE_BUILD_TYPE= If you have ``clang``/``clang++`` on the path, it should just work, and special Ninja files will be created in the build directory. I strongly suggest 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,14 @@ Changes to building LLVM ------------------------ +* Omitting ``CMAKE_BUILD_TYPE`` when using a single configuration generator is now + an error. You now have to pass ``-DCMAKE_BUILD_TYPE=`` in order to configure + LLVM. This is done to help new users of LLVM select the correct type: since building + LLVM in Debug mode is very resource intensive, we want to make sure that new users + make the choice that lines up with their usage. We have also improved documentation + around this setting that should help new users. You can find this documentation + `here `_. + Changes to TableGen ------------------- diff --git a/llvm/docs/TestSuiteGuide.md b/llvm/docs/TestSuiteGuide.md --- a/llvm/docs/TestSuiteGuide.md +++ b/llvm/docs/TestSuiteGuide.md @@ -386,6 +386,7 @@ ```bash % cmake -G Ninja -D CMAKE_C_COMPILER=path/to/clang \ -C ../test-suite/cmake/caches/target-arm64-iphoneos-internal.cmake \ + -D CMAKE_BUILD_TYPE=Release \ -D TEST_SUITE_REMOTE_HOST=mydevice \ ../test-suite % ninja