Skip to content

[CMake] Add missing dependency #108461

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

Conversation

efferifick
Copy link
Contributor

The mlir-capi-execution-engine-test test executable

if(MLIR_ENABLE_EXECUTION_ENGINE)
  _add_capi_test_executable(mlir-capi-execution-engine-test
    execution_engine.c
  LINK_LIBS PRIVATE
    MLIRCAPIConversion
    MLIRCAPIExecutionEngine
    MLIRCAPIRegisterEverything
)
endif()

is run by lit tests, but it is not properly listed as a dependency. It is added in places conditionally across the file tests/CMakeLists.txt

# The native target may not be enabled, in this case we won't
# run tests that involves executing on the host: do not build
# useless binaries.
if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
  list(APPEND MLIR_TEST_DEPENDS
    mlir-cpu-runner
    llc
    mlir_async_runtime
    mlir-capi-execution-engine-test
    mlir_c_runner_utils
    mlir_runner_utils
    mlir_float16_utils
  )
endif()

But this condition is not the same as the one where the test executable is added. It has been reported on discord that the following error occurred:

FAIL: MLIR :: CAPI/execution_engine.c (2 of 2121)
******************** TEST 'MLIR :: CAPI/execution_engine.c' FAILED ********************
Exit Code: 127
Command Output (stdout):
--
# RUN: at line 10
/usr/bin/mlir-capi-execution-engine-test 2>&1 | /usr/bin/FileCheck /builddir/build/BUILD/mlir-19.1.0_rc4-build/mlir-19.1.0-rc4.src/test/CAPI/execution_engine.c
# executed command: /usr/bin/mlir-capi-execution-engine-test
# .---command stderr------------
# | '/usr/bin/mlir-capi-execution-engine-test': command not found
# `-----------------------------

This error will not be deterministic and is dependent on the order in which tools are built. If by any chance, mlir-capi-execution-engine-test is built before the lit tests run, then nothing will happen. But lit tests can be run before mlir-capi-execution-engine-test is built.

This patch adds the mlir-capi-execution-engine to the MLIR_TEST_DEPENDS list when the MLIR_ENABLE_EXECUTION_ENGINE flag is present.

Happy to make changes like:

  • removing mlir-capi-execution-engine-test from the other place where it is included in the tests
  • and merge and sort alphabetically these two commands
set(MLIR_TEST_DEPENDS
FileCheck count not split-file
mlir-capi-ir-test
mlir-capi-irdl-test
mlir-capi-llvm-test
mlir-capi-pass-test
mlir-capi-quant-test
mlir-capi-rewrite-test
mlir-capi-sparse-tensor-test
mlir-capi-transform-test
mlir-capi-transform-interpreter-test
mlir-capi-translation-test
mlir-linalg-ods-yaml-gen
mlir-lsp-server
mlir-opt
  mlir-query
  mlir-reduce
  mlir-tblgen
  mlir-translate
  tblgen-lsp-server
  tblgen-to-irdl
  )

set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
  mlir-capi-pdl-test
  mlir-pdll-lsp-server
  mlir-pdll
  ) 

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the mlir label Sep 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2024

@llvm/pr-subscribers-mlir

Author: Erick Ochoa (efferifick)

Changes

The mlir-capi-execution-engine-test test executable

if(MLIR_ENABLE_EXECUTION_ENGINE)
  _add_capi_test_executable(mlir-capi-execution-engine-test
    execution_engine.c
  LINK_LIBS PRIVATE
    MLIRCAPIConversion
    MLIRCAPIExecutionEngine
    MLIRCAPIRegisterEverything
)
endif()

is run by lit tests, but it is not properly listed as a dependency. It is added in places conditionally across the file tests/CMakeLists.txt

# The native target may not be enabled, in this case we won't
# run tests that involves executing on the host: do not build
# useless binaries.
if(LLVM_ENABLE_PIC AND TARGET ${LLVM_NATIVE_ARCH})
  list(APPEND MLIR_TEST_DEPENDS
    mlir-cpu-runner
    llc
    mlir_async_runtime
    mlir-capi-execution-engine-test
    mlir_c_runner_utils
    mlir_runner_utils
    mlir_float16_utils
  )
endif()

But this condition is not the same as the one where the test executable is added. It has been reported on discord that the following error occurred:

FAIL: MLIR :: CAPI/execution_engine.c (2 of 2121)
******************** TEST 'MLIR :: CAPI/execution_engine.c' FAILED ********************
Exit Code: 127
Command Output (stdout):
--
# RUN: at line 10
/usr/bin/mlir-capi-execution-engine-test 2>&1 | /usr/bin/FileCheck /builddir/build/BUILD/mlir-19.1.0_rc4-build/mlir-19.1.0-rc4.src/test/CAPI/execution_engine.c
# executed command: /usr/bin/mlir-capi-execution-engine-test
# .---command stderr------------
# | '/usr/bin/mlir-capi-execution-engine-test': command not found
# `-----------------------------

This error will not be deterministic and is dependent on the order in which tools are built. If by any chance, mlir-capi-execution-engine-test is built before the lit tests run, then nothing will happen. But lit tests can be run before mlir-capi-execution-engine-test is built.

This patch adds the mlir-capi-execution-engine to the MLIR_TEST_DEPENDS list when the MLIR_ENABLE_EXECUTION_ENGINE flag is present.

Happy to make changes like:

  • removing mlir-capi-execution-engine-test from the other place where it is included in the tests
  • and merge and sort alphabetically these two commands
set(MLIR_TEST_DEPENDS
FileCheck count not split-file
mlir-capi-ir-test
mlir-capi-irdl-test
mlir-capi-llvm-test
mlir-capi-pass-test
mlir-capi-quant-test
mlir-capi-rewrite-test
mlir-capi-sparse-tensor-test
mlir-capi-transform-test
mlir-capi-transform-interpreter-test
mlir-capi-translation-test
mlir-linalg-ods-yaml-gen
mlir-lsp-server
mlir-opt
  mlir-query
  mlir-reduce
  mlir-tblgen
  mlir-translate
  tblgen-lsp-server
  tblgen-to-irdl
  )

set(MLIR_TEST_DEPENDS ${MLIR_TEST_DEPENDS}
  mlir-capi-pdl-test
  mlir-pdll-lsp-server
  mlir-pdll
  ) 

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

1 Files Affected:

  • (modified) mlir/test/CMakeLists.txt (+4)
diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt
index df95e5db11f1e0..4d2d738b734ec6 100644
--- a/mlir/test/CMakeLists.txt
+++ b/mlir/test/CMakeLists.txt
@@ -150,6 +150,10 @@ if(MLIR_ENABLE_CUDA_RUNNER)
   list(APPEND MLIR_TEST_DEPENDS mlir_cuda_runtime)
 endif()
 
+if(MLIR_ENABLE_EXECUTION_ENGINE)
+  list(APPEND MLIR_TEST_DEPENDS mlir-capi-execution-engine-test)
+endif()
+
 if(MLIR_ENABLE_ROCM_RUNNER)
   list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)
 endif()

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

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

image

@makslevental makslevental merged commit 17ff616 into llvm:main Sep 13, 2024
10 checks passed
Copy link

@efferifick Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@tbaederr
Copy link
Contributor

Thanks for the patch, it solved the issue for me. Do you want to backport this to the llvm 19 branch as well?

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.

4 participants