2019-06-16 19:59:06 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub, makeWrapper
|
2018-09-17 17:50:38 +00:00
|
|
|
, coq, ocamlPackages, coq2html
|
2015-07-15 17:14:18 +00:00
|
|
|
, tools ? stdenv.cc
|
|
|
|
}:
|
2014-05-02 00:09:37 +00:00
|
|
|
|
2017-02-20 20:09:53 +00:00
|
|
|
assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
|
2019-10-12 16:50:25 +00:00
|
|
|
assert lib.versionAtLeast coq.coq-version "8.8.0";
|
2016-09-19 17:00:42 +00: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 00:09:37 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "compcert";
|
2019-10-12 16:50:25 +00:00
|
|
|
version = "3.6";
|
2014-05-02 00:09:37 +00:00
|
|
|
|
2019-03-18 08:47:58 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "AbsInt";
|
|
|
|
repo = "CompCert";
|
|
|
|
rev = "v${version}";
|
2019-10-12 16:50:25 +00:00
|
|
|
sha256 = "1k9xhj7fgllhf7bn7rp3w6zfvs4clglnc4w39zp4678hrwvdcpha";
|
2014-05-02 00:09:37 +00:00
|
|
|
};
|
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = ocaml-pkgs ++ [ coq coq2html ];
|
2014-05-02 00:09:37 +00:00
|
|
|
enableParallelBuilding = true;
|
2014-12-17 18:11:30 +00:00
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
patchPhase = ''
|
|
|
|
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 \
|
|
|
|
-toolprefix ${tools}/bin/ \
|
|
|
|
${ccomp-platform}
|
|
|
|
'';
|
2014-05-02 00:09:37 +00:00
|
|
|
|
2015-07-15 17:14:18 +00: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/
|
|
|
|
|
|
|
|
# install compcert lib files; remove copy from $out, too
|
2015-07-15 17:14:18 +00:00
|
|
|
mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
|
2017-07-17 15:20:47 +00:00
|
|
|
mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
|
2015-07-15 17:14:18 +00:00
|
|
|
$lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
|
2019-01-13 00:37:30 +00:00
|
|
|
rm -rf $out/lib/compcert/coq
|
|
|
|
|
|
|
|
# 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 17:14:18 +00:00
|
|
|
'';
|
|
|
|
|
2019-01-13 00:37:30 +00:00
|
|
|
outputs = [ "out" "lib" "doc" "man" ];
|
2015-07-15 17:14:18 +00:00
|
|
|
|
2014-10-05 22:07:34 +00:00
|
|
|
meta = with stdenv.lib; {
|
2014-05-02 00:09:37 +00:00
|
|
|
description = "Formally verified C compiler";
|
|
|
|
homepage = "http://compcert.inria.fr";
|
2017-09-21 13:24:17 +00:00
|
|
|
license = licenses.inria-compcert;
|
2019-01-13 00:37:30 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
2014-10-05 22:07:34 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
|
2014-05-02 00:09:37 +00:00
|
|
|
};
|
|
|
|
}
|