Skip to content

Commit 70edfe9

Browse files
authored
[cmake] Fix host tool path with driver build on Windows (#199152)
On Windows, the llvm-shlib dylib build uses the llvm-nm host tool to make all symbols visible by default. The LLVM_TOOL_LLVM_DRIVER_BUILD=ON build would fail because $<TARGET_FILE:llvm-nm> was invalid. This change passes the name of the symlink / executable copy as a custom property so things work out and the llvm-nm.exe host tool can be found.
1 parent 87d6941 commit 70edfe9

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

clang-tools-extra/clang-tidy/misc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ set(LLVM_LINK_COMPONENTS
33
Support
44
)
55

6-
setup_host_tool(clang-tidy-confusable-chars-gen CLANG_TIDY_CONFUSABLE_CHARS_GEN clang_tidy_confusable_chars_gen clang_tidy_confusable_chars_gen_target)
7-
86
add_subdirectory(ConfusableTable)
97

8+
setup_host_tool(clang-tidy-confusable-chars-gen CLANG_TIDY_CONFUSABLE_CHARS_GEN clang_tidy_confusable_chars_gen clang_tidy_confusable_chars_gen_target)
9+
1010
include_directories(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../include-cleaner/include")
1111

1212
add_custom_command(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(LLVM_LINK_COMPONENTS Support)
22
list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
33

4-
add_llvm_executable(clang-tidy-confusable-chars-gen
4+
add_clang_executable(clang-tidy-confusable-chars-gen
55
BuildConfusableTable.cpp
66
)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,9 @@ macro(llvm_add_tool project name)
16041604
)
16051605
generate_llvm_objects(${name} ${ARGN})
16061606
add_custom_target(${name} DEPENDS llvm-driver)
1607+
set_target_properties(${name} PROPERTIES
1608+
LLVM_TOOL_EXECUTABLE
1609+
"${LLVM_RUNTIME_OUTPUT_INTDIR}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
16071610
else()
16081611
add_llvm_executable(${name} ${ARGN})
16091612
@@ -2797,7 +2800,12 @@ function(get_host_tool_path tool_name setting_name exe_var_name target_var_name)
27972800
get_native_tool_path(${tool_name} exe_name)
27982801
set(target_name host_${tool_name})
27992802
else()
2800-
set(exe_name $<TARGET_FILE:${tool_name}>)
2803+
# Driver-built tools set this property in llvm_add_tool because their
2804+
# targets are utilities, not executable targets.
2805+
get_target_property(exe_name ${tool_name} LLVM_TOOL_EXECUTABLE)
2806+
if(NOT exe_name)
2807+
set(exe_name $<TARGET_FILE:${tool_name}>)
2808+
endif()
28012809
set(target_name ${tool_name})
28022810
endif()
28032811
# Force setting the cache variable because they are only used for being

0 commit comments

Comments
 (0)