Skip to content

[CMake][mlir] Race condition due to missing dependencies #74611

@e-kud

Description

@e-kud

I have two builds that failed due to absence of mlir/Dialect/OpenMP/OmpCommon.td
https://buildkite.com/llvm-project/github-pull-requests/builds/20376#018c3c3d-939e-437e-901d-09148aa0930b
https://buildkite.com/llvm-project/github-pull-requests/builds/20388#018c3c75-e9f2-472e-8fd1-41227938bd0d

I've made an experiment:

$ rm ./tools/mlir/include/mlir/Dialect/OpenMP/OmpCommon.td
$ ninja tools/mlir/python/dialects/_omp_ops_gen.py
[1/1] Building dialects/_omp_ops_gen.py...
FAILED: tools/mlir/python/dialects/_omp_ops_gen.py
cd /home/eugene/src/llvm-project/build && /home/eugene/src/llvm-project/build/bin/mlir-tblgen -gen-python-op-bindings -bind-dialect=omp -I /home/eugene/src/llvm-project/mlir/python -I/home/eugene/src/llvm-project/build/include -I/home/eugene/src/llvm-project/llvm/include -I/home/eugene/src/llvm-project/mlir/include -I/home/eugene/src/llvm-project/build/tools/mlir/include /home/eugene/src/llvm-project/mlir/python/mlir/dialects/OpenMPOps.td --write-if-changed -o tools/mlir/python/dialects/_omp_ops_gen.py -d tools/mlir/python/dialects/_omp_ops_gen.py.d
Included from /home/eugene/src/llvm-project/mlir/python/mlir/dialects/OpenMPOps.td:12:
/home/eugene/src/llvm-project/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:36:9: error: Could not find include file 'mlir/Dialect/OpenMP/OmpCommon.td'
include "mlir/Dialect/OpenMP/OmpCommon.td"
        ^
Included from /home/eugene/src/llvm-project/mlir/python/mlir/dialects/OpenMPOps.td:12:
/home/eugene/src/llvm-project/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:36:9: error: Unexpected token at top level
include "mlir/Dialect/OpenMP/OmpCommon.td"
        ^
ninja: build stopped: subcommand failed.

This patch fixes the problem

diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 55731943fb78..585918afc263 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -335,7 +335,8 @@ declare_mlir_dialect_python_bindings(
   TD_FILE dialects/OpenMPOps.td
   SOURCES
     dialects/openmp.py
-  DIALECT_NAME omp)
+  DIALECT_NAME omp
+  DEPENDS omp_common_td)

 declare_mlir_dialect_python_bindings(
   ADD_TO_PARENT MLIRPythonSources.Dialects
$ rm ./tools/mlir/include/mlir/Dialect/OpenMP/OmpCommon.td
$ ninja tools/mlir/python/dialects/_omp_ops_gen.py
[2/2] Building dialects/_omp_ops_gen.py...

But maybe a complete review of dependencies is required or there is a more generic approach. Otherwise, if the patch is OK, I'll open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cmakeBuild system in general and CMake in particularmlir

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions