2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, makeWrapper
|
2020-12-09 12:39:15 +00:00
|
|
|
, coqPackages, ocamlPackages, coq2html
|
2020-04-24 23:36:52 +00:00
|
|
|
, tools ? stdenv.cc
|
2020-12-09 12:39:15 +00:00
|
|
|
, version ? "3.8"
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir ];
|
|
|
|
ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux";
|
2020-12-09 12:39:15 +00:00
|
|
|
inherit (coqPackages) coq flocq;
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) optional optionalString;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
2020-12-09 12:39:15 +00:00
|
|
|
|
|
|
|
let param = {
|
|
|
|
"3.7" = {
|
|
|
|
sha256 = "1h4zhk9rrqki193nxs9vjvya7nl9yxjcf07hfqb6g77riy1vd2jr";
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/AbsInt/CompCert/commit/0a2db0269809539ccc66f8ec73637c37fbd23580.patch";
|
|
|
|
sha256 = "0n8qrba70x8f422jdvq9ddgsx6avf2dkg892g4ldh3jiiidyhspy";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/AbsInt/CompCert/commit/5e29f8b5ba9582ecf2a1d0baeaef195873640607.patch";
|
|
|
|
sha256 = "184nfdgxrkci880lkaj5pgnify3plka7xfgqrgv16275sqppc5hc";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
"3.8" = {
|
|
|
|
sha256 = "1gzlyxvw64ca12qql3wnq3bidcx9ygsklv9grjma3ib4hvg7vnr7";
|
|
|
|
useExternalFlocq = true;
|
|
|
|
};
|
|
|
|
}."${version}"; in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "compcert";
|
2020-12-09 12:39:15 +00:00
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "AbsInt";
|
|
|
|
repo = "CompCert";
|
|
|
|
rev = "v${version}";
|
2020-12-09 12:39:15 +00:00
|
|
|
inherit (param) sha256;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
patches = param.patches or [];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = ocaml-pkgs ++ [ coq coq2html ];
|
2020-12-09 12:39:15 +00:00
|
|
|
propagatedBuildInputs = optional (param.useExternalFlocq or false) flocq;
|
2020-04-24 23:36:52 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-10-07 09:15:18 +00:00
|
|
|
postPatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace ./configure \
|
|
|
|
--replace '{toolprefix}gcc' '{toolprefix}cc'
|
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
./configure -clightgen \
|
|
|
|
-prefix $out \
|
2020-10-07 09:15:18 +00:00
|
|
|
-coqdevdir $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ \
|
2020-04-24 23:36:52 +00:00
|
|
|
-toolprefix ${tools}/bin/ \
|
2020-12-09 12:39:15 +00:00
|
|
|
${optionalString (param.useExternalFlocq or false) "-use-external-Flocq"} \
|
2020-04-24 23:36:52 +00:00
|
|
|
${ccomp-platform}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installTargets = "documentation install";
|
|
|
|
postInstall = ''
|
|
|
|
# move man into place
|
|
|
|
mkdir -p $man/share
|
|
|
|
mv $out/share/man/ $man/share/
|
|
|
|
|
|
|
|
# move docs into place
|
|
|
|
mkdir -p $doc/share/doc/compcert
|
|
|
|
mv doc/html $doc/share/doc/compcert/
|
|
|
|
|
|
|
|
# wrap ccomp to undefine _FORTIFY_SOURCE; ccomp invokes cc1 which sets
|
|
|
|
# _FORTIFY_SOURCE=2 by default, but undefines __GNUC__ (as it should),
|
|
|
|
# which causes a warning in libc. this suppresses it.
|
|
|
|
for x in ccomp clightgen; do
|
|
|
|
wrapProgram $out/bin/$x --add-flags "-U_FORTIFY_SOURCE"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "lib" "doc" "man" ];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Formally verified C compiler";
|
2020-12-09 12:39:15 +00:00
|
|
|
homepage = "https://compcert.org";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.inria-compcert;
|
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
|
|
|
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
|
|
|
|
};
|
|
|
|
}
|