One quick way to workaround: Use Clang and Clang++ to build TVM project. You could use
cmake .. -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_C_COMPILER="clang"
,
Then we can avoid this issue.
In fact, this is not our issue. It is the ABI incompatibility issue between Clang and GCC when to handle llvm optional
data structure due to the trivially copyable optimization in the OptionalStorage type
being enabled when compiling with clang and disabled when GCC.
In short, if the LLVM is compiled with Clang, the project links LLVM library should use Clang too. If the LLVM is compiled with GCC, the project links LLVM library should use GCC too.
Unfortunately, The compiler of prebuilt packages of LLVM seems is Clang, not GCC. The LLVM community also aware it: [llvm-dev] Ubuntu LLVM packages incompatible with clang built projects?
And this bug: 39427 – gcc ABI incompatibility when passing llvm::Optional confirm this issue too and one patch for fixing is merged: ⚙ D54540 [ADT] Drop llvm::Optional clang-specific optmization for trivially copyable types. And LLVM 7.1.0 sould contain this patch.
For our TVM of Release 0.5, we should release one note for LLVM 7.0 users
-
If you want to use GCC to build TVM, please use GCC to compile LLVM 7.0 by yourself
-
If you want to use prebuilt packages of LLVM 7.0 on Ubuntu, please use Clang to build TVM.
-
Don’t use LLVM 7.0 until LLVM fix it.
Moreever, we have similar things we should notice: LLVM ERROR: Only small and large code models are allowed on AArch64
It is the same reason.
I suggest we don’t do anything for ugly workaround and wait LLVM 7.1.0.