2015-05-30 14:41:34 +01:00
|
|
|
{ stdenv, fetch, cmake, libxml2, libedit, llvm, zlib, version, clang-tools-extra_src }:
|
2014-01-21 01:19:53 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "clang-${version}";
|
|
|
|
|
|
|
|
unpackPhase = ''
|
2014-06-19 23:22:38 +01:00
|
|
|
unpackFile ${fetch "cfe" "045wjnp5j8xd2zjhvldcllnwlnrwz3dafmlk412z804d5xvzb9jv"}
|
2014-05-10 16:29:41 +01:00
|
|
|
mv cfe-${version}.src clang
|
2014-01-21 01:19:53 +00:00
|
|
|
sourceRoot=$PWD/clang
|
2014-05-10 16:29:41 +01:00
|
|
|
unpackFile ${clang-tools-extra_src}
|
|
|
|
mv clang-tools-extra-* $sourceRoot/tools/extra
|
2014-01-21 01:19:53 +00:00
|
|
|
# !!! Hopefully won't be needed for 3.5
|
|
|
|
unpackFile ${llvm.src}
|
2014-05-10 16:29:41 +01:00
|
|
|
export cmakeFlags="$cmakeFlags -DCLANG_PATH_TO_LLVM_SOURCE="`ls -d $PWD/llvm-*`
|
|
|
|
(cd llvm-* && patch -Np1 -i ${./llvm-separate-build.patch})
|
2014-01-21 01:19:53 +00:00
|
|
|
'';
|
|
|
|
|
2014-01-27 17:50:21 +00:00
|
|
|
patches = [ ./clang-separate-build.patch ./clang-purity.patch ];
|
2014-01-21 01:19:53 +00:00
|
|
|
|
2015-05-30 14:41:34 +01:00
|
|
|
buildInputs = [ cmake libedit libxml2 zlib ];
|
2014-01-21 01:19:53 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCMAKE_CXX_FLAGS=-std=c++11"
|
|
|
|
"-DCLANG_PATH_TO_LLVM_BUILD=${llvm}"
|
2014-01-21 01:33:02 +00:00
|
|
|
] ++
|
2014-12-17 18:11:30 +00:00
|
|
|
(stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include") ++
|
2015-01-15 04:25:26 +00:00
|
|
|
(stdenv.lib.optional (stdenv.cc.cc != null) "-DGCC_INSTALL_PREFIX=${stdenv.cc.cc}");
|
2014-01-21 01:19:53 +00:00
|
|
|
|
2014-02-03 01:39:16 +00:00
|
|
|
# Clang expects to find LLVMgold in its own prefix
|
2014-03-26 13:06:22 +00:00
|
|
|
# Clang expects to find sanitizer libraries in its own prefix
|
|
|
|
postInstall = ''
|
|
|
|
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
|
2014-05-10 16:29:41 +01:00
|
|
|
ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/
|
2014-03-26 13:06:22 +00:00
|
|
|
'';
|
2014-02-03 01:39:16 +00:00
|
|
|
|
2015-03-25 03:37:01 +00:00
|
|
|
passthru = {
|
|
|
|
isClang = true;
|
|
|
|
cc = stdenv.cc.cc;
|
|
|
|
# GCC_INSTALL_PREFIX points here, so just use it even though it may not
|
|
|
|
# actually be a gcc
|
|
|
|
gcc = stdenv.cc.cc;
|
|
|
|
};
|
2014-01-21 01:19:53 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
|
|
|
|
homepage = http://llvm.org/;
|
|
|
|
license = stdenv.lib.licenses.bsd3;
|
|
|
|
platforms = stdenv.lib.platforms.all;
|
|
|
|
};
|
|
|
|
}
|