1{ stdenv, lib, fetchurl, fetchpatch
2, coq, ocamlPackages
3, tools ? stdenv.cc
4}:
5
6assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02";
7
8stdenv.mkDerivation rec {
9 name = "compcert-${version}";
10 version = "3.3";
11
12 src = fetchurl {
13 url = "http://compcert.inria.fr/release/${name}.tgz";
14 sha256 = "16xrqcwak1v1fk5ndx6jf1yvxv3adsr7p7z34gfm2mpggxnq0xwn";
15 };
16
17 buildInputs = [ coq ]
18 ++ (with ocamlPackages; [ ocaml findlib menhir ]);
19
20 enableParallelBuilding = true;
21
22 patches = [ (fetchpatch {
23 url = "https://github.com/AbsInt/CompCert/commit/679ecfeaa24c0615fa1999e9582bf2af6a9f35e7.patch";
24 sha256 = "04yrn6dp57aw6lmlr4yssjlx9cxix0mlmaw7gfhwyz5bzqc2za1a";
25 })];
26
27 configurePhase = ''
28 substituteInPlace ./configure --replace '{toolprefix}gcc' '{toolprefix}cc'
29 ./configure -clightgen -prefix $out -toolprefix ${tools}/bin/ '' +
30 (if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux");
31
32 installTargets = "documentation install";
33
34 postInstall = ''
35 mkdir -p $lib/share/doc/compcert
36 mv doc/html $lib/share/doc/compcert/
37 mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
38 mv backend cfrontend common cparser driver flocq x86 x86_64 lib \
39 $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/
40 '';
41
42 outputs = [ "out" "lib" ];
43
44 meta = with stdenv.lib; {
45 description = "Formally verified C compiler";
46 homepage = "http://compcert.inria.fr";
47 license = licenses.inria-compcert;
48 platforms = platforms.linux ++
49 platforms.darwin;
50 maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
51 };
52}