forked from OSchip/llvm-project
[CMake] Make omitting CMAKE_BUILD_TYPE an error
After a lot of discussion in this diff the consensus was that it is really hard to guess the users intention with their LLVM build. Instead of trying to guess if Debug or Release is the correct default option we opted for just not specifying CMAKE_BUILD_TYPE a error. Discussion on discourse here: https://discourse.llvm.org/t/rfc-select-a-better-linker-by-default-or-warn-about-using-bfd Reviewed By: hans, mehdi_amini, aaron.ballman, jhenderson, MaskRay, awarzynski Differential Revision: https://reviews.llvm.org/D124153
This commit is contained in:
parent
cbd3902fa3
commit
350bdf9227
|
@ -64,8 +64,15 @@ else()
|
|||
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=<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 @@ if (LLVM_INCLUDE_BENCHMARKS)
|
|||
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()
|
||||
|
|
|
@ -34,7 +34,7 @@ CLANG_ENABLE_BOOTSTRAP.
|
|||
|
||||
.. code-block:: console
|
||||
|
||||
$ cmake -G Ninja -DCLANG_ENABLE_BOOTSTRAP=On <path to source>
|
||||
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_BOOTSTRAP=On <path to source>
|
||||
$ ninja stage2
|
||||
|
||||
This command itself isn't terribly useful because it assumes default
|
||||
|
@ -48,7 +48,7 @@ CMake option, each variable separated by a ";". As example:
|
|||
|
||||
.. code-block:: console
|
||||
|
||||
$ cmake -G Ninja -DCLANG_ENABLE_BOOTSTRAP=On -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE" <path to source>
|
||||
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_BOOTSTRAP=On -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE" <path to source>
|
||||
$ ninja stage2
|
||||
|
||||
CMake options starting by ``BOOTSTRAP_`` will be passed only to the stage2 build.
|
||||
|
|
|
@ -48,7 +48,7 @@ This is an example workflow and configuration to get and build the LLVM source:
|
|||
* ``cd llvm-project``
|
||||
* ``mkdir build``
|
||||
* ``cd build``
|
||||
* ``cmake -G <generator> [options] ../llvm``
|
||||
* ``cmake -G <generator> -DCMAKE_BUILD_TYPE=<type> [options] ../llvm``
|
||||
|
||||
Some common build system generators are:
|
||||
|
||||
|
@ -665,7 +665,7 @@ To configure LLVM, follow these steps:
|
|||
|
||||
.. code-block:: console
|
||||
|
||||
% cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/install/path
|
||||
% cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=<type> -DCMAKE_INSTALL_PREFIX=/install/path
|
||||
[other options] SRC_ROOT
|
||||
|
||||
Compiling the LLVM Suite Source Code
|
||||
|
@ -677,7 +677,7 @@ invocation:
|
|||
|
||||
.. code-block:: console
|
||||
|
||||
% cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=type SRC_ROOT
|
||||
% cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=<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 @@ platforms or configurations using the same source tree.
|
|||
|
||||
.. 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
|
||||
|
|
|
@ -145,13 +145,13 @@ Finally, if you're using your platform compiler, run:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cmake -G Ninja <source-dir> <options above>
|
||||
$ cmake -G Ninja <source-dir> -DCMAKE_BUILD_TYPE=<type> <options above>
|
||||
|
||||
If you're using Clang as the cross-compiler, run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ CC='clang' CXX='clang++' cmake -G Ninja <source-dir> <options above>
|
||||
$ CC='clang' CXX='clang++' cmake -G Ninja <source-dir> -DCMAKE_BUILD_TYPE=<type> <options above>
|
||||
|
||||
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
|
||||
|
|
|
@ -69,6 +69,14 @@ Changes to the LLVM IR
|
|||
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=<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 <https://llvm.org/docs/CMake.html#cmake-build-type>`_.
|
||||
|
||||
Changes to TableGen
|
||||
-------------------
|
||||
|
||||
|
|
|
@ -386,6 +386,7 @@ There are two ways to run the tests in a cross compilation setting:
|
|||
```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
|
||||
|
|
Loading…
Reference in New Issue