lol
1{ stdenv
2, fetch
3, perl
4, groff
5, cmake
6, python2
7, libffi
8, binutils
9, libxml2
10, valgrind
11, ncurses
12, version
13, zlib
14, compiler-rt_src
15, debugVersion ? false
16}:
17
18let
19 src = fetch "llvm" "1mzgy7r0dma0npi1qrbr1s5n4nbj1ipxgbiw0q671l4s0r3qs0qp";
20in stdenv.mkDerivation rec {
21 name = "llvm-${version}";
22
23 unpackPhase = ''
24 unpackFile ${src}
25 mv llvm-${version}.src llvm
26 sourceRoot=$PWD/llvm
27 unpackFile ${compiler-rt_src}
28 mv compiler-rt-* $sourceRoot/projects/compiler-rt
29 '';
30
31 buildInputs =
32 [ perl groff cmake libxml2 libffi python2 ] /*
33 ++ stdenv.lib.optional stdenv.isLinux valgrind */;
34
35 propagatedBuildInputs = [ ncurses zlib ];
36
37 patches = stdenv.lib.optionals (!stdenv.isDarwin) [
38 # llvm-config --libfiles returns (non-existing) static libs
39 ../fix-llvm-config.patch
40 ];
41
42 # hacky fix: created binaries need to be run before installation
43 preBuild = ''
44 mkdir -p $out/
45 ln -sv $PWD/lib $out
46 '';
47
48 cmakeFlags = with stdenv; [
49 "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
50 "-DLLVM_BUILD_TESTS=ON"
51 "-DLLVM_ENABLE_FFI=ON"
52 "-DLLVM_REQUIRES_RTTI=1"
53 "-DLLVM_BINUTILS_INCDIR=${binutils.dev or binutils}/include"
54 "-DCMAKE_CXX_FLAGS=-std=c++11"
55 ] ++ stdenv.lib.optional (!stdenv.isDarwin) "-DBUILD_SHARED_LIBS=ON";
56
57 postBuild = ''
58 rm -fR $out
59
60 paxmark m bin/{lli,llvm-rtdyld}
61
62 paxmark m unittests/ExecutionEngine/JIT/JITTests
63 paxmark m unittests/ExecutionEngine/MCJIT/MCJITTests
64 paxmark m unittests/Support/SupportTests
65 '';
66
67 enableParallelBuilding = true;
68
69 passthru.src = src;
70
71 meta = {
72 description = "Collection of modular and reusable compiler and toolchain technologies";
73 homepage = http://llvm.org/;
74 license = stdenv.lib.licenses.ncsa;
75 maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric ];
76 platforms = stdenv.lib.platforms.all;
77 };
78}