Skip to content

Commit f5006e0

Browse files
authored
[MLIR][IRDL][CMake] Switch to using setup_host_tool to fix cross compilation (#156606)
Using `build_native_tool` directly doesn't seem to be standard, instead other tools seem to call `setup_host_tool` (e.g. milr-linalg-ods-gen and `add_tablegen` seems to have a copy of `setup_host_tool` internally). When cross compiling llvm in two stages, the first building all native tools and then the second using those built tools to cross compile, this prevents the second stage from trying to rebuild mlir-irdl-to-cpp, which fails.
1 parent 96b1dfb commit f5006e0

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,4 @@ mlir_target_link_libraries(mlir-irdl-to-cpp
66
MLIRTargetIRDLToCpp
77
)
88

9-
# Set up a native build when cross-compiling.
10-
if(LLVM_USE_HOST_TOOLS)
11-
build_native_tool(
12-
mlir-irdl-to-cpp
13-
MLIR_IRDL_TO_CPP_EXE
14-
15-
# Native tool must depend on target tool so that the native tool gets
16-
# properly rebuilt when the target tool changes.
17-
DEPENDS mlir-irdl-to-cpp
18-
)
19-
add_custom_target(mlir-irdl-to-cpp-host DEPENDS ${MLIR_IRDL_TO_CPP_EXE})
20-
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp-host)
21-
else()
22-
set(MLIR_IRDL_TO_CPP_EXE $<TARGET_FILE:mlir-irdl-to-cpp>)
23-
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp)
24-
endif()
25-
26-
# Save the executable path and target name to the cache to expose it globally.
27-
set(MLIR_IRDL_TO_CPP_EXE "${MLIR_IRDL_TO_CPP_EXE}" CACHE INTERNAL "")
28-
set(MLIR_IRDL_TO_CPP_TARGET "${MLIR_IRDL_TO_CPP_TARGET}" CACHE INTERNAL "")
9+
setup_host_tool(mlir-irdl-to-cpp MLIR_IRDL_TO_CPP MLIR_IRDL_TO_CPP_EXE MLIR_IRDL_TO_CPP_TARGET)

0 commit comments

Comments
 (0)