1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs synced 2024-10-19 03:47:13 -04:00
nixpkgs/pkgs/development/compilers/llvm/clang.nix
Shea Levy 6e3cde6383 Enable building clang separately from llvm
Note that there is some duplication when building clang now. The llvm source
is unpacked twice, ./configure is run twice, and two small unit test
libraries are compiled twice. IMO this is a fair tradeoff for having
llvm be a separate build unaffected by changes to clang

svn path=/nixpkgs/trunk/; revision=29919
2011-10-19 20:57:18 +00:00

63 lines
1.7 KiB
Nix

{ stdenv, fetchurl, perl, groff, llvm }:
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
let
triplet = if (stdenv.system == "i686-linux") then "i686-unknown-linux-gnu"
else if (stdenv.system == "x86_64-linux") then "x86_64-unknown-linux-gnu"
else throw "System not supported";
version = "2.9";
in
stdenv.mkDerivation {
name = "clang-${version}";
CC = if stdenv.gcc ? clang then "clang" else "gcc";
CXX = if stdenv.gcc ? clang then "clang++" else "g++";
src = llvm.src;
buildInputs = [ perl llvm groff ];
configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ];
srcClang = fetchurl {
url = "http://llvm.org/releases/${version}/clang-${version}.tgz";
sha256 = "1pq9g7qxw761dp6gx3amx39kl9p4zhlymmn8gfmcnw9ag0zizi3h";
};
prePatch = ''
pushd tools
unpackFile $srcClang
mv clang-${version} clang
popd
find
'';
patches = [ ./clang-include-paths.patch ./clang-ld-flags.patch ./clang-tblgen.patch ./clang-system-llvm-libs.patch ];
buildFlags = [ "TableGen=tblgen" "LLVM_CONFIG=llvm-config" ];
# Set up the header file paths
preBuild = ''
sed -i -e 's,C_INCLUDE_PATH,"${stdenv.gcc.libc}/include/",' \
-e 's,CPP_HOST,"${triplet}",' \
-e 's,CPP_INCLUDE_PATH,"${stdenv.gcc.gcc}/include/c++/${stdenv.gcc.gcc.version}",' \
tools/clang/lib/Frontend/InitHeaderSearch.cpp
pushd utils/unittest
make
popd
cd tools/clang
'';
passthru = { gcc = stdenv.gcc.gcc; };
meta = {
homepage = http://clang.llvm.org/;
description = "A C language family frontend for LLVM";
license = "BSD";
maintainers = with stdenv.lib.maintainers; [viric shlevy];
platforms = with stdenv.lib.platforms; linux;
};
}