compcert: clean up expression
- Require Coq 8.6.1+ - Split substituteInPlace call into patchPhase - Constrain platforms correctly to x86_64 Linux/Darwin, which was all it supported anyway (there was no way to properly configure i686 builds, nor cross builds. In the future there might be) - Minor stylistic cleanups - Add new 'man' and 'doc' outputs (the previous attempt to move the build artifact outputs into $lib no longer worked correctly and they were installed into 'out' instead, this fixes it completely). - Clean up weird binary artifacts left in $out (that were already in $lib) - Wrap ccomp to undefine _FORTIFY_SOURCE; otherwise it causes annoying warnings on every invocation Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
@@ -1,10 +1,15 @@
|
|||||||
{ stdenv, lib, fetchurl, fetchpatch
|
{ stdenv, lib, fetchurl, fetchpatch, makeWrapper
|
||||||
, coq, ocamlPackages, coq2html
|
, coq, ocamlPackages, coq2html
|
||||||
, tools ? stdenv.cc
|
, tools ? stdenv.cc
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
|
assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
|
||||||
|
assert lib.versionAtLeast coq.coq-version "8.6.1";
|
||||||
|
|
||||||
|
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 {
|
stdenv.mkDerivation rec {
|
||||||
name = "compcert-${version}";
|
name = "compcert-${version}";
|
||||||
version = "3.4";
|
version = "3.4";
|
||||||
@@ -14,34 +19,53 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "12gchwvkzhd2bhrnwzfb4a06wc4hgv98z987k06vj7ga31ii763h";
|
sha256 = "12gchwvkzhd2bhrnwzfb4a06wc4hgv98z987k06vj7ga31ii763h";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [ coq coq2html ]
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
++ (with ocamlPackages; [ ocaml findlib menhir ]);
|
buildInputs = ocaml-pkgs ++ [ coq coq2html ];
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
patchPhase = ''
|
||||||
|
substituteInPlace ./configure \
|
||||||
|
--replace '{toolprefix}gcc' '{toolprefix}cc'
|
||||||
|
'';
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
substituteInPlace ./configure --replace '{toolprefix}gcc' '{toolprefix}cc'
|
./configure -clightgen \
|
||||||
./configure -clightgen -prefix $out -toolprefix ${tools}/bin/ '' +
|
-prefix $out \
|
||||||
(if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux");
|
-toolprefix ${tools}/bin/ \
|
||||||
|
${ccomp-platform}
|
||||||
|
'';
|
||||||
|
|
||||||
installTargets = "documentation install";
|
installTargets = "documentation install";
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mkdir -p $lib/share/doc/compcert
|
# move man into place
|
||||||
mv doc/html $lib/share/doc/compcert/
|
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/
|
mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
|
||||||
mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
|
mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
|
||||||
$lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
|
$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" ];
|
outputs = [ "out" "lib" "doc" "man" ];
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "Formally verified C compiler";
|
description = "Formally verified C compiler";
|
||||||
homepage = "http://compcert.inria.fr";
|
homepage = "http://compcert.inria.fr";
|
||||||
license = licenses.inria-compcert;
|
license = licenses.inria-compcert;
|
||||||
platforms = platforms.linux ++
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
||||||
platforms.darwin;
|
|
||||||
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
|
maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user