biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / coq-modules / compcert / default.nix
blob769017d4e28225e6559b494d01a13b4a235a96f9
1 { lib, fetchzip, mkCoqDerivation
2 , coq, flocq, compcert
3 , ocamlPackages, fetchpatch, makeWrapper, coq2html
4 , stdenv, tools ? stdenv.cc
5 , version ? null
6 }:
8 let
10 # https://compcert.org/man/manual002.html
11 targets = {
12   x86_64-linux = "x86_64-linux";
13   aarch64-linux = "aarch64-linux";
14   x86_64-darwin = "x86_64-macos";
15   aarch64-darwin = "aarch64-macos";
16   riscv32-linux = "rv32-linux";
17   riscv64-linux = "rv64-linux";
20 target = targets.${stdenv.hostPlatform.system}
21   or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
23 compcert = mkCoqDerivation {
25   pname = "compcert";
26   owner = "AbsInt";
28   inherit version;
29   releaseRev = v: "v${v}";
31   defaultVersion =  with lib.versions; lib.switch coq.version [
32       { case = range "8.14" "8.19"; out = "3.13.1"; }
33       { case = isEq "8.13"        ; out = "3.10"; }
34       { case = isEq "8.12"       ; out = "3.9"; }
35       { case = range "8.8" "8.11"; out = "3.8"; }
36     ] null;
38   release = {
39     "3.8".sha256 = "1gzlyxvw64ca12qql3wnq3bidcx9ygsklv9grjma3ib4hvg7vnr7";
40     "3.9".sha256 = "1srcz2dqrvmbvv5cl66r34zqkm0hsbryk7gd3i9xx4slahc9zvdb";
41     "3.10".sha256 = "sha256:19rmx8r8v46101ij5myfrz60arqjy7q3ra3fb8mxqqi3c8c4l4j6";
42     "3.11".sha256 = "sha256-ZISs/ZAJVWtxp9+Sg5qV5Rss1gI9hK769GnBfawLa6A=";
43     "3.12".sha256 = "sha256-hXkQ8UnAx3k50OJGBmSm4hgrnRFCosu4+PEMrcKfmV0=";
44     "3.13".sha256 = "sha256-ZedxgEPr1ZgKIcyhQ6zD1l2xr6RDNNUYq/4ZyR6ojM4=";
45     "3.13.1".sha256 = "sha256-ldXbuzVB0Z+UVTd5S4yGSg6oRYiKbXLMmUZcQsJLcns=";
46   };
48   strictDeps = true;
50   nativeBuildInputs = with ocamlPackages; [ makeWrapper ocaml findlib menhir coq coq2html ];
51   buildInputs = with ocamlPackages; [ menhirLib ];
52   propagatedBuildInputs = [ flocq ];
54   enableParallelBuilding = true;
56   postPatch = ''
57     substituteInPlace ./configure \
58       --replace \$\{toolprefix\}ar 'ar' \
59       --replace '{toolprefix}gcc' '{toolprefix}cc'
60   '';
62   configurePhase = ''
63     ./configure -clightgen \
64     -prefix $out \
65     -coqdevdir $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ \
66     -toolprefix ${tools}/bin/ \
67     -use-external-Flocq \
68     ${target}
69   '';
71   installTargets = "documentation install";
72   installFlags = []; # trust ./configure
73   preInstall = ''
74     mkdir -p $out/share/man
75     mkdir -p $man/share
76   '';
77   postInstall = ''
78     # move man into place
79     mv $out/share/man/ $man/share/
81     # move docs into place
82     mkdir -p $doc/share/doc/compcert
83     mv doc/html $doc/share/doc/compcert/
85     # wrap ccomp to undefine _FORTIFY_SOURCE; ccomp invokes cc1 which sets
86     # _FORTIFY_SOURCE=2 by default, but undefines __GNUC__ (as it should),
87     # which causes a warning in libc. this suppresses it.
88     for x in ccomp clightgen; do
89       wrapProgram $out/bin/$x --add-flags "-U_FORTIFY_SOURCE"
90     done
91   '';
93   outputs = [ "out" "lib" "doc" "man" ];
95   meta = with lib; {
96     description = "Formally verified C compiler";
97     homepage    = "https://compcert.org";
98     license     = licenses.inria-compcert;
99     platforms   = builtins.attrNames targets;
100     maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ];
101   };
102 }; in
103 compcert.overrideAttrs (o:
104   {
105     patches = with lib.versions; lib.switch [ coq.version o.version ] [
106       { cases = [ (range "8.12.2" "8.13.2") "3.8" ];
107         out = [
108           # Support for Coq 8.12.2
109           (fetchpatch {
110             url = "https://github.com/AbsInt/CompCert/commit/06956421b4307054af221c118c5f59593c0e67b9.patch";
111             sha256 = "1f90q6j3xfvnf3z830bkd4d8526issvmdlrjlc95bfsqs78i1yrl";
112           })
113           # Support for Coq 8.13.0
114           (fetchpatch {
115             url = "https://github.com/AbsInt/CompCert/commit/0895388e7ebf9c9f3176d225107e21968919fb97.patch";
116             sha256 = "0qhkzgb2xl5kxys81pldp3mr39gd30lvr2l2wmplij319vp3xavd";
117           })
118           # Support for Coq 8.13.1
119           (fetchpatch {
120             url = "https://github.com/AbsInt/CompCert/commit/6bf310dd678285dc193798e89fc2c441d8430892.patch";
121             sha256 = "026ahhvpj5pksy90f8pnxgmhgwfqk4kwyvcf8x3dsanvz98d4pj5";
122           })
123           # Drop support for Coq < 8.9
124           (fetchpatch {
125             url = "https://github.com/AbsInt/CompCert/commit/7563a5df926a4c6fb1489a7a4c847641c8a35095.patch";
126             sha256 = "05vkslzy399r3dm6dmjs722rrajnyfa30xsyy3djl52isvn4gyfb";
127           })
128           # Support for Coq 8.13.2
129           (fetchpatch {
130             url = "https://github.com/AbsInt/CompCert/commit/48bc183167c4ce01a5c9ea86e49d60530adf7290.patch";
131             sha256 = "0j62lppfk26d1brdp3qwll2wi4gvpx1k70qivpvby5f7dpkrkax1";
132           })
133         ];
134       }
135       { cases = [ (range "8.14" "8.15") "3.10" ];
136         out = [
137           # Support for Coq 8.14.1
138           (fetchpatch {
139             url = "https://github.com/AbsInt/CompCert/commit/a79f0f99831aa0b0742bf7cce459cc9353bd7cd0.patch";
140             sha256 = "sha256:0g20x8gfzvplpad9y9vr1p33k6qv6rsp691x6687v9ffvz7zsz94";
141           })
142           # Support for Coq 8.15.0
143           (fetchpatch {
144             url = "https://github.com/AbsInt/CompCert/commit/a882f78c069f7337dd9f4abff117d4df98ef38a6.patch";
145             sha256 = "sha256:16i87s608fj9ni7cvd5wrd7gicqniad7w78wi26pxdy0pacl7bjg";
146           })
147           # Support for Coq 8.15.1
148           (fetchpatch {
149             url = "https://github.com/AbsInt/CompCert/commit/10a976994d7fd30d143354c289ae735d210ccc09.patch";
150             sha256 = "sha256:0bg58gpkgxlmxzp6sg0dvybrfk0pxnm7qd6vxlrbsbm2w6wk03jv";
151           })
152           # Support for Coq 8.15.2
153           (fetchpatch {
154             url = "https://github.com/AbsInt/CompCert/commit/283a5be7296c4c0a94d863b427c77007ab875733.patch";
155             sha256 = "sha256:1s7hvb5ii3p8kkcjlzwldvk8xc3iiibxi9935qjbrh25xi6qs66k";
156           })
157         ];
158       }
159       { cases = [ (isEq "8.16") (range "3.11" "3.12") ];
160         out = [
161           # Support for Coq 8.16.0
162           (fetchpatch {
163             url = "https://github.com/AbsInt/CompCert/commit/34be08a23d18d56f2dde24fd24b6dbe3bcb01ec3.patch";
164             sha256 = "sha256-a5YnftGVadVypEqrOYRRxI7YtGOEWyKnO4GqakFhvzI=";
165           })
166           # Support for Coq 8.16.1
167           (fetchpatch {
168             url = "https://github.com/AbsInt/CompCert/commit/35531503b3493cb9b0ec8a8585e84928c85b4af9.patch";
169             hash = "sha256-DvtYi/eiPUe8tA0EFTcCjJA0JjtVKceUsX4ZDM0pWkE=";
170           })
171         ];
172       }
173       { cases = [ (range "8.17" "8.19") (isEq "3.13") ];
174         out = [
175           # Support for Coq 8.17.0 & Coq 8.17.1
176           (fetchpatch {
177             url = "https://github.com/AbsInt/CompCert/commit/2e04d986bdae578186e40330842878559a550402.patch";
178             hash = "sha256-2ZRAjUUSScJI8ogWFTnukCUnJdLWGvyOPyfIVlHL4ig=";
179           })
180           # Support for Coq 8.18.0
181           (fetchpatch {
182             url = "https://github.com/AbsInt/CompCert/commit/28218c5663cba36c6078ca342335d4e55c412bd7.patch";
183             hash = "sha256-aAatUMO26oZwFYGh1BXYWxbTuyOgU8BAKMGDS5796hM=";
184           })
185           # MenhirLib update
186           (fetchpatch {
187             url = "https://github.com/AbsInt/CompCert/commit/9f3d7b6eb99377ad4689cd57563c484c57baa457.patch";
188             hash = "sha256-paofdSBxP/JFoBSiO1OI+mjKRI3UCanXRh/drzYt93E=";
189           })
190           # Support for Coq 8.19.0 & Coq 8.19.1
191           (fetchpatch {
192             url = "https://github.com/AbsInt/CompCert/commit/a2e4ed62fc558d565366845f9d135bd7db5e23c4.patch";
193             hash = "sha256-ufk0bokuayLfkSvK3cK4E9iXU5eZpp9d/ETSa/zCfMg=";
194           })
195         ];
196       }
197     ] [];
198   }