blob: b1372d0b82c70ce57e01fd2b52aeef6298adcc22 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# Nix shell entry point
#
# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong
# SPDX-License-Identifier: AGPL-3.0-or-later
with import <nixpkgs> { };
let
bcExtractHook = writeTextFile {
name = "bc-extract-hook";
text = ''
#!${runtimeShell}
extractBitcodes() {
mkdir -p $out/share/klee
for i in $out/bin/*
do
${wllvm}/bin/extract-bc -o $out/share/klee/$(basename $i).bc $i
done
}
preDistPhases+=(extractBitcodes)
'';
executable = true;
destination = "/nix-support/setup-hook";
};
binRenameHook = version: writeTextFile {
name = "bin-rename-hook";
text = ''
#!${runtimeShell}
renameBinaries() {
for i in $out/bin/*
do mv $i{,.${version}}
done
}
preDistPhases+=(renameBinaries)
'';
executable = true;
destination = "/nix-support/setup-hook";
};
cppcheck = version: commit: hash: callPackage ./cppcheck {
stdenv = wllvmStdenv;
inherit version;
inherit commit;
inherit hash;
inherit bcExtractHook;
binRenameHook = binRenameHook version;
};
grep-2_6 = fetchurl {
url = "mirror://gnu/grep/grep-2.6.tar.xz";
hash = "sha256-YsNien9DBt1gBAED27fZ8SIOSlTFV9ndDEwy9t1itRE=";
};
grep-2_12 = fetchurl {
url = "mirror://gnu/grep/grep-2.12.tar.xz";
hash = "sha256-Tc4KT7g93QEg31HgC1L6dg8u2GddTUwLCuZCumkurWQ=";
};
grep = version: base: commit: hash: callPackage ./grep {
stdenv = wllvmStdenv;
inherit version;
inherit base;
snapshot = fetchurl {
url = "http://git.savannah.gnu.org/cgit/grep.git/snapshot/grep-${commit}.tar.gz";
inherit hash;
};
inherit bcExtractHook;
binRenameHook = binRenameHook version;
};
md4c = version: commit: hash: callPackage ./md4c {
stdenv = wllvmStdenv;
inherit version;
inherit commit;
inherit hash;
inherit bcExtractHook;
binRenameHook = binRenameHook version;
};
wllvmStdenv = let
inherit (llvmPackages_12) clang libllvm stdenv;
cflags = lib.concatStringsSep " " [
# Recommended by https://github.com/klee/klee/issues/902
"-g" "-O1" "-Xclang" "-disable-llvm-passes"
# Prevent clang from emitting safe version of certain library functions
# KLEE has yet to model
"-D__NO_STRING_INLINES" "-D_FORTIFY_SOURCE=0" "-U__OPTIMIZE__"
];
wllvmEnv = writeText "wllvm.env" ''
CC=wllvm
CXX=wllvm++
export CFLAGS="${cflags}"
export CXXFLAGS="${cflags}"
export LLVM_COMPILER=clang
export PATH=${lib.makeBinPath [ clang libllvm wllvm ]}:$PATH
'';
in overrideCC stdenv (wrapCCWith {
cc = wllvm;
extraBuildCommands = ''
cat ${wllvmEnv} >> $out/nix-support/setup-hook
'';
});
in mkShell {
packages = [
(cppcheck "9261.buggy"
"4943771e41f76edc64b273c6b257ecc0ba778a20"
"sha256-mcE9Nq/OfNiLgz3PuZEUplFRMc7E2D7ALuFdNFT6iQI=")
(cppcheck "9261.fixed"
"00fae7fb428b0b055135d6b972a1b52dd2c08d03"
"sha256-jJY06u07fzd9AOd1pr7xM7Qdm6oDW1ehGEqKlxxHT6s=")
(grep "8f08d8e2.parent" grep-2_6
"c1cb19fe67f4c83f9232087ae03c178905d62b0d"
"sha256-tT3H9pehJ8X6XPf6qyhUvjKspQZXvCd2I4uQQuabOn8=")
(grep "8f08d8e2" grep-2_6
"8f08d8e282bf3d4917e94135e67ba17d738313ce"
"sha256-xQO/d/nTk/q/7Sq6m+exZX7jwYzqbhcKirw9tqC7+zI=")
(grep "55cf7b6a.parent" grep-2_12
"a2e0193455e620f6bad1005500da418d9eba2ae6"
"sha256-Q1Xye4qHdWOlZSJ+S+T9Cy/71OLN+WE97Va84BFoV/Q=")
(grep "55cf7b6a" grep-2_12
"55cf7b6a1905320c36702a476b09ebb29a2934d3"
"sha256-uUHEG4bDDNFiVgj/1mIkttp1B7tlZ1HOWJGPEfbCErU=")
(md4c "107.buggy"
"e278609ee06ad7f9efcb06da48188a4b837ed11b"
"sha256-UoqBSOnlfDsTHz/uLGIUEgmTSiU408iUcwAJTLdbEPM=")
(md4c "107.fixed"
"5d7c35973e5d06b46ca21b5b6e292c56dba7ca23"
"sha256-N/vIRhXuU948z0O4NXKMSKOZGAEE6UjGDT5oqrGpUy8=")
klee
];
}
|