Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build failure with clang 10 on Ubuntu 20.04 #2915

Open
andreimatei opened this issue May 18, 2020 · 13 comments
Open

build failure with clang 10 on Ubuntu 20.04 #2915

andreimatei opened this issue May 18, 2020 · 13 comments

Comments

@andreimatei
Copy link

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.

@zrait
Copy link

zrait commented May 29, 2020

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.

@andreimatei
Copy link
Author

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

@110y
Copy link

110y commented Sep 23, 2020

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

@Becavalier
Copy link

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

@jnhu76
Copy link

jnhu76 commented Mar 30, 2021

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)

@smehod
Copy link

smehod commented Aug 31, 2021

has

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

@smehod
Copy link

smehod commented Aug 31, 2021

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.

@nobody4t
Copy link

nobody4t commented Sep 3, 2021

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

@RoyZhang7
Copy link

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

@dgtlrift
Copy link

dgtlrift commented Feb 3, 2023

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?

@wastedfishcn
Copy link

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

@jasneetsinghwahan
Copy link

jasneetsinghwahan commented May 3, 2023

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

@hackingwu
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests