2020-09-28 22:04:26 +01:00
|
|
|
{ stdenv, lib, fetchFromGitHub, fetchpatch, makeWrapper
|
2018-09-17 18:50:38 +01:00
|
|
|
, coq, ocamlPackages, coq2html
|
2015-07-15 18:14:18 +01:00
|
|
|
, tools ? stdenv.cc
|
|
|
|
}:
|
2014-05-02 01:09:37 +01:00
|
|
|
|
2017-02-20 20:09:53 +00:00
|
|
|
assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
|
2019-10-12 17:50:25 +01:00
|
|
|
assert lib.versionAtLeast coq.coq-version "8.8.0";
|
2016-09-19 18:00:42 +01:00
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
let
|
|
|
|
ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir ];
|
|
|
|
ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux";
|
|
|
|
in
|
2014-05-02 01:09:37 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "compcert";
|
2020-04-01 11:06:48 +01:00
|
|
|
version = "3.7";
|
2014-05-02 01:09:37 +01:00
|
|
|
|
2019-03-18 08:47:58 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "AbsInt";
|
|
|
|
repo = "CompCert";
|
|
|
|
rev = "v${version}";
|
2020-04-01 11:06:48 +01:00
|
|
|
sha256 = "1h4zhk9rrqki193nxs9vjvya7nl9yxjcf07hfqb6g77riy1vd2jr";
|
2014-05-02 01:09:37 +01:00
|
|
|
};
|
|
|
|
|
2020-09-28 22:04:26 +01:00
|
|
|
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";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = ocaml-pkgs ++ [ coq coq2html ];
|
2014-05-02 01:09:37 +01:00
|
|
|
enableParallelBuilding = true;
|
2014-12-17 18:11:30 +00:00
|
|
|
|
2020-09-28 22:04:26 +01:00
|
|
|
postPatch = ''
|
2019-01-13 00:37:30 +00:00
|
|
|
substituteInPlace ./configure \
|
|
|
|
--replace '{toolprefix}gcc' '{toolprefix}cc'
|
|
|
|
'';
|
|
|
|
|
2014-12-17 18:11:30 +00:00
|
|
|
configurePhase = ''
|
2019-01-13 00:37:30 +00:00
|
|
|
./configure -clightgen \
|
|
|
|
-prefix $out \
|
2020-09-28 22:04:26 +01:00
|
|
|
-coqdevdir $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ \
|
2019-01-13 00:37:30 +00:00
|
|
|
-toolprefix ${tools}/bin/ \
|
|
|
|
${ccomp-platform}
|
|
|
|
'';
|
2014-05-02 01:09:37 +01:00
|
|
|
|
2015-07-15 18:14:18 +01:00
|
|
|
installTargets = "documentation install";
|
|
|
|
postInstall = ''
|
2019-01-13 00:37:30 +00:00
|
|
|
# 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
|
2015-07-15 18:14:18 +01:00
|
|
|
'';
|
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
outputs = [ "out" "lib" "doc" "man" ];
|
2015-07-15 18:14:18 +01:00
|
|
|
|
2014-10-05 23:07:34 +01:00
|
|
|
meta = with stdenv.lib; {
|
2014-05-02 01:09:37 +01:00
|
|
|
description = "Formally verified C compiler";
|
|
|
|
homepage = "http://compcert.inria.fr";
|
2017-09-21 14:24:17 +01:00
|
|
|
license = licenses.inria-compcert;
|
2019-01-13 00:37:30 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
2014-10-05 23:07:34 +01:00
|
|
|
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
|
2014-05-02 01:09:37 +01:00
|
|
|
};
|
|
|
|
}
|