[cpptest] build_module_test.cc check failed

When I run Gtest file build_module_test.cc ,I encounter this:

Running main() from /home/qwe123/googletest/googletest/src/gtest_main.cc unknown file: Failure C++ exception with description "[11:59:42] /home/qwe123/TVMsrc/src/target/codegen.cc:60:

An error occurred during the execution of TVM. For more information, please see: Handle TVM Errors — tvm 0.9.dev182+ge718f5a8a documentation

Check failed: (bf != nullptr) is false: target.build.llvm is not enabled Stack trace: 0: tvm::codegen::Build(tvm::IRModule, tvm::Target) at /home/qwe123/TVMsrc/src/target/codegen.cc:60 1: tvm::build(tvm::runtime::Map<tvm::Target, tvm::IRModule, void, void> const&, tvm::Target const&) at /home/qwe123/TVMsrc/src/driver/driver_api.cc:549 2: tvm::build(tvm::IRModule const&, tvm::Target const&, tvm::Target const&) at /home/qwe123/TVMsrc/src/driver/driver_api.cc:583 3: BuildModule_Basic_Test::TestBody() at /home/qwe123/TVMsrc/tests/cpp/build_module_test.cc:56 4: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) 5: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) 6: testing::Test::Run() 7: testing::TestInfo::Run() 8: testing::TestSuite::Run() 9: testing::internal::UnitTestImpl::RunAllTests() 10: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) 11: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) 12: testing::UnitTest::Run() 13: RUN_ALL_TESTS() 14: main 15: __libc_start_main 16: _start 17: 0xffffffffffffffff

" thrown in the test body.

It seems that my llvm is not enable,so I try another python test:test_minimal_target_codegen_llvm.py, It works .

Launching pytest with arguments /home/qwe123/TVMsrc/tests/python/all-platform-minimal-test/test_minimal_target_codegen_llvm.py --no-header --no-summary -q in /home/qwe123/TVMsrc/tests/python/all-platform-minimal-test

enabled targets: llvm; llvm -device=arm_cpu pytest marker: ============================= test session starts ============================== collecting … collected 1 item

test_minimal_target_codegen_llvm.py::test_llvm_add_pipeline PASSED [100%]

============================== 1 passed in 0.47s ===============================

So why this happened? I am confused about this. My Python llvm test passed, but google test didn’t!

I find that when I create this PackedFunc* object, I can’t find “target.build.llvm”

this Manager m has not “target.build.llvm” attrs inside!*

It does mean that the LLVM is not enabled. The particular global function “target.build.llvm” is defined in the file “src/target/llvm/llvm_module.cc”. Would you like to check if this file is included?

1 Like

Thanks for your reply! I check the file src/target/llvm/llvm_module.cc, indeed it isn’t included.

How can I fix it?

My LLVM system path is quiet correct, and I do make config.cmake as tutorial. image

Thansks for your help.

I want to confirm that I make my LLVM support indeed, so I add a random string in src/target/llvm/llvm_module.cc, and remake TVM, it shows that I do compile with this llvm_module.cc file. pay attention to my compliation process. It recompile llvm_module.cc

I guess it is my CLION IDE cmake-debug goes wrong?

It does not show the tips of building with llvm

when I use Ctest build/cpptest in terminal, it is totally ok! It proves that it is caused by IDE cmake-debug.

I’m not good at using this IDE, so funny.

OK I solve this problem, it is really stupid. It is caused by my unfamiliarity of clion ide.

When I’m using Clion IDE, It will set up a doc called “/cmake-build-debug”. It’s like our file “/build”. However , it lack of the file “config.cmake”

Screenshot from 2022-01-08 21-27-26

I noticed that Cmake in Clion doesn’t support llvm , so I copy config.cmake from file “build”, and paste it in “/cmake-build-debug”. And use direction like we do in “/build”:

cmake …

make -j20

make cpptest

and then, It works and no bug in clion debugger!

I know it is a simple problem, but I hope this will help when other guy use IDE! :grinning: