2022-08-21 13:32:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, testers
|
|
|
|
, bison
|
|
|
|
, cadical
|
|
|
|
, cbmc
|
|
|
|
, cmake
|
|
|
|
, flex
|
|
|
|
, makeWrapper
|
|
|
|
, perl
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "cbmc";
|
2023-02-09 11:40:11 +00:00
|
|
|
version = "5.76.1";
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "diffblue";
|
|
|
|
repo = pname;
|
|
|
|
rev = "${pname}-${version}";
|
2023-02-09 11:40:11 +00:00
|
|
|
sha256 = "sha256-OVOoAfoqev33c7pIzBGK9HD+zgji/+BWKD33RYJaSDc=";
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
cmake
|
|
|
|
flex
|
|
|
|
perl
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [ cadical ];
|
|
|
|
|
|
|
|
# do not download sources
|
|
|
|
# link existing cadical instead
|
|
|
|
patches = [
|
|
|
|
./0001-Do-not-download-sources-in-cmake.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# do not hardcode gcc
|
|
|
|
substituteInPlace "scripts/bash-autocomplete/extract_switches.sh" \
|
|
|
|
--replace "gcc" "$CC" \
|
|
|
|
--replace "g++" "$CXX"
|
|
|
|
# fix library_check.sh interpreter error
|
|
|
|
patchShebangs .
|
|
|
|
'' + lib.optionalString (!stdenv.cc.isGNU) ''
|
|
|
|
# goto-gcc rely on gcc
|
|
|
|
substituteInPlace "regression/CMakeLists.txt" \
|
|
|
|
--replace "add_subdirectory(goto-gcc)" ""
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# goto-cc expects ls_parse.py in PATH
|
|
|
|
mkdir -p $out/share/cbmc
|
|
|
|
mv $out/bin/ls_parse.py $out/share/cbmc/ls_parse.py
|
|
|
|
chmod +x $out/share/cbmc/ls_parse.py
|
|
|
|
wrapProgram $out/bin/goto-cc \
|
|
|
|
--prefix PATH : "$out/share/cbmc" \
|
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [
|
2023-02-16 17:41:37 +00:00
|
|
|
# Needed with GCC 12 but breaks on darwin (with clang)
|
|
|
|
"-Wno-error=maybe-uninitialized"
|
|
|
|
] ++ lib.optionals stdenv.cc.isClang [
|
|
|
|
# fix "argument unused during compilation"
|
|
|
|
"-Wno-unused-command-line-argument"
|
2023-03-04 12:14:45 +00:00
|
|
|
]);
|
2022-08-21 13:32:41 +00:00
|
|
|
|
|
|
|
# TODO: add jbmc support
|
|
|
|
cmakeFlags = [ "-DWITH_JBMC=OFF" "-Dsat_impl=cadical" "-Dcadical_INCLUDE_DIR=${cadical.dev}/include" ];
|
|
|
|
|
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = cbmc;
|
|
|
|
command = "cbmc --version";
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "CBMC is a Bounded Model Checker for C and C++ programs";
|
|
|
|
homepage = "http://www.cprover.org/cbmc/";
|
|
|
|
license = licenses.bsdOriginal;
|
|
|
|
maintainers = with maintainers; [ jiegec ];
|
|
|
|
platforms = platforms.unix;
|
2023-01-11 07:51:40 +00:00
|
|
|
# https://github.com/diffblue/cbmc/issues/7423
|
|
|
|
broken = stdenv.isLinux && stdenv.isAarch64;
|
2022-08-21 13:32:41 +00:00
|
|
|
};
|
|
|
|
}
|