2016-03-09 00:05:46 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetch
|
|
|
|
, perl
|
|
|
|
, groff
|
|
|
|
, cmake
|
|
|
|
, python
|
|
|
|
, libffi
|
|
|
|
, binutils
|
|
|
|
, libxml2
|
|
|
|
, valgrind
|
|
|
|
, ncurses
|
|
|
|
, version
|
|
|
|
, zlib
|
|
|
|
, compiler-rt_src
|
|
|
|
, libcxxabi
|
|
|
|
, debugVersion ? false
|
2016-08-17 11:43:57 +00:00
|
|
|
, enableSharedLibraries ? true
|
2016-03-09 00:05:46 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2016-08-30 18:56:01 +00:00
|
|
|
src = fetch "llvm" "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf";
|
2016-03-09 00:05:46 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "llvm-${version}";
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
unpackFile ${src}
|
|
|
|
mv llvm-${version}.src llvm
|
|
|
|
sourceRoot=$PWD/llvm
|
|
|
|
unpackFile ${compiler-rt_src}
|
|
|
|
mv compiler-rt-* $sourceRoot/projects/compiler-rt
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ perl groff cmake libxml2 python libffi ]
|
|
|
|
++ stdenv.lib.optional stdenv.isDarwin libcxxabi;
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ ncurses zlib ];
|
|
|
|
|
2016-11-15 21:39:08 +00:00
|
|
|
# Fix a segfault in llc
|
|
|
|
# See http://lists.llvm.org/pipermail/llvm-dev/2016-October/106500.html
|
|
|
|
patches = [ ./D17533-1.patch ];
|
|
|
|
|
2016-05-05 22:43:54 +00:00
|
|
|
# hacky fix: New LLVM releases require a newer OS X SDK than
|
|
|
|
# 10.9. This is a temporary measure until nixpkgs darwin support is
|
|
|
|
# updated.
|
2016-11-15 21:39:08 +00:00
|
|
|
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
|
2016-05-05 22:43:54 +00:00
|
|
|
sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
|
|
|
|
'';
|
|
|
|
|
2016-03-09 00:05:46 +00:00
|
|
|
# hacky fix: created binaries need to be run before installation
|
|
|
|
preBuild = ''
|
|
|
|
mkdir -p $out/
|
|
|
|
ln -sv $PWD/lib $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = with stdenv; [
|
|
|
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
|
|
|
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
|
|
|
"-DLLVM_BUILD_TESTS=ON"
|
|
|
|
"-DLLVM_ENABLE_FFI=ON"
|
|
|
|
"-DLLVM_ENABLE_RTTI=ON"
|
|
|
|
] ++ stdenv.lib.optional enableSharedLibraries [
|
|
|
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
|
|
|
] ++ stdenv.lib.optional (!isDarwin)
|
2016-04-16 16:44:01 +00:00
|
|
|
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include"
|
2016-03-09 00:05:46 +00:00
|
|
|
++ stdenv.lib.optionals ( isDarwin) [
|
|
|
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
|
|
|
"-DCAN_TARGET_i386=false"
|
|
|
|
];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
rm -fR $out
|
|
|
|
|
|
|
|
paxmark m bin/{lli,llvm-rtdyld}
|
|
|
|
'';
|
|
|
|
|
2016-08-17 11:43:57 +00:00
|
|
|
postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
|
|
|
|
install_name_tool -id $out/lib/libLLVM.dylib $out/lib/libLLVM.dylib
|
|
|
|
ln -s $out/lib/libLLVM.dylib $out/lib/libLLVM-${version}.dylib
|
|
|
|
'';
|
|
|
|
|
2016-03-09 00:05:46 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
passthru.src = src;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Collection of modular and reusable compiler and toolchain technologies";
|
|
|
|
homepage = http://llvm.org/;
|
2017-02-11 22:13:29 +00:00
|
|
|
license = stdenv.lib.licenses.ncsa;
|
2016-03-09 00:05:46 +00:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric ];
|
|
|
|
platforms = stdenv.lib.platforms.all;
|
|
|
|
};
|
|
|
|
}
|