2014-01-21 02:19:53 +01:00
|
|
|
{ stdenv
|
|
|
|
, fetch
|
2017-11-10 20:16:11 +01:00
|
|
|
, fetchpatch
|
2014-01-21 02:19:53 +01:00
|
|
|
, perl
|
|
|
|
, groff
|
|
|
|
, cmake
|
2016-11-09 16:05:53 +01:00
|
|
|
, python2
|
2014-01-21 02:19:53 +01:00
|
|
|
, libffi
|
2017-10-30 19:56:34 +01:00
|
|
|
, libbfd
|
2014-01-21 02:19:53 +01:00
|
|
|
, libxml2
|
|
|
|
, valgrind
|
|
|
|
, ncurses
|
|
|
|
, version
|
2014-02-04 00:10:38 +01:00
|
|
|
, zlib
|
2014-05-10 17:29:41 +02:00
|
|
|
, compiler-rt_src
|
2015-10-03 13:16:41 +02:00
|
|
|
, debugVersion ? false
|
2014-01-21 02:19:53 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2014-06-20 00:22:38 +02:00
|
|
|
src = fetch "llvm" "1mzgy7r0dma0npi1qrbr1s5n4nbj1ipxgbiw0q671l4s0r3qs0qp";
|
2014-01-21 02:19:53 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "llvm-${version}";
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
unpackFile ${src}
|
2014-05-10 17:29:41 +02:00
|
|
|
mv llvm-${version}.src llvm
|
2014-01-21 02:19:53 +01:00
|
|
|
sourceRoot=$PWD/llvm
|
2014-05-10 17:29:41 +02:00
|
|
|
unpackFile ${compiler-rt_src}
|
|
|
|
mv compiler-rt-* $sourceRoot/projects/compiler-rt
|
2014-01-21 02:19:53 +01:00
|
|
|
'';
|
|
|
|
|
2014-09-23 13:13:53 +02:00
|
|
|
buildInputs =
|
2017-05-23 18:10:19 +02:00
|
|
|
[ perl groff cmake libxml2 libffi python2 ] /*
|
2014-10-11 22:04:03 +02:00
|
|
|
++ stdenv.lib.optional stdenv.isLinux valgrind */;
|
2014-01-21 02:19:53 +01:00
|
|
|
|
2014-02-04 00:10:38 +01:00
|
|
|
propagatedBuildInputs = [ ncurses zlib ];
|
|
|
|
|
2017-05-23 18:10:19 +02:00
|
|
|
patches = stdenv.lib.optionals (!stdenv.isDarwin) [
|
|
|
|
# llvm-config --libfiles returns (non-existing) static libs
|
2017-06-16 17:52:58 +02:00
|
|
|
../fix-llvm-config.patch
|
2017-05-23 18:10:19 +02:00
|
|
|
];
|
|
|
|
|
2017-11-10 20:16:11 +01:00
|
|
|
postPatch = stdenv.lib.optionalString (stdenv ? glibc) ''
|
|
|
|
(
|
|
|
|
cd projects/compiler-rt
|
|
|
|
patch -p1 -F3 < ${
|
|
|
|
fetchpatch {
|
|
|
|
name = "sigaltstack.patch"; # for glibc-2.26
|
|
|
|
url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
|
|
|
|
sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sed -i "s,#include <pthread.h>,&\n#include <signal.h>,g" \
|
|
|
|
lib/asan/asan_linux.cc
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
2014-01-21 02:19:53 +01:00
|
|
|
# hacky fix: created binaries need to be run before installation
|
|
|
|
preBuild = ''
|
|
|
|
mkdir -p $out/
|
|
|
|
ln -sv $PWD/lib $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = with stdenv; [
|
2015-10-03 13:16:41 +02:00
|
|
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
2013-12-17 01:34:52 +01:00
|
|
|
"-DLLVM_BUILD_TESTS=ON"
|
2014-01-21 02:19:53 +01:00
|
|
|
"-DLLVM_ENABLE_FFI=ON"
|
2015-06-11 00:45:24 +02:00
|
|
|
"-DLLVM_REQUIRES_RTTI=1"
|
2017-10-30 19:56:34 +01:00
|
|
|
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
2014-01-21 02:19:53 +01:00
|
|
|
"-DCMAKE_CXX_FLAGS=-std=c++11"
|
2017-05-23 18:10:19 +02:00
|
|
|
] ++ stdenv.lib.optional (!stdenv.isDarwin) "-DBUILD_SHARED_LIBS=ON";
|
2014-01-21 02:19:53 +01:00
|
|
|
|
2013-12-17 01:34:52 +01:00
|
|
|
postBuild = ''
|
|
|
|
rm -fR $out
|
|
|
|
|
|
|
|
paxmark m bin/{lli,llvm-rtdyld}
|
|
|
|
|
|
|
|
paxmark m unittests/ExecutionEngine/JIT/JITTests
|
|
|
|
paxmark m unittests/ExecutionEngine/MCJIT/MCJITTests
|
|
|
|
paxmark m unittests/Support/SupportTests
|
|
|
|
'';
|
|
|
|
|
2014-01-21 02:19:53 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
passthru.src = src;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Collection of modular and reusable compiler and toolchain technologies";
|
|
|
|
homepage = http://llvm.org/;
|
2017-02-11 23:13:29 +01:00
|
|
|
license = stdenv.lib.licenses.ncsa;
|
2015-07-01 14:11:05 +02:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric ];
|
2014-02-03 01:47:59 +01:00
|
|
|
platforms = stdenv.lib.platforms.all;
|
2014-01-21 02:19:53 +01:00
|
|
|
};
|
|
|
|
}
|