diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-01-08 09:00:53 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-06-10 14:35:18 +0000 |
commit | d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229 (patch) | |
tree | 26ea96bfcdf9f425b45882b4945addac80aec0b1 /bolt/tools | |
parent | fd3304ef8545081246f28cd37be98a05d6f24bdd (diff) | |
download | llvm-d5daa5c5b091cafb9b7ffd19b5dfa2daadef3229.tar.gz |
[cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore
First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.
Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.
@beanz added it in d0e1c2a550ef348aae036d0fe78cab6f038c420c to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.
Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.
To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.
For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D117977
Diffstat (limited to 'bolt/tools')
-rw-r--r-- | bolt/tools/CMakeLists.txt | 14 | ||||
-rw-r--r-- | bolt/tools/driver/CMakeLists.txt | 6 | ||||
-rw-r--r-- | bolt/tools/heatmap/CMakeLists.txt | 2 | ||||
-rw-r--r-- | bolt/tools/merge-fdata/CMakeLists.txt | 2 |
4 files changed, 19 insertions, 5 deletions
diff --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt index 1fe85145d79a..91b00a5438af 100644 --- a/bolt/tools/CMakeLists.txt +++ b/bolt/tools/CMakeLists.txt @@ -1,3 +1,17 @@ +set(BOLT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH + "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") +mark_as_advanced(BOLT_TOOLS_INSTALL_DIR) + +# Move these macros to AddBolt if such a CMake module is ever created. + +macro(add_bolt_tool name) + llvm_add_tool(BOLT ${ARGV}) +endmacro() + +macro(add_bolt_tool_symlink name) + llvm_add_tool_symlink(BOLT ${ARGV}) +endmacro() + add_subdirectory(driver) add_subdirectory(llvm-bolt-fuzzer) add_subdirectory(merge-fdata) diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt index 2338ccec11d2..e56be15dbcff 100644 --- a/bolt/tools/driver/CMakeLists.txt +++ b/bolt/tools/driver/CMakeLists.txt @@ -11,7 +11,7 @@ else() set(BOLT_DRIVER_DEPS "") endif() -add_llvm_tool(llvm-bolt +add_bolt_tool(llvm-bolt llvm-bolt.cpp DEPENDS @@ -25,8 +25,8 @@ target_link_libraries(llvm-bolt LLVMBOLTUtils ) -add_llvm_tool_symlink(perf2bolt llvm-bolt) -add_llvm_tool_symlink(llvm-boltdiff llvm-bolt) +add_bolt_tool_symlink(perf2bolt llvm-bolt) +add_bolt_tool_symlink(llvm-boltdiff llvm-bolt) set(BOLT_DEPENDS llvm-bolt diff --git a/bolt/tools/heatmap/CMakeLists.txt b/bolt/tools/heatmap/CMakeLists.txt index 820b268125e8..cb8e7ee2605c 100644 --- a/bolt/tools/heatmap/CMakeLists.txt +++ b/bolt/tools/heatmap/CMakeLists.txt @@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS Support ) -add_llvm_tool(llvm-bolt-heatmap +add_bolt_tool(llvm-bolt-heatmap heatmap.cpp ) diff --git a/bolt/tools/merge-fdata/CMakeLists.txt b/bolt/tools/merge-fdata/CMakeLists.txt index 2de2ede8f2b5..08b2e65b1bce 100644 --- a/bolt/tools/merge-fdata/CMakeLists.txt +++ b/bolt/tools/merge-fdata/CMakeLists.txt @@ -1,6 +1,6 @@ set(LLVM_LINK_COMPONENTS Support) -add_llvm_tool(merge-fdata +add_bolt_tool(merge-fdata merge-fdata.cpp DEPENDS |