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

bcc doesn't find llvm cmake files on Ubuntu Xenial #492

Open
drzaeus77 opened this Issue Apr 18, 2016 · 9 comments

Comments

Projects
None yet
5 participants
@drzaeus77
Collaborator

drzaeus77 commented Apr 18, 2016

There is an upstream bug related to cmake+llvm that is affecting our ability to build on Ubuntu Xenial. That bug is tracked at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819072.

The cmake .. phase of our build break with:

$ cmake ..
-- Latest recognized Git tag is v0.1.8
-- Git HEAD is 3036b96e4ba4f03868ff2271765adb031edf21d6
-- Revision is 0.1.8-3036b96e
CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
  include could not find load file:

    /usr/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
  CMakeLists.txt:17 (find_package)


CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:181 (include):
  include could not find load file:

    /usr/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
  CMakeLists.txt:17 (find_package)


-- Found LLVM: /usr/include
CMake Error at CMakeLists.txt:36 (message):
  Unable to find clang libraries


-- Configuring incomplete, errors occurred!

As a workaround, I was able to do the following manually:

sudo apt-get install -y llvm-3.8-dev libclang-3.8-dev
sudo mkdir -p /usr/lib/llvm-3.8/share/llvm
sudo ln -s /usr/share/llvm-3.8/cmake /usr/lib/llvm-3.8/share/llvm/cmake
sudo sed -i -e '/get_filename_component(LLVM_INSTALL_PREFIX/ {s|^|#|}' -e '/^# Compute the installation prefix/i set(LLVM_INSTALL_PREFIX "/usr/lib/llvm-3.8")' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMConfig.cmake
sudo sed -i '/_IMPORT_CHECK_TARGETS Polly/ {s|^|#|}' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports-relwithdebinfo.cmake
sudo sed -i '/_IMPORT_CHECK_TARGETS sancov/ {s|^|#|}' /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports-relwithdebinfo.cmake
sudo ln -s /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1 /usr/lib/llvm-3.8/lib/

This /issue should serve as a placeholder until the upstream is fixed.

@drzaeus77

This comment has been minimized.

Show comment
Hide comment
@drzaeus77

drzaeus77 Jun 26, 2016

Collaborator

Just to update that the debian bug seems to have been resolved, hopefully the fix propagates downstream soon.

Collaborator

drzaeus77 commented Jun 26, 2016

Just to update that the debian bug seems to have been resolved, hopefully the fix propagates downstream soon.

@dark

This comment has been minimized.

Show comment
Hide comment
@dark

dark Sep 23, 2016

Member

For the record, this issue is still open as of today, for package versions:

ii llvm-3.8-dev 1:3.8-2ubuntu4 amd64 Modular compiler and toolchain technologies, libraries and headers
ii libclang-3.8-dev 1:3.8-2ubuntu4 amd64 clang library - Development package

Member

dark commented Sep 23, 2016

For the record, this issue is still open as of today, for package versions:

ii llvm-3.8-dev 1:3.8-2ubuntu4 amd64 Modular compiler and toolchain technologies, libraries and headers
ii libclang-3.8-dev 1:3.8-2ubuntu4 amd64 clang library - Development package

@HammiSaif

This comment has been minimized.

Show comment
Hide comment
@HammiSaif

HammiSaif Mar 6, 2017

No solution for the above error ?

HammiSaif commented Mar 6, 2017

No solution for the above error ?

@drzaeus77

This comment has been minimized.

Show comment
Hide comment
@drzaeus77

drzaeus77 Mar 6, 2017

Collaborator

Not that I am aware of. Would be curious whether it works on 16.10 and above, which may depend on whether 3.9 gets packaged or not.

Collaborator

drzaeus77 commented Mar 6, 2017

Not that I am aware of. Would be curious whether it works on 16.10 and above, which may depend on whether 3.9 gets packaged or not.

@HammiSaif

This comment has been minimized.

Show comment
Hide comment
@HammiSaif

HammiSaif Mar 7, 2017

So how can I build an LLVM pass using cmake on ubuntu 16.04 ?

HammiSaif commented Mar 7, 2017

So how can I build an LLVM pass using cmake on ubuntu 16.04 ?

@drzaeus77

This comment has been minimized.

Show comment
Hide comment
@drzaeus77

drzaeus77 Mar 7, 2017

Collaborator

The workaround mentioned above (symbolic linking and sed commands) is what I use on the buildbots for bcc.

Collaborator

drzaeus77 commented Mar 7, 2017

The workaround mentioned above (symbolic linking and sed commands) is what I use on the buildbots for bcc.

@HammiSaif

This comment has been minimized.

Show comment
Hide comment
@HammiSaif

HammiSaif Mar 10, 2017

Well from this error:
Make Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
include could not find load file:

/usr/share/llvm/cmake/LLVMExports.cmake

Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)

It seems like path to the LLVMExports.cmake file is not set correctly in LLVMConfig.cmake. I changed the line 174 of my LLVMConfig.cmake from " set(LLVM_CMAKE_DIR "${LLVM_INSTALL_PREFIX}/share/llvm/cmake") " to " set(LLVM_CMAKE_DIR "${LLVM_INSTALL_PREFIX}/share/llvm-3.8/cmake")" and above cmake error was removed. I am using Ubuntu 16.04 and installed cmake + llvm using Ubuntu packages.

HammiSaif commented Mar 10, 2017

Well from this error:
Make Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
include could not find load file:

/usr/share/llvm/cmake/LLVMExports.cmake

Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)

It seems like path to the LLVMExports.cmake file is not set correctly in LLVMConfig.cmake. I changed the line 174 of my LLVMConfig.cmake from " set(LLVM_CMAKE_DIR "${LLVM_INSTALL_PREFIX}/share/llvm/cmake") " to " set(LLVM_CMAKE_DIR "${LLVM_INSTALL_PREFIX}/share/llvm-3.8/cmake")" and above cmake error was removed. I am using Ubuntu 16.04 and installed cmake + llvm using Ubuntu packages.

@butterl

This comment has been minimized.

Show comment
Hide comment
@butterl

butterl Jul 15, 2017

@HammiSaif I followed your instruction and fix the previous error but got below error,did you meet it, I also using ubuntu 16.04 and install llvm from apt

CMake Error at /usr/share/llvm-3.8/cmake/LLVMExports.cmake:1034 (message):
  The imported target "LLVMSupport" references the file

     "/usr/lib/libLLVMSupport.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/share/llvm-3.8/cmake/LLVMExports.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include)
  CMakeLists.txt:22 (find_package)

butterl commented Jul 15, 2017

@HammiSaif I followed your instruction and fix the previous error but got below error,did you meet it, I also using ubuntu 16.04 and install llvm from apt

CMake Error at /usr/share/llvm-3.8/cmake/LLVMExports.cmake:1034 (message):
  The imported target "LLVMSupport" references the file

     "/usr/lib/libLLVMSupport.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/share/llvm-3.8/cmake/LLVMExports.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include)
  CMakeLists.txt:22 (find_package)
@gabhijit

This comment has been minimized.

Show comment
Hide comment
@gabhijit

gabhijit Jul 24, 2017

@drzaeus77 @butterl

I somehow managed to get all the CMake errors resolved (broadly following what @drzaeus77 has suggested), but then I got a number of warnings of the type -

In file included from /usr/lib/llvm-3.8/include/clang/AST/Decl.h:17:0,
                 from /usr/lib/llvm-3.8/include/clang/AST/ASTTypeTraits.h:20,
                 from /usr/lib/llvm-3.8/include/clang/AST/ASTContext.h:18,
                 from /usr/lib/llvm-3.8/include/clang/Frontend/ASTUnit.h:18,
                 from /usr/lib/llvm-3.8/include/clang/Frontend/FrontendAction.h:24,
                 from /usr/lib/llvm-3.8/include/clang/CodeGen/CodeGenAction.h:13,
                 from /home/path-to-bcc/bcc/src/cc/frontends/clang/loader.cc:37:
/usr/lib/llvm-3.8/include/clang/AST/APValue.h: In member function ‘clang::APValue::APSInt& clang::APValue::getInt()’:
/usr/lib/llvm-3.8/include/clang/AST/APValue.h:202:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     return *(APSInt*)(char*)Data.buffer;

This looked like chasing rabbit holes. So I finally decided to give llvm and clang 3.8 a pass and built using clang-3.7 and llvm-3.7. ( I had to clean up all llvm-3.8 packages that were installed using apt-get remove llvm-3.8 clang-3.8)

Other than a couple of warnings like this - the compilation was successful.

bcc/build/src/cc/frontends/b/lexer.ll.cc:764:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for ( yyl = 0; yyl < yyleng; ++yyl )

So you might want to try 3.7 instead of 3.8 (Note also: There is a hard-coded reference to 3.7 in CMakeLists.txt - line 41 or something - so may be that is expected version?).

gabhijit commented Jul 24, 2017

@drzaeus77 @butterl

I somehow managed to get all the CMake errors resolved (broadly following what @drzaeus77 has suggested), but then I got a number of warnings of the type -

In file included from /usr/lib/llvm-3.8/include/clang/AST/Decl.h:17:0,
                 from /usr/lib/llvm-3.8/include/clang/AST/ASTTypeTraits.h:20,
                 from /usr/lib/llvm-3.8/include/clang/AST/ASTContext.h:18,
                 from /usr/lib/llvm-3.8/include/clang/Frontend/ASTUnit.h:18,
                 from /usr/lib/llvm-3.8/include/clang/Frontend/FrontendAction.h:24,
                 from /usr/lib/llvm-3.8/include/clang/CodeGen/CodeGenAction.h:13,
                 from /home/path-to-bcc/bcc/src/cc/frontends/clang/loader.cc:37:
/usr/lib/llvm-3.8/include/clang/AST/APValue.h: In member function ‘clang::APValue::APSInt& clang::APValue::getInt()’:
/usr/lib/llvm-3.8/include/clang/AST/APValue.h:202:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     return *(APSInt*)(char*)Data.buffer;

This looked like chasing rabbit holes. So I finally decided to give llvm and clang 3.8 a pass and built using clang-3.7 and llvm-3.7. ( I had to clean up all llvm-3.8 packages that were installed using apt-get remove llvm-3.8 clang-3.8)

Other than a couple of warnings like this - the compilation was successful.

bcc/build/src/cc/frontends/b/lexer.ll.cc:764:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for ( yyl = 0; yyl < yyleng; ++yyl )

So you might want to try 3.7 instead of 3.8 (Note also: There is a hard-coded reference to 3.7 in CMakeLists.txt - line 41 or something - so may be that is expected version?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment