bcc
bcc copied to clipboard
build failure with clang 10 on Ubuntu 20.04
Doing
cmake ..
make build
Leads to:
/usr/bin/ld: /usr/lib/llvm-10/lib/libclangCodeGen.a(BackendUtil.cpp.o): in function `(anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >)':
(.text._ZN12_GLOBAL__N_118EmitAssemblyHelper30EmitAssemblyWithNewPassManagerEN5clang13BackendActionESt10unique_ptrIN4llvm17raw_pwrite_streamESt14default_deleteIS5_EE+0x1f15): undefined reference to `getPollyPluginInfo()'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/cpp/CMakeFiles/HelloWorld.dir/build.make:158: examples/cpp/HelloWorld] Error 1
make[1]: *** [CMakeFiles/Makefile2:1069: examples/cpp/CMakeFiles/HelloWorld.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
This is with clang version 10.0.0-4ubuntu1.
This appears to be upstream clang issue https://bugs.llvm.org/show_bug.cgi?id=44870
A fix claims to have been merged upstream but apparently didn't make this clang release. I gather from other Google hits that there are workarounds to be done in the cmake files, but I don't know the details.
Yes, I believe this is will happen with any llvm version >= 10.
I fixed this for myself just by adding Polly and PollyISL to the list of Clang libs in cmake/clang_libs.cmake and then adding them to the find_library calls in the root CMakeLists.txt, but I don't think this is the ideal solution. The resolutions for the upstream issue will fix builds if whoever is using Clang is using cmake to link Clang or using llvm-config, but not if they are doing things manually the way that bcc does. I'm not familiar with the reasons why bcc manually links Clang, so it'd be great if a regular contributor could take a look at this.
I can confirm that the problem goes away when using clang from the current HEAD.
I've faced the same issue and fixed by switching llvm version 10.0.1.
You can use the "Automatic installation script" to easily upgrade the Clang and LLVM related tools on Ubuntu. FYI: https://apt.llvm.org/
I've face the same issue with clang-10 and Ubuntu 18.04.
I tried to use @zrait 's method. The issue has been solved.
list(APPEND clang_libs
${libclangParse}
${libclangSema}
${libclangCodeGen}
${libclangAnalysis}
${libclangRewrite}
${libclangEdit}
${libclangAST}
${libclangLex}
${libclangBasic}
Polly
PollyISL)
has
Could you explain it detailly and which files should modify! Thanks very much.
Yes, I believe this is will happen with any
llvmversion >= 10.I fixed this for myself just by adding
PollyandPollyISLto the list of Clang libs incmake/clang_libs.cmakeand then adding them to thefind_librarycalls in the rootCMakeLists.txt, but I don't think this is the ideal solution. The resolutions for the upstream issue will fix builds if whoever is using Clang is using cmake to link Clang or usingllvm-config, but not if they are doing things manually the way thatbccdoes. I'm not familiar with the reasons whybccmanually links Clang, so it'd be great if a regular contributor could take a look at this.
Could you explain it detailly and which files should modify! Thanks very much.
I still got this issue when to compile in ubuntu 20.04.
Met the same issue with a similar setting. @zrait and @jnhu76's method worked, except it took me 10 mins to find the file (like @smehod)
For whom come here later, the file you need to add Polly and PollyISL is /bcc/cmake/clang_libs.cmake
I've face the same issue with clang-10 and Ubuntu 18.04.
I tried to use @zrait 's method. The issue has been solved.
list(APPEND clang_libs ${libclangParse} ${libclangSema} ${libclangCodeGen} ${libclangAnalysis} ${libclangRewrite} ${libclangEdit} ${libclangAST} ${libclangLex} ${libclangBasic} Polly PollyISL)
This fix worked. Is this considered a workaround or is there a reason this hasn't been pushed into the codebase?
But when I used this fix, it caused more bugs. Do I just need to change the cmake when using this method? Or do I need to download Polly from LLVM? @dgtlrift
list(APPEND clang_libs ${libclangParse} ${libclangSema} ${libclangCodeGen} ${libclangAnalysis} ${libclangRewrite} ${libclangEdit} ${libclangAST} ${libclangLex} Polly PollyISL)
in my case i didn't include ${libclangbasic} since, it wasn't mentioned there and again running $ make o/p: Build target test_libbcc
my system: $ clang --version clang version 10.0.0-4ubuntu1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
$uname -r 5.15.0-71-generic ubuntu 20.04.6
ubuntu 20, @jnhu76 if contains ${libclangBasic} ,there comes one error multiple define. just like @zrait ,only add Polly , PollyISL, it works.