Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbmc: 6.4.0 -> 6.4.1, fix darwin, drop unnecessary cadical dependency #372193

Merged
merged 6 commits into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions pkgs/by-name/cb/cbmc/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
lib,
stdenv,
fetchFromGitHub,
testers,
bison,
cadical,
cbmc,
cmake,
flex,
makeWrapper,
perl,
substituteAll,
cudd,
fetchurl,
nix-update-script,
fetchpatch,
versionCheckHook,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "cbmc";
version = "6.4.0";
version = "6.4.1";

src = fetchFromGitHub {
owner = "diffblue";
repo = "cbmc";
tag = "cbmc-${finalAttrs.version}";
hash = "sha256-PZZnseOE3nodE0zwyG+82gm55BO4rsCcP4T+fZq7L6I=";
hash = "sha256-O8aZTW+Eylshl9bmm9GzbljWB0+cj2liZHs2uScERkM=";
};

srcglucose = fetchFromGitHub {
Expand All @@ -47,16 +46,18 @@ stdenv.mkDerivation (finalAttrs: {
makeWrapper
];

buildInputs = [ cadical ];

# do not download sources
# link existing cadical instead
patches = [
(substituteAll {
src = ./0001-Do-not-download-sources-in-cmake.patch;
inherit cudd;
})
./0002-Do-not-download-sources-in-cmake.patch
# Fixes build with libc++ >= 19 due to the removal of std::char_traits<unsigned>.
# Remove for versions > 6.4.1.
(fetchpatch {
url = "https://github.com/diffblue/cbmc/commit/684bf4221c8737952e6469304f5a360dc3d5439d.patch";
hash = "sha256-3hHu6FcyHjfeFjNxhyhxxk7I/SK98BXT+xy7NgtEt50=";
})
];

postPatch =
Expand Down Expand Up @@ -91,30 +92,36 @@ stdenv.mkDerivation (finalAttrs: {
'';

env.NIX_CFLAGS_COMPILE = toString (
lib.optionals stdenv.cc.isGNU [
# Needed with GCC 12 but breaks on darwin (with clang)
"-Wno-error=maybe-uninitialized"
]
++ lib.optionals stdenv.cc.isClang [
lib.optionals stdenv.cc.isClang [
# fix "argument unused during compilation"
"-Wno-unused-command-line-argument"
# fix "variable 'plus_overflow' set but not used"
"-Wno-error=unused-but-set-variable"
# fix "passing no argument for the '...' parameter of a variadic macro is a C++20 extension"
"-Wno-error=c++20-extensions"
]
);

# 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";
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
versionCheckProgram = "${placeholder "out"}/bin/cbmc";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using pname is already the default. I think that you can drop this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in general it's discouraged to rely on pname (e.g. in src #277994). I think it applies in this case as well. More fitting would be meta.mainProgram, but cbmc doesn't have a primary binary. Being a bit more explicit in this case doesn't hurt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right about not relying generally on pname, but here it's not really the same.
The hook rightfully defaults to calling the binary of the same name as the package.
versionCheckProgram is only expected to be provided when the binary has a different name than pname.

versionCheckProgramArg = "--version";

passthru.updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"cbmc-(.*)"
];
};

passthru.updateScript = nix-update-script { };

meta = {
description = "CBMC is a Bounded Model Checker for C and C++ programs";
homepage = "http://www.cprover.org/cbmc/";
Expand Down