Skip to content

[MLIR][IRDL][CMake] CMake fixes for cross-compilation #145672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arthurqiu
Copy link
Contributor

The PR fixes a misconfigured dependency that causes CMake error "No rule to make target 'NATIVE/bin/mlir-irdl-to-cpp'" for cross-compilation.

@llvmbot llvmbot added the mlir label Jun 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2025

@llvm/pr-subscribers-mlir

Author: None (arthurqiu)

Changes

The PR fixes a misconfigured dependency that causes CMake error "No rule to make target 'NATIVE/bin/mlir-irdl-to-cpp'" for cross-compilation.


Full diff: https://github.com/llvm/llvm-project/pull/145672.diff

1 Files Affected:

  • (modified) mlir/cmake/modules/IRDLToCpp.cmake (+1-1)
diff --git a/mlir/cmake/modules/IRDLToCpp.cmake b/mlir/cmake/modules/IRDLToCpp.cmake
index 8470ccdf55166..2457773ef2565 100644
--- a/mlir/cmake/modules/IRDLToCpp.cmake
+++ b/mlir/cmake/modules/IRDLToCpp.cmake
@@ -5,7 +5,7 @@ function(add_irdl_to_cpp_target target irdl_file)
 
     # The command output depends on the executable to ensure IRDL sources are properly rebuilt
     # if the tool changes.
-    DEPENDS ${MLIR_IRDL_TO_CPP_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file}
+    DEPENDS ${MLIR_IRDL_TO_CPP_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file}
     COMMENT "Building ${irdl_file}..."
   )
   add_custom_target(${target} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${irdl_file}.cpp.inc)

@arthurqiu
Copy link
Contributor Author

@Moxinilian request for review. Thanks!

Copy link
Member

@Moxinilian Moxinilian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked the comment above? Can you make sure that it still correctly rebuilds the sources if the tool changes? If this is not the case you may want to depend on both the target and the executable.

@arthurqiu
Copy link
Contributor Author

Have you checked the comment above? Can you make sure that it still correctly rebuilds the sources if the tool changes? If this is not the case you may want to depend on both the target and the executable.

Not sure if I miss anything, but I think IRDL source should still be rebuilt if it depends on MLIR_IRDL_TO_CPP_TARGET.

https://cmake.org/cmake/help/latest/command/add_custom_command.html

If the argument is the name of a target (created by the add_custom_target(), add_executable(), or add_library() command) a target-level dependency is created to make sure the target is built before any target using this custom command. Additionally, if the target is an executable or library, a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants