[MLIR][IRDL][CMake] Switch to using setup_host_tool to fix cross compilation#156606
[MLIR][IRDL][CMake] Switch to using setup_host_tool to fix cross compilation#156606Moxinilian merged 2 commits intollvm:mainfrom
setup_host_tool to fix cross compilation#156606Conversation
…mpilation 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.
|
@Moxinilian do you mind reviewing this |
Moxinilian
left a comment
There was a problem hiding this comment.
Excellent! This looks much better indeed, thanks. I wish this was documented somewhere, I swear I did my best with the original implementation 😆
Co-authored-by: Théo Degioanni <30992420+Moxinilian@users.noreply.github.com>
|
@llvm/pr-subscribers-mlir-core @llvm/pr-subscribers-mlir Author: None (Zentrik) ChangesUsing 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. Full diff: https://github.com/llvm/llvm-project/pull/156606.diff 1 Files Affected:
diff --git a/mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt b/mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt
index 3a0f77d856b44..27a7e22db7d7b 100644
--- a/mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt
+++ b/mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt
@@ -6,23 +6,4 @@ mlir_target_link_libraries(mlir-irdl-to-cpp
MLIRTargetIRDLToCpp
)
-# Set up a native build when cross-compiling.
-if(LLVM_USE_HOST_TOOLS)
- build_native_tool(
- mlir-irdl-to-cpp
- MLIR_IRDL_TO_CPP_EXE
-
- # Native tool must depend on target tool so that the native tool gets
- # properly rebuilt when the target tool changes.
- DEPENDS mlir-irdl-to-cpp
- )
- add_custom_target(mlir-irdl-to-cpp-host DEPENDS ${MLIR_IRDL_TO_CPP_EXE})
- set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp-host)
-else()
- set(MLIR_IRDL_TO_CPP_EXE $<TARGET_FILE:mlir-irdl-to-cpp>)
- set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp)
-endif()
-
-# Save the executable path and target name to the cache to expose it globally.
-set(MLIR_IRDL_TO_CPP_EXE "${MLIR_IRDL_TO_CPP_EXE}" CACHE INTERNAL "")
-set(MLIR_IRDL_TO_CPP_TARGET "${MLIR_IRDL_TO_CPP_TARGET}" CACHE INTERNAL "")
+setup_host_tool(mlir-irdl-to-cpp MLIR_IRDL_TO_CPP MLIR_IRDL_TO_CPP_EXE MLIR_IRDL_TO_CPP_TARGET)
|
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
…mpilation (llvm#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. (cherry picked from commit f5006e0)
Using
build_native_tooldirectly doesn't seem to be standard, instead other tools seem to callsetup_host_tool(e.g. milr-linalg-ods-gen andadd_tablegenseems to have a copy ofsetup_host_toolinternally).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.