[llvm-dev] LLVM as a project dependency

Chris Bieneman via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 15 11:14:15 PDT 2016

Hi Paweł,

In general I would strongly recommend against using pre-built packages for development and distribution if you’re supporting multiple platforms. Those mechanisms are great if you’re only supporting one platform, but as you noticed the package managers across different platforms are never in sync, so using pre-built packages introduces a lot of extra burden on you.

There are really two options I would recommend. Which one you use depends on the relationship between your project and LLVM.

If your project is an LLVM or Clang based tool, the simplest solution is probably to structure your project similar to other LLVM tools and drop your source directory into the LLVM tree under “tools”. This will allow the LLVM build system to configure and build your tool with LLVM. This mechanism is widely used for projects like Clang and Polly.

The other approach that is a bit less traveled would be using CMake’s ExternalProject module as you mentioned. The ExternalProject module will allow you to manage the SCM checkout, configuration, build and installation of the LLVM libraries from within your project’s build system. Using ExternalProject is probably not suitable if your tool depends on more than just the LLVM project, so if you’re using Clang libraries as well as LLVM libraries you may not want to follow this approach.

Hope this helps,

> On Jun 15, 2016, at 3:22 AM, Paweł Bylica via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hello LLVM,
> I'm maintaining a project that has the LLVM as a dependency. I tried using pre-built LLVM libraries as much as possible, but have issues with this approach all the time. I would like to discuss alternatives.
> On Linux I try to use llvm-dev packages. Main issues are: different distributions has LLVM packaged differently, the packages are sometimes broken (usually cmake shared files), if not broken at the moment they can brake in the future despite the fact the particular LLVM version has been released long time ago, llvm.org/apt <http://llvm.org/apt> has been closed.
> On macOS I use homebrew. Usually fine but you have to wait long time for a new version (e.g. they rejected LLVM 3.7.0 for some reason). If I'm not wrong, homebrew builds LLVM from source.
> On Windows... I build it myself and upload binaries to GitHub. Then cmake script can download it.
> I really started thinking about building LLVM from source everywhere as a my project build step. It should work more/less the same on all platforms. In the future I might reach for LTO+PGO (I imagine it is not possible using pre-built libraries).
> Ideally would be to setup the dependencies against the LLVM libraries during cmake configuration step and build only required libraries when building my project.
> Recently, I've seen cmake's ExternalProject module (https://cmake.org/cmake/help/v3.5/module/ExternalProject.html <https://cmake.org/cmake/help/v3.5/module/ExternalProject.html>) mentioned here. Can this help with my goal?
> Have you tried something similar? What your opinions? Any suggestions?
> - Paweł
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160615/59d6b0dc/attachment.html>

More information about the llvm-dev mailing list