This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGd3da9067d143: [CMake] Allow setting the location of host tools with LLVM_NATIVE_TOOL_DIR (authored by mstorsjo).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131052/new/ https://reviews.llvm.org/D131052 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt clang-tools-extra/pseudo/include/CMakeLists.txt llvm/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/cmake/modules/TableGen.cmake llvm/tools/llvm-config/CMakeLists.txt mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
Index: mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt =================================================================== --- mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt +++ mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt @@ -14,23 +14,13 @@ MLIRParser ) -set(MLIR_LINALG_ODS_YAML_GEN mlir-linalg-ods-yaml-gen CACHE - STRING "Native mlir-linalg-ods-yaml-gen executable. Saves building one when cross-compiling.") +setup_host_tool(mlir-linalg-ods-yaml-gen MLIR_LINALG_ODS_YAML_GEN MLIR_LINALG_ODS_YAML_GEN_EXE MLIR_LINALG_ODS_YAML_GEN_TARGET) -set(MLIR_LINALG_ODS_YAML_GEN_EXE ${MLIR_LINALG_ODS_YAML_GEN} PARENT_SCOPE) -set(MLIR_LINALG_ODS_YAML_GEN_TARGET mlir-linalg-ods-yaml-gen PARENT_SCOPE) +if(NOT ${MLIR_LINALG_ODS_YAML_GEN_EXE} STREQUAL "mlir-linalg-ods-yaml-gen") + add_custom_target(mlir-linalg-ods-yaml-gen-host DEPENDS ${MLIR_LINALG_ODS_YAML_GEN_EXE}) -if(LLVM_USE_HOST_TOOLS) - if (${MLIR_LINALG_ODS_YAML_GEN} STREQUAL "mlir-linalg-ods-yaml-gen") - build_native_tool(mlir-linalg-ods-yaml-gen MLIR_LINALG_ODS_YAML_GEN_EXE DEPENDS mlir-linalg-ods-yaml-gen) - set(MLIR_LINALG_ODS_YAML_GEN_EXE ${MLIR_LINALG_ODS_YAML_GEN_EXE} PARENT_SCOPE) - - add_custom_target(mlir-linalg-ods-yaml-gen-host DEPENDS ${MLIR_LINALG_ODS_YAML_GEN_EXE}) - set(MLIR_LINALG_ODS_YAML_GEN_TARGET mlir-linalg-ods-yaml-gen-host DEPENDS PARENT_SCOPE) - - if(NOT LLVM_BUILD_UTILS) - set_target_properties(mlir-linalg-ods-yaml-gen PROPERTIES EXCLUDE_FROM_ALL ON) - endif() + if(NOT LLVM_BUILD_UTILS) + set_target_properties(mlir-linalg-ods-yaml-gen PROPERTIES EXCLUDE_FROM_ALL ON) endif() endif() Index: llvm/tools/llvm-config/CMakeLists.txt =================================================================== --- llvm/tools/llvm-config/CMakeLists.txt +++ llvm/tools/llvm-config/CMakeLists.txt @@ -91,10 +91,18 @@ # Add the dependency on the generation step. add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH}) -if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH) - build_native_tool(llvm-config LLVM_CONFIG_PATH) - set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") +if(CMAKE_CROSSCOMPILING) + if (LLVM_NATIVE_TOOL_DIR AND NOT LLVM_CONFIG_PATH) + if (EXISTS "${LLVM_NATIVE_TOOL_DIR}/llvm-config${LLVM_HOST_EXECUTABLE_SUFFIX}") + set(LLVM_CONFIG_PATH "${LLVM_NATIVE_TOOL_DIR}/llvm-config${LLVM_HOST_EXECUTABLE_SUFFIX}") + endif() + endif() - add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) - add_dependencies(llvm-config NativeLLVMConfig) + if (NOT LLVM_CONFIG_PATH) + build_native_tool(llvm-config LLVM_CONFIG_PATH) + set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "") + + add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH}) + add_dependencies(llvm-config NativeLLVMConfig) + endif() endif() Index: llvm/cmake/modules/TableGen.cmake =================================================================== --- llvm/cmake/modules/TableGen.cmake +++ llvm/cmake/modules/TableGen.cmake @@ -156,7 +156,13 @@ ${ADD_TABLEGEN_UNPARSED_ARGUMENTS}) set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) - set(${project}_TABLEGEN "${target}" CACHE + set(${project}_TABLEGEN_DEFAULT "${target}") + if (LLVM_NATIVE_TOOL_DIR) + if (EXISTS "${LLVM_NATIVE_TOOL_DIR}/${target}${LLVM_HOST_EXECUTABLE_SUFFIX}") + set(${project}_TABLEGEN_DEFAULT "${LLVM_NATIVE_TOOL_DIR}/${target}${LLVM_HOST_EXECUTABLE_SUFFIX}") + endif() + endif() + set(${project}_TABLEGEN "${${project}_TABLEGEN_DEFAULT}" CACHE STRING "Native TableGen executable. Saves building one when cross-compiling.") # Effective tblgen executable to be used: Index: llvm/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/cmake/modules/AddLLVM.cmake +++ llvm/cmake/modules/AddLLVM.cmake @@ -2397,3 +2397,31 @@ endif() endif() endfunction() + +function(setup_host_tool tool_name setting_name exe_var_name target_var_name) + set(${setting_name}_DEFAULT "${tool_name}") + + if(LLVM_USE_HOST_TOOLS AND LLVM_NATIVE_TOOL_DIR) + if(EXISTS "${LLVM_NATIVE_TOOL_DIR}/${tool_name}${LLVM_HOST_EXECUTABLE_SUFFIX}") + set(${setting_name}_DEFAULT "${LLVM_NATIVE_TOOL_DIR}/${tool_name}${LLVM_HOST_EXECUTABLE_SUFFIX}") + endif() + endif() + + set(${setting_name} "${${setting_name}_DEFAULT}" CACHE + STRING "Host ${tool_name} executable. Saves building if cross-compiling.") + + if(LLVM_USE_HOST_TOOLS) + if(NOT ${setting_name} STREQUAL "${tool_name}") + set(exe_name ${${setting_name}}) + set(target_name ${${setting_name}}) + else() + build_native_tool(${tool_name} exe_name DEPENDS ${tool_name}) + set(target_name ${exe_name}) + endif() + else() + set(exe_name $<TARGET_FILE:${tool_name}>) + set(target_name ${tool_name}) + endif() + set(${exe_var_name} "${exe_name}" CACHE STRING "") + set(${target_var_name} "${target_name}" CACHE STRING "") +endfunction() Index: llvm/CMakeLists.txt =================================================================== --- llvm/CMakeLists.txt +++ llvm/CMakeLists.txt @@ -665,6 +665,7 @@ if( WIN32 AND NOT CYGWIN ) set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") endif() +set(LLVM_NATIVE_TOOL_DIR "" CACHE PATH "Path to a directory containing prebuilt matching native tools (such as llvm-tblgen)") set(LLVM_INTEGRATED_CRT_ALLOC "" CACHE PATH "Replace the Windows CRT allocator with any of {rpmalloc|mimalloc|snmalloc}. Only works with /MT enabled.") if(LLVM_INTEGRATED_CRT_ALLOC) Index: clang-tools-extra/pseudo/include/CMakeLists.txt =================================================================== --- clang-tools-extra/pseudo/include/CMakeLists.txt +++ clang-tools-extra/pseudo/include/CMakeLists.txt @@ -1,21 +1,7 @@ # The cxx.bnf grammar file set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf) -set(CLANG_PSEUDO_GEN "clang-pseudo-gen" CACHE - STRING "Host clang-pseudo-gen executable. Saves building if cross-compiling.") - -if(NOT CLANG_PSEUDO_GEN STREQUAL "clang-pseudo-gen") - set(pseudo_gen ${CLANG_PSEUDO_GEN}) - set(pseudo_gen_target ${CLANG_PSEUDO_GEN}) -elseif(LLVM_USE_HOST_TOOLS) - # The NATIVE executable *must* depend on the current target, otherwise the - # native one won't get rebuilt when the pseudo-gen sources change. - build_native_tool(clang-pseudo-gen pseudo_gen DEPENDS clang-pseudo-gen) - set(pseudo_gen_target "${pseudo_gen}") -else() - set(pseudo_gen $<TARGET_FILE:clang-pseudo-gen>) - set(pseudo_gen_target clang-pseudo-gen) -endif() +setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target) # Generate inc files. set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc) Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt =================================================================== --- clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -3,19 +3,7 @@ Support ) -set(CLANG_TIDY_CONFUSABLE_CHARS_GEN "clang-tidy-confusable-chars-gen" CACHE - STRING "Host clang-tidy-confusable-chars-gen executable. Saves building if cross-compiling.") - -if(NOT CLANG_TIDY_CONFUSABLE_CHARS_GEN STREQUAL "clang-tidy-confusable-chars-gen") - set(clang_tidy_confusable_chars_gen ${CLANG_TIDY_CONFUSABLE_CHARS_GEN}) - set(clang_tidy_confusable_chars_gen_target ${CLANG_TIDY_CONFUSABLE_CHARS_GEN}) -elseif(LLVM_USE_HOST_TOOLS) - build_native_tool(clang-tidy-confusable-chars-gen clang_tidy_confusable_chars_gen) - set(clang_tidy_confusable_chars_gen_target "${clang_tidy_confusable_chars_gen}") -else() - set(clang_tidy_confusable_chars_gen $<TARGET_FILE:clang-tidy-confusable-chars-gen>) - set(clang_tidy_confusable_chars_gen_target clang-tidy-confusable-chars-gen) -endif() +setup_host_tool(clang-tidy-confusable-chars-gen CLANG_TIDY_CONFUSABLE_CHARS_GEN clang_tidy_confusable_chars_gen clang_tidy_confusable_chars_gen_target) add_subdirectory(ConfusableTable)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits