1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 makeWrapper,
7 llvm,
8 libclang,
9 flex,
10 zlib,
11 perlPackages,
12 util-linux,
13}:
14
15stdenv.mkDerivation rec {
16 pname = "creduce";
17 version = "2.10.0-unstable-2024-06-01";
18
19 src = fetchFromGitHub {
20 owner = "csmith-project";
21 repo = "creduce";
22 rev = "31e855e290970cba0286e5032971509c0e7c0a80";
23 hash = "sha256-RbxFqZegsCxnUaIIA5OfTzx1wflCPeF+enQt90VwMgA=";
24 };
25
26 postPatch =
27 # On Linux, c-reduce's preferred way to reason about
28 # the cpu architecture/topology is to use 'lscpu',
29 # so let's make sure it knows where to find it:
30 lib.optionalString stdenv.hostPlatform.isLinux ''
31 substituteInPlace creduce/creduce_utils.pm --replace \
32 lscpu ${util-linux}/bin/lscpu
33 '';
34
35 nativeBuildInputs = [
36 cmake
37 makeWrapper
38 llvm.dev
39 ];
40 buildInputs = [
41 # Ensure stdenv's CC is on PATH before clang-unwrapped
42 stdenv.cc
43 # Actual deps:
44 llvm
45 libclang
46 flex
47 zlib
48 ]
49 ++ (with perlPackages; [
50 perl
51 ExporterLite
52 FileWhich
53 GetoptTabular
54 RegexpCommon
55 TermReadKey
56 ]);
57
58 postInstall = ''
59 wrapProgram $out/bin/creduce --prefix PERL5LIB : "$PERL5LIB"
60 '';
61
62 meta = with lib; {
63 description = "C program reducer";
64 mainProgram = "creduce";
65 homepage = "https://embed.cs.utah.edu/creduce";
66 # Officially, the license is: https://github.com/csmith-project/creduce/blob/master/COPYING
67 license = licenses.ncsa;
68 longDescription = ''
69 C-Reduce is a tool that takes a large C or C++ program that has a
70 property of interest (such as triggering a compiler bug) and
71 automatically produces a much smaller C/C++ program that has the same
72 property. It is intended for use by people who discover and report
73 bugs in compilers and other tools that process C/C++ code.
74 '';
75 maintainers = [ ];
76 platforms = platforms.all;
77 };
78}