nixpkgs/pkgs/development/compilers/compcert/default.nix

75 lines
2.2 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchFromGitHub, makeWrapper
2018-09-17 18:50:38 +01:00
, coq, ocamlPackages, coq2html
, tools ? stdenv.cc
}:
2017-02-20 20:09:53 +00:00
assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
assert lib.versionAtLeast coq.coq-version "8.6.1";
2016-09-19 18:00:42 +01:00
let
ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir ];
ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux";
in
stdenv.mkDerivation rec {
name = "compcert-${version}";
2019-03-04 20:25:07 +00:00
version = "3.5";
2019-03-18 08:47:58 +00:00
src = fetchFromGitHub {
owner = "AbsInt";
repo = "CompCert";
rev = "v${version}";
sha256 = "1g8067a5x3vd0l47d04gjvy5yx49nghh55am5d1fbrjirfsnsz8j";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = ocaml-pkgs ++ [ coq coq2html ];
enableParallelBuilding = true;
patchPhase = ''
substituteInPlace ./configure \
2019-08-14 13:50:22 +01:00
--replace '|8.9.0' '|8.9.0|8.9.1' \
--replace '{toolprefix}gcc' '{toolprefix}cc'
'';
configurePhase = ''
./configure -clightgen \
-prefix $out \
-toolprefix ${tools}/bin/ \
${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/
# install compcert lib files; remove copy from $out, too
mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
$lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
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
'';
outputs = [ "out" "lib" "doc" "man" ];
2014-10-05 23:07:34 +01:00
meta = with stdenv.lib; {
description = "Formally verified C compiler";
homepage = "http://compcert.inria.fr";
license = licenses.inria-compcert;
platforms = [ "x86_64-linux" "x86_64-darwin" ];
2014-10-05 23:07:34 +01:00
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
};
}