I attempted to build TVM with LLVM 19 but failed with the following errors. I checked the LLVM docs and PRs and found that it seems like they dropped Module.h include during LLVM 19 development cycle which caused the error. I'll send the PR to fix it.
llvm/llvm-project#96892
https://llvm.org/doxygen/classllvm_1_1Module.html
Got the below error message.
FAILED: CMakeFiles/tvm_objs.dir/src/target/llvm/codegen_amdgpu.cc.o
ccache /usr/bin/c++ -DDMLC_USE_FOPEN64=0 -DDMLC_USE_LOGGING_LIBRARY="<tvm/runtime/logging.h>" -DNDEBUG=1 -DTVM_INDEX_DEFAULT_I64=1 -DTVM_LLVM_HAS_AARCH64_TARGET=1 -DTVM_LLVM_VERSION=190 -DTVM_LOG_DEBUG -DTVM_THREADPOOL_USE_OPENMP=0 -DTVM_USE_LIBBACKTRACE=1 -DUSE_FALLBACK_STL_MAP=0 -DUSE_MICRO_STANDALONE_RUNTIME=1 -DUSE_RELAY_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DDMLC_ENABLE_RTTI=0 -I/home/ubuntu/data/sandbox/_dep/tvm/include -I/home/ubuntu/data/sandbox/_dep/tvm/build/libbacktrace/include -I/home/ubuntu/data/sandbox/_dep/tvm/3rdparty/libcrc/include -isystem /home/ubuntu/data/sandbox/_dep/tvm/3rdparty/dlpack/include -isystem /home/ubuntu/data/sandbox/_dep/tvm/3rdparty/dmlc-core/include -isystem /home/ubuntu/data/sandbox/_dep/tvm/3rdparty/rang/include -isystem /home/ubuntu/data/sandbox/_dep/tvm/3rdparty/compiler-rt -isystem /home/ubuntu/data/sandbox/_dep/tvm/3rdparty/picojson -isystem /home/ubuntu/data/source/llvm-project/llvm/include -isystem /home/ubuntu/data/source/llvm-project/build/include -std=c++17 -faligned-new -O2 -Wall -fPIC -fno-rtti -MD -MT CMakeFiles/tvm_objs.dir/src/target/llvm/codegen_amdgpu.cc.o -MF CMakeFiles/tvm_objs.dir/src/target/llvm/codegen_amdgpu.cc.o.d -o CMakeFiles/tvm_objs.dir/src/target/llvm/codegen_amdgpu.cc.o -c /home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc: In function ‘tvm::runtime::Module tvm::codegen::BuildAMDGPU(tvm::IRModule, tvm::Target)’:
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:274:9: error: invalid use of incomplete type ‘class llvm::Module’
274 | mlib->setTargetTriple(llvm_target->GetTargetTriple());
| ^~
In file included from /home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Argument.h:18,
from /home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Function.h:25,
from /home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:29:
/home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Value.h:47:7: note: forward declaration of ‘class llvm::Module’
47 | class Module;
| ^~~~~~
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:275:9: error: invalid use of incomplete type ‘class llvm::Module’
275 | mlib->setDataLayout(tm->createDataLayout());
| ^~
/home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Value.h:47:7: note: forward declaration of ‘class llvm::Module’
47 | class Module;
| ^~~~~~
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:277:34: error: invalid use of incomplete type ‘class llvm::Module’
277 | for (llvm::Function& f : mlib->functions()) {
| ^~
/home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Value.h:47:7: note: forward declaration of ‘class llvm::Module’
47 | class Module;
| ^~~~~~
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:289:9: error: invalid use of incomplete type ‘class llvm::Module’
289 | module->print(dest_ll, nullptr);
| ^~
/home/ubuntu/data/source/llvm-project/llvm/include/llvm/IR/Value.h:47:7: note: forward declaration of ‘class llvm::Module’
47 | class Module;
| ^~~~~~
In file included from /usr/include/c++/13/memory:78,
from /home/ubuntu/data/source/llvm-project/llvm/include/llvm/ADT/SmallVector.h:28,
from /home/ubuntu/data/source/llvm-project/llvm/include/llvm/ADT/SmallString.h:17,
from /home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:26:
/usr/include/c++/13/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = llvm::Module]’:
/usr/include/c++/13/bits/unique_ptr.h:404:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = llvm::Module; _Dp = std::default_delete<llvm::Module>]’
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:273:62: required from here
/usr/include/c++/13/bits/unique_ptr.h:97:23: error: invalid application of ‘sizeof’ to incomplete type ‘llvm::Module’
97 | static_assert(sizeof(_Tp)>0,
| ^~~~~~~~~~~
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc: In member function ‘virtual llvm::Value* tvm::codegen::CodeGenAMDGPU::CreateStorageSync(const tvm::tir::CallNode*)’:
/home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:205:3: warning: control reaches end of non-void function [-Wreturn-type]
205 | }
| ^
In file included from /home/ubuntu/data/sandbox/_dep/tvm/include/tvm/tir/stmt_functor.h:31,
from /home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_llvm.h:61,
from /home/ubuntu/data/sandbox/_dep/tvm/src/target/llvm/codegen_amdgpu.cc:55:
/home/ubuntu/data/sandbox/_dep/tvm/include/tvm/tir/expr_functor.h: In member function ‘R tvm::tir::ExprFunctor<R(const tvm::PrimExpr&, Args ...)>::VisitExprDefault_(const tvm::runtime::Object*, Args ...) [with R = llvm::Value*; Args = {}]’:
/home/ubuntu/data/sandbox/_dep/tvm/include/tvm/tir/expr_functor.h:154:48: warning: control reaches end of non-void function [-Wreturn-type]
154 | LOG(FATAL) << "Do not have a default for " << op->GetTypeKey();
| ^
ninja: build stopped: subcommand failed.
Build TVM with LLVM.
I attempted to build TVM with LLVM 19 but failed with the following errors. I checked the LLVM docs and PRs and found that it seems like they dropped
Module.hinclude during LLVM 19 development cycle which caused the error. I'll send the PR to fix it.llvm/llvm-project#96892
https://llvm.org/doxygen/classllvm_1_1Module.html
Expected behavior
TVM successfully compiles
Actual behavior
Got the below error message.
Environment
Steps to reproduce
Build TVM with LLVM.
Triage