summary refs log tree commit diff
path: root/pkgs/development/compilers/souper/default.nix
blob: 2203dc980b132daaf238695494674191ca81db17 (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
{ stdenv, fetchFromGitHub, cmake, makeWrapper
, llvmPackages_4, hiredis, z3, gtest
}:

let
  klee = fetchFromGitHub {
    owner = "rsas";
    repo  = "klee";
    rev   = "57cd3d43056b029d9da3c6b3c666c4153554c04f";
    sha256 = "197wb7nbirlfpx2jr3afpjjhcj7slc4dxxi02j3kmazz9kcqaygz";
  };
in stdenv.mkDerivation rec {
  name = "souper-unstable-${version}";
  version = "2017-03-23";

  src = fetchFromGitHub {
    owner  = "google";
    repo   = "souper";
    rev    = "cf2911d2eb1e7c8ab465df5a722fa5cdac06e6fc";
    sha256 = "1kg08a1af4di729pn1pip2lzqzlvjign6av95214f5rr3cq2q0cl";
  };

  nativeBuildInputs = [
    cmake
    makeWrapper
  ];

  buildInputs = [
    llvmPackages_4.llvm
    llvmPackages_4.clang-unwrapped
    hiredis
    gtest
  ];

  patches = [ ./cmake-fix.patch ];

  enableParallelBuilding = true;

  preConfigure = ''
      mkdir -pv third_party
      cp -R "${klee}" third_party/klee
  '';

  installPhase = ''
      mkdir -pv $out/bin
      cp -v ./souper       $out/bin/
      cp -v ./clang-souper $out/bin/
      wrapProgram "$out/bin/souper" \
          --add-flags "-z3-path=\"${z3}/bin/z3\""
  '';

  meta = with stdenv.lib; {
    description = "A superoptimizer for LLVM IR";
    homepage    = "https://github.com/google/souper";
    license     = licenses.asl20;
    maintainers = with maintainers; [ taktoa ];
    platforms   = with platforms; linux;
  };
}