Compilation error when building llvm-cbe with LLVM-9
hc825b opened this issue · 3 comments
hc825b commented
Hi llvm-cbe-dev,
I encountered the following error message when running make
to build llvm-cbe with LLVM-9
$HOME/comp_ws/llvm-cbe/tools/llvm-cbe/llvm-cbe.cpp:408:3: error: expected unqualified-id before ‘if’
408 | if (Target.addPassesToEmitFile(PM, Out->os(),
...
After a quick look, I think the preprocessor macros from line 394-405 linked below is convoluted and causes a missing if condition or an extra right brace }
when compiling with LLVM-9 or below.
I expand and rewrite the macros manually and this fix worked for my setup. I did not test this against LLVM-10 or LLVM-11.
#if LLVM_VERSION_MAJOR > 10
if (mc::getExplicitRelaxAll()) {
if (codegen::getFileType() != CodeGenFileType::CGFT_ObjectFile)
errs() << argv[0]
<< ": warning: ignoring -mc-relax-all because filetype != obj\n";
}
#elif LLVM_VERSION_MAJOR == 10
if (RelaxAll) {
if (FileType != CodeGenFileType::CGFT_ObjectFile)
errs() << argv[0]
<< ": warning: ignoring -mc-relax-all because filetype != obj\n";
}
#else
if (RelaxAll) {
if (FileType != TargetMachine::CGFT_ObjectFile)
errs() << argv[0]
<< ": warning: ignoring -mc-relax-all because filetype != obj\n";
}
#endif
hc825b commented
I see. That is unfortunate. Thanks for the quick response!
hikari-no-yume commented
By the way, LLVM supports importing bitcode from previous LLVM versions, so if another tool you are using produces LLVM 9 output, it should be no problem to use it with an llvm-cbe built with LLVM 10.