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