1{
2 callPackage,
3 fetchgit,
4 lib,
5 stdenv,
6 gtk3,
7 pkg-config,
8 libxml2,
9 llvm,
10 perl,
11 sqlite,
12}:
13
14let
15 GCC_BASE = "${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.uname.processor}-unknown-linux-gnu/${stdenv.cc.cc.version}";
16in
17stdenv.mkDerivation rec {
18 pname = "sparse";
19 version = "0.6.4-unstable-2024-02-03";
20
21 src = fetchgit {
22 url = "https://git.kernel.org/pub/scm/devel/sparse/sparse.git";
23 rev = "0196afe16a50c76302921b139d412e82e5be2349";
24 hash = "sha256-Fft3hm988Xw92WIwXEoVoX7xzzkDhKy+bn9YuQIOhSk=";
25 };
26
27 preConfigure = ''
28 sed -i 's|"/usr/include"|"${stdenv.cc.libc.dev}/include"|' pre-process.c
29 sed -i 's|qx(\$ccom -print-file-name=)|"${GCC_BASE}"|' cgcc
30 '';
31
32 makeFlags = [
33 "PREFIX=${placeholder "out"}"
34 ];
35
36 nativeBuildInputs = [ pkg-config ];
37 buildInputs = [
38 gtk3
39 libxml2
40 llvm
41 perl
42 sqlite
43 ];
44 doCheck = true;
45 buildFlags = [ "GCC_BASE:=${GCC_BASE}" ];
46
47 # Test failures with "fortify3" on, such as:
48 # +*** buffer overflow detected ***: terminated
49 # +Aborted (core dumped)
50 # error: Actual exit value does not match the expected one.
51 # error: expected 0, got 134.
52 # error: FAIL: test 'bool-float.c' failed
53 hardeningDisable = [ "fortify3" ];
54
55 passthru.tests = {
56 simple-execution = callPackage ./tests.nix { };
57 };
58
59 meta = with lib; {
60 description = "Semantic parser for C";
61 homepage = "https://git.kernel.org/pub/scm/devel/sparse/sparse.git/";
62 license = licenses.mit;
63 platforms = platforms.linux;
64 maintainers = with maintainers; [
65 thoughtpolice
66 jkarlson
67 ];
68 };
69}