2016-03-09 00:05:46 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetch
|
2017-11-07 08:17:00 +00:00
|
|
|
, fetchpatch
|
2016-03-09 00:05:46 +00:00
|
|
|
, perl
|
|
|
|
, groff
|
|
|
|
, cmake
|
|
|
|
, python
|
|
|
|
, libffi
|
2017-10-30 18:56:34 +00:00
|
|
|
, libbfd
|
2016-03-09 00:05:46 +00:00
|
|
|
, libxml2
|
|
|
|
, ncurses
|
|
|
|
, version
|
|
|
|
, zlib
|
|
|
|
, compiler-rt_src
|
|
|
|
, debugVersion ? false
|
2016-08-17 12:43:57 +01:00
|
|
|
, enableSharedLibraries ? true
|
2016-03-09 00:05:46 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2016-08-30 19:56:01 +01: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
|
|
|
|
'';
|
|
|
|
|
2018-06-13 22:18:19 +01:00
|
|
|
buildInputs = [ perl groff cmake libxml2 python libffi ];
|
2016-03-09 00:05:46 +00:00
|
|
|
|
|
|
|
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
|
2018-06-23 17:51:22 +01:00
|
|
|
patches = [ ./D17533-1.patch ]
|
|
|
|
++ stdenv.lib.optional (!stdenv.isDarwin) ./fix-llvm-config.patch
|
|
|
|
++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
|
|
|
|
../TLI-musl.patch
|
|
|
|
../dynamiclibrary-musl.patch
|
|
|
|
];
|
2016-11-15 21:39:08 +00:00
|
|
|
|
2017-08-06 23:05:18 +01:00
|
|
|
# hacky fix: New LLVM releases require a newer macOS SDK than
|
2016-05-05 23:43:54 +01:00
|
|
|
# 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 ''
|
2017-10-06 06:26:19 +01:00
|
|
|
sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
|
|
|
|
|
|
|
|
substituteInPlace CMakeLists.txt \
|
2019-01-07 04:11:38 +00:00
|
|
|
--replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \
|
2017-10-06 06:26:19 +01:00
|
|
|
--replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' ""
|
2017-11-07 08:17:00 +00:00
|
|
|
''
|
2018-06-23 17:47:04 +01:00
|
|
|
+ ''
|
2017-11-07 08:17:00 +00:00
|
|
|
(
|
|
|
|
cd projects/compiler-rt
|
|
|
|
patch -p1 < ${
|
|
|
|
fetchpatch {
|
|
|
|
name = "sigaltstack.patch"; # for glibc-2.26
|
|
|
|
url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
|
|
|
|
sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2016-05-05 23:43:54 +01:00
|
|
|
'';
|
|
|
|
|
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"
|
2018-06-23 22:53:38 +01:00
|
|
|
|
|
|
|
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
|
|
|
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}"
|
|
|
|
"-DTARGET_TRIPLE=${stdenv.targetPlatform.config}"
|
2016-03-09 00:05:46 +00:00
|
|
|
] ++ stdenv.lib.optional enableSharedLibraries [
|
|
|
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
|
|
|
] ++ stdenv.lib.optional (!isDarwin)
|
2017-10-30 18:56:34 +00:00
|
|
|
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
2016-03-09 00:05:46 +00:00
|
|
|
++ stdenv.lib.optionals ( isDarwin) [
|
|
|
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
|
|
|
"-DCAN_TARGET_i386=false"
|
2018-06-23 17:51:22 +01:00
|
|
|
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
|
|
|
|
# Not yet supported
|
|
|
|
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
|
|
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
|
|
|
|
2016-03-09 00:05:46 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
rm -fR $out
|
|
|
|
'';
|
|
|
|
|
2016-08-17 12:43:57 +01:00
|
|
|
postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
|
|
|
|
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;
|
2018-07-22 20:50:19 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ];
|
2016-03-09 00:05:46 +00:00
|
|
|
platforms = stdenv.lib.platforms.all;
|
|
|
|
};
|
|
|
|
}
|