[PATCH] D118186: [cmake] Allow optionally to build `tablegen` in `Release` and use it in `Debug` for the `Ninja Multi-Config` generator
Argyrios Kyrtzidis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 13:40:39 PST 2022
akyrtzi created this revision.
Herald added a subscriber: mgorny.
akyrtzi requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If `Ninja Multi-Config` is used and LLVM_OPTIMIZED_TABLEGEN=YES is set
tablegen binaries will be built in `Release`, even when building for `Debug` configuration,
without needing a separate configured build directory just for tablegen binaries.
To get such a setup you'd configure like this:
cmake -G 'Ninja Multi-Config' /path/to/llvm-project/llvm \
-DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_CROSS_CONFIGS="Release" \
-DLLVM_OPTIMIZED_TABLEGEN=YES \
....
Also note the other benefit of `Ninja Multi-Config` is saving configure time, particularly when
switching between `Debug` and `Release` during development.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118186
Files:
llvm/CMakeLists.txt
llvm/cmake/modules/TableGen.cmake
Index: llvm/cmake/modules/TableGen.cmake
===================================================================
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -96,6 +96,13 @@
set(tablegen_exe ${${project}_TABLEGEN_EXE})
set(tablegen_depends ${${project}_TABLEGEN_TARGET} ${tablegen_exe})
+ if (LLVM_OPTIMIZED_TABLEGEN_VIA_NINJA_MULTI_CONFIG)
+ set(tablegen_exe "${CMAKE_BINARY_DIR}/Release/bin/${${project}_TABLEGEN_EXE}")
+ # Only depend on the release executable; if we also depend on the target
+ # we'll build for both release and debug.
+ set(tablegen_depends ${tablegen_exe})
+ endif()
+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
COMMAND ${tablegen_exe} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
${tblgen_includes}
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -661,7 +661,12 @@
endif()
option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF)
-if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES)))
+if (LLVM_OPTIMIZED_TABLEGEN AND NOT CMAKE_CROSSCOMPILING AND CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND "Release" IN_LIST CMAKE_CROSS_CONFIGS)
+ # "Ninja Multi-Config" generator allows using release tablegen binaries
+ # without needing a separate configured build directory for them.
+ set(LLVM_OPTIMIZED_TABLEGEN_VIA_NINJA_MULTI_CONFIG TRUE)
+endif()
+if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND NOT LLVM_OPTIMIZED_TABLEGEN_VIA_NINJA_MULTI_CONFIG AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES)))
set(LLVM_USE_HOST_TOOLS ON)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118186.403026.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220125/430896f9/attachment.bin>
More information about the llvm-commits
mailing list