Hi, I am trying to build the latest tvm 0.11 version in CentOS 7 with gcc/g++ version of 9.3.1 using rhel devtoolset. I installed llvmdev 11.1 and changed cmake.config file as follows:
set(USE_CUDA ON)
set(USE_LLVM /path/to/llvm-config)
and ran the following command
cmake -D CMAKE_C_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/gcc -D CMAKE_CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/g++ ..
make -j16
leading to a linker error:
[100%] Building CXX object CMakeFiles/tvm_objs.dir/src/relay/backend/contrib/example_target_hooks/tir_to_runtime.cc.o
[100%] Building CXX object CMakeFiles/tvm_objs.dir/src/contrib/hybrid/codegen_hybrid.cc.o
[100%] Built target tvm_objs
[100%] Linking CXX shared library libtvm.so
ld.lld: error: undefined symbol: llvm::Intrinsic::getName(unsigned int, llvm::ArrayRef<llvm::Type*>)
>>> referenced by codegen_llvm.cc
>>> CMakeFiles/tvm_objs.dir/src/target/llvm/codegen_llvm.cc.o:(tvm::codegen::CodeGenLLVM::CreateIntrinsic(tvm::tir::CallNode const*))
>>> referenced by llvm_module.cc
>>> CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_module.cc.o:(tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<void tvm::runtime::TypedPackedFunc<tvm::runtime::String (long)>::AssignTypedLambda<tvm::codegen::'lambda7'(long)>(tvm::codegen::'lambda7'(long), std::string)::'lambda'(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*))
ld.lld: error: undefined symbol: llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::function_ref<llvm::Optional<std::string> (llvm::StringRef)>)
>>> referenced by llvm_instance.cc
>>> CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o:(tvm::codegen::LLVMInstance::ParseBuffer(llvm::MemoryBuffer const&) const)
ld.lld: error: undefined symbol: llvm::sys::getDefaultTargetTriple()
>>> referenced by llvm_instance.cc
>>> CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o:(tvm::codegen::LLVMTargetInfo::LLVMTargetInfo(tvm::codegen::LLVMInstance&, tvm::Target const&))
ld.lld: error: undefined symbol: llvm::TargetRegistry::lookupTarget(std::string const&, std::string&)
>>> referenced by llvm_instance.cc
>>> CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_instance.cc.o:(tvm::codegen::LLVMTargetInfo::GetOrCreateTargetMachine(bool))
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/tvm.dir/build.make:1348: libtvm.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:932: CMakeFiles/tvm.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
I tried passing the llvm header path to cmake (CXXFLAGS=-isystem\ llvm/header/path cmake …) but no use. Building libtvm.so for the same repository had no problem in other servers (I tried in ubuntu 20.04, 18.04).
Edit: I checked cmake LLVM_LIBRARY_PATH, LLVM_INCLUDE_DIR path and header inside it, but seem there is nothing wrong.