[LLVMdev] Packaging llvm 3.4 for nixpkgs

Shea Levy shea at shealevy.com
Tue Jan 21 12:56:57 PST 2014


Hi all,

I'm a maintainer for nixpkgs, the official package repository of the
nix[1] package manager, and I've just finished adding the packages that
make up the 3.4 release. Overall I am very impressed with your build
system (especially given the scope of the project), but there were a few
minor issues that I thought you might want to know about in case they
can be fixed for future releases.

In nixpkgs, we use llvm as a dependency of mesa (for gallium), and so we
needed to build llvm and clang separately so as not to require all X
users to build clang. In addition, to save space on systems that have
more than one package linked to llvm we build it with shared libraries
(nix allows us to do this safely even if multiple versions of llvm are
installed, see [1] for details). This combination required a few tweaks:

* Before running make for llvm, I had to set up a symlink from
  $prefix/lib pointing to $buildRoot/lib. This is because llvm-tablegen
  runs during the build, but its rpath points to $prefix/lib
* For lld and clang, I had to unpack the llvm source and point
  *_PATH_TO_LLVM_SOURCE appropriately, despite having a proper llvm
  install available in *_PATH_TO_LLVM_BUILD. Based on the comments in
  the cmake file, this should not be necessary
* I had to patch[2] llvm's source tree when building clang so that
  clang-tablegen would not try to build itself in llvm's sources
* I had to patch[3] clang-tools-extra to include a cmake library that I
  guess is normally included by the llvm build

There were several other small issues as well:

* I had to patch[4] polly, I'm guessing that build was never tested with
  CMAKE_CXX_FLAGS set (we set it to use -std=c++11)
* libc++abi depends on the libc++ source for a header, and libc++
  depends on the libc++abi build. Not a full circular dependency but
  annoying to have to unpack the libc++ sources for the libc++abi build
  and then again for the libc++ build
* libc++abi has a spurious -lstdc++ in its build script, which I patched
  out (to no ill effect) in order to avoid a dependency on libstdc++
* There is no official release for libc++abi
* There are no official installation instructions for libc++abi
* It would be nice to be able to build compiler-rt and clang-tools-extra
  separately from llvm and clang, respectively

Anyway, I'm writing this not to complain but to let you know about the
issues. If there's any way I can help improve things, please let me
know!

Cheers,
Shea Levy

1: http://nixos.org/nix
2: https://raw.github.com/NixOS/nixpkgs/fea2266/pkgs/development/compilers/llvm/3.4/llvm-separate-build.patch
3: https://raw.github.com/NixOS/nixpkgs/fea2266/pkgs/development/compilers/llvm/3.4/clang-separate-build.patch
4: https://raw.github.com/NixOS/nixpkgs/fea2266/pkgs/development/compilers/llvm/3.4/polly-separate-build.patch



More information about the llvm-dev mailing list