about summary refs log tree commit diff
path: root/pkgs/development/tools/misc/creduce/default.nix
blob: 37ec63627b153bdaa74764e18fbbe1e57e475eba (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
{ stdenv, fetchurl, cmake, makeWrapper
, llvm, clang-unwrapped
, flex
, zlib
, perl, ExporterLite, FileWhich, GetoptTabular, RegexpCommon, TermReadKey
, utillinux
}:

assert stdenv.isLinux -> (utillinux != null);

stdenv.mkDerivation rec {
  name = "creduce-${version}";
  version = "2.7.0";

  src = fetchurl {
    url = "http://embed.cs.utah.edu/creduce/${name}.tar.gz";
    sha256 = "0h8s4d54q6cl6i45x3143l2xmr29b2yhr3m0n5qqx63sr5csip1n";
  };

  buildInputs = [
    # Ensure stdenv's CC is on PATH before clang-unwrapped
    stdenv.cc
    # Actual deps:
    cmake makeWrapper
    llvm clang-unwrapped
    flex zlib
    perl ExporterLite FileWhich GetoptTabular RegexpCommon TermReadKey
  ];

  # On Linux, c-reduce's preferred way to reason about
  # the cpu architecture/topology is to use 'lscpu',
  # so let's make sure it knows where to find it:
  patchPhase = stdenv.lib.optionalString stdenv.isLinux ''
    substituteInPlace creduce/creduce_utils.pm --replace \
      lscpu ${utillinux}/bin/lscpu
  '';


  enableParallelBuilding = true;

  postInstall = ''
    wrapProgram $out/bin/creduce --prefix PERL5LIB : "$PERL5LIB"
  '';

  meta = with stdenv.lib; {
    description = "A C program reducer";
    homepage = https://embed.cs.utah.edu/creduce;
    # Officially, the license is: https://github.com/csmith-project/creduce/blob/master/COPYING
    license = licenses.ncsa;
    longDescription = ''
      C-Reduce is a tool that takes a large C or C++ program that has a
      property of interest (such as triggering a compiler bug) and
      automatically produces a much smaller C/C++ program that has the same
      property.  It is intended for use by people who discover and report
      bugs in compilers and other tools that process C/C++ code.
    '';
    maintainers = [ maintainers.dtzWill ];
    platforms = platforms.all;
  };
}