bcc icon indicating copy to clipboard operation
bcc copied to clipboard

build failure with clang 10 on Ubuntu 20.04

Open andreimatei opened this issue 5 years ago • 13 comments

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.

andreimatei avatar May 18 '20 02:05 andreimatei

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.

zrait avatar May 29 '20 00:05 zrait

I can confirm that the problem goes away when using clang from the current HEAD.

andreimatei avatar May 29 '20 00:05 andreimatei

I've faced the same issue and fixed by switching llvm version 10.0.1.

110y avatar Sep 23 '20 12:09 110y

You can use the "Automatic installation script" to easily upgrade the Clang and LLVM related tools on Ubuntu. FYI: https://apt.llvm.org/

Becavalier avatar Oct 11 '20 00:10 Becavalier

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)

jnhu76 avatar Mar 30 '21 15:03 jnhu76

has

Could you explain it detailly and which files should modify! Thanks very much.

smehod avatar Aug 31 '21 02:08 smehod

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.

Could you explain it detailly and which files should modify! Thanks very much.

smehod avatar Aug 31 '21 02:08 smehod

I still got this issue when to compile in ubuntu 20.04.

nobody4t avatar Sep 03 '21 01:09 nobody4t

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

RoyZhang7 avatar Jul 12 '22 04:07 RoyZhang7

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?

dgtlrift avatar Feb 03 '23 18:02 dgtlrift

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

wastedfishcn avatar Apr 24 '23 10:04 wastedfishcn

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

jasneetsinghwahan avatar May 03 '23 07:05 jasneetsinghwahan

ubuntu 20, @jnhu76 if contains ${libclangBasic} ,there comes one error multiple define. just like @zrait ,only add Polly , PollyISL, it works.

hackingwu avatar Apr 29 '24 04:04 hackingwu