summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/default.nix
blob: 4229e43949a3b1c67396bda5cfd0866674a82706 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ stdenv, fetchurl, gcc, flex, perl, libtool, groff
, buildClang ? false }:

stdenv.mkDerivation ({
  name = "llvm-2.8";
  
  src = fetchurl {
    url    = http://llvm.org/releases/2.8/llvm-2.8.tgz;
    sha256 = "0fyl2gk2ld28isz9bq4f6r4dhqm9vljfj3pdfwlc2v0w5xsdpb95";
  };

  buildInputs = [ gcc flex perl groff ];

  configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ];

  meta = {
    homepage = http://llvm.org/;
    description = "Collection of modular and reusable compiler and toolchain technologies";
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; all;
  };
}
// stdenv.lib.optionalAttrs buildClang (
  # I write the assert because 'gcc.libc' will be evaluated although 'triplet' would not
  # evaluate properly (in the preConfigure below)
  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";
  in {
    name = "clang-2.8";

    srcClang = fetchurl {
      url = http://llvm.org/releases/2.8/clang-2.8.tgz;
      sha256 = "1hg0vqmyr4wdy686l2bga0rpin41v0q9ds2k5659m8z6acali0zd";
    };

    prePatch = ''
      pushd tools
      unpackFile $srcClang
      mv clang-2.8 clang
      popd
      find
    '';

    patches = [ ./clang-include-paths.patch ];

    # Set up the header file paths
    preConfigure = ''
      sed -i -e 's,C_INCLUDE_PATH,"${gcc.libc}/include/",' \
        -e 's,CPP_HOST,"${triplet}",' \
        -e 's,CPP_INCLUDE_PATH,"${gcc.gcc}/include/c++/${gcc.gcc.version}",' \
        tools/clang/lib/Frontend/InitHeaderSearch.cpp
    '';

    meta = {
      homepage = http://clang.llvm.org/;
      description = "A C language family frontend for LLVM";
      license = "BSD";
      maintainers = with stdenv.lib.maintainers; [viric];
      platforms = with stdenv.lib.platforms; linux;
    };
  }
))