Tarantula
Tarantula

Reputation: 19833

How to enable shared library build while using CMake for LLVM?

The problem: Ubuntu 10.10 doesn't supply LLVM CMake modules (/usr/share/llvm) or (/usr/local/share/llvm) when installing LLVM 2.8 from Ubuntu repositories.

So I'm now compiling LLVM 2.8 using CMake by myself and then installing it like this:

cmake ..
make
make install

This will install CMake modules I need to link LLVM into my library. The problem is that when I compile LLVM using CMake, only static libraries are compiled. I saw in LLVM documentation, that you can compile shared libraries using this parameter into CMake:

cmake -DBUILD_SHARED_LIBS=true ..

But now, the CMake returns this error:

-- Target triple: i686-pc-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Building with -fPIC
-- Targeting Alpha
-- Targeting ARM
-- Targeting Blackfin
-- Targeting CBackend
-- Targeting CellSPU
-- Targeting CppBackend
-- Targeting Mips
-- Targeting MBlaze
-- Targeting MSP430
-- Targeting PIC16
-- Targeting PowerPC
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting X86
-- Targeting XCore
-- Configuring done
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "LLVMARMCodeGen" of type SHARED_LIBRARY
    depends on "LLVMARMAsmPrinter"
  "LLVMARMAsmPrinter" of type SHARED_LIBRARY
    depends on "LLVMARMCodeGen"
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
-- Build files have been written to: /llvm-2.8/build

And I cannot compile it as shared library, does anyone knows how to solve that problem ? I need the shared libraries because they're dependencies of many other tools.

Summary

1) LLVM 2.8 from Ubuntu repository installs LLVM shared libraries but doesn't install CMake modules I need.

2) On the other side, if I compile LLVM by myself, it installs the CMake modules I need, but I can only do that when compiling LLVM as static library.

Upvotes: 7

Views: 12505

Answers (3)

Tarantula
Tarantula

Reputation: 19833

After a lot of investigation (google, source and llvmdev mail-list), I discovered that this problem is in fact an issue with the 2.8 release, the compilation of shared libraries using CMake in that release is broken. I'm porting my library now to the version 2.9rc1 which is working fine and was already scheduled to be released soon, thanks for all answers.

Upvotes: 5

ohmantics
ohmantics

Reputation: 1819

Try reading this page and then ask on the llvmdev list if that doesn't help.

Upvotes: 0

Adam Mitz
Adam Mitz

Reputation: 6043

LLVM 2.8 documentation does not mention building with CMake.

Try ./configure --enable-shared

Upvotes: 1

Related Questions