diff --git a/pkgs/development/compilers/compcert/default.nix b/pkgs/development/compilers/compcert/default.nix deleted file mode 100644 index beafd6414f43..000000000000 --- a/pkgs/development/compilers/compcert/default.nix +++ /dev/null @@ -1,125 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, makeWrapper -, coqPackages, ocamlPackages, coq2html -, tools ? stdenv.cc -, version ? "3.9" -}: - -let - ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir menhirLib ]; - ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux"; - inherit (coqPackages) coq flocq; - inherit (lib) optional optionalString; -in - -let param = { - "3.7" = { - sha256 = "1h4zhk9rrqki193nxs9vjvya7nl9yxjcf07hfqb6g77riy1vd2jr"; - patches = [ - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/0a2db0269809539ccc66f8ec73637c37fbd23580.patch"; - sha256 = "0n8qrba70x8f422jdvq9ddgsx6avf2dkg892g4ldh3jiiidyhspy"; - }) - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/5e29f8b5ba9582ecf2a1d0baeaef195873640607.patch"; - sha256 = "184nfdgxrkci880lkaj5pgnify3plka7xfgqrgv16275sqppc5hc"; - }) - ]; - }; - "3.8" = { - sha256 = "1gzlyxvw64ca12qql3wnq3bidcx9ygsklv9grjma3ib4hvg7vnr7"; - patches = [ - # Support for Coq 8.12.2 - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/06956421b4307054af221c118c5f59593c0e67b9.patch"; - sha256 = "1f90q6j3xfvnf3z830bkd4d8526issvmdlrjlc95bfsqs78i1yrl"; - }) - # Support for Coq 8.13.0 - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/0895388e7ebf9c9f3176d225107e21968919fb97.patch"; - sha256 = "0qhkzgb2xl5kxys81pldp3mr39gd30lvr2l2wmplij319vp3xavd"; - }) - # Support for Coq 8.13.1 - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/6bf310dd678285dc193798e89fc2c441d8430892.patch"; - sha256 = "026ahhvpj5pksy90f8pnxgmhgwfqk4kwyvcf8x3dsanvz98d4pj5"; - }) - # Drop support for Coq < 8.9 - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/7563a5df926a4c6fb1489a7a4c847641c8a35095.patch"; - sha256 = "05vkslzy399r3dm6dmjs722rrajnyfa30xsyy3djl52isvn4gyfb"; - }) - # Support for Coq 8.13.2 - (fetchpatch { - url = "https://github.com/AbsInt/CompCert/commit/48bc183167c4ce01a5c9ea86e49d60530adf7290.patch"; - sha256 = "0j62lppfk26d1brdp3qwll2wi4gvpx1k70qivpvby5f7dpkrkax1"; - }) - ]; - useExternalFlocq = true; - }; - "3.9" = { - sha256 = "1srcz2dqrvmbvv5cl66r34zqkm0hsbryk7gd3i9xx4slahc9zvdb"; - useExternalFlocq = true; - }; -}."${version}"; in - -stdenv.mkDerivation rec { - pname = "compcert"; - inherit version; - - src = fetchFromGitHub { - owner = "AbsInt"; - repo = "CompCert"; - rev = "v${version}"; - inherit (param) sha256; - }; - - patches = param.patches or []; - - nativeBuildInputs = [ makeWrapper ]; - buildInputs = ocaml-pkgs ++ [ coq coq2html ]; - propagatedBuildInputs = optional (param.useExternalFlocq or false) flocq; - enableParallelBuilding = true; - - postPatch = '' - substituteInPlace ./configure \ - --replace \$\{toolprefix\}ar 'ar' \ - --replace '{toolprefix}gcc' '{toolprefix}cc' - ''; - - configurePhase = '' - ./configure -clightgen \ - -prefix $out \ - -coqdevdir $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ \ - -toolprefix ${tools}/bin/ \ - ${optionalString (param.useExternalFlocq or false) "-use-external-Flocq"} \ - ${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/ - - # 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" ]; - - meta = with lib; { - description = "Formally verified C compiler"; - homepage = "https://compcert.org"; - license = licenses.inria-compcert; - platforms = [ "x86_64-linux" "x86_64-darwin" ]; - maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ]; - }; -} diff --git a/pkgs/development/coq-modules/VST/default.nix b/pkgs/development/coq-modules/VST/default.nix index ad5caec94921..c3bd33ce4bfd 100644 --- a/pkgs/development/coq-modules/VST/default.nix +++ b/pkgs/development/coq-modules/VST/default.nix @@ -9,10 +9,8 @@ with lib; mkCoqDerivation { inherit version; defaultVersion = with versions; switch coq.coq-version [ { case = range "8.12" "8.13"; out = "2.7.1"; } - { case = "8.11"; out = "2.6"; } ] null; release."2.7.1".sha256 = "1674j7bkvihiv19vizm99dp6gj3lryb00zx6a87jz214f3ydcvnj"; - release."2.6".sha256 = "00bf9hl4pvmsqa08lzjs1mrxyfgfxq4k6778pnldmc8ichm90jgk"; releaseRev = v: "v${v}"; propagatedBuildInputs = [ compcert ]; diff --git a/pkgs/development/coq-modules/compcert/default.nix b/pkgs/development/coq-modules/compcert/default.nix new file mode 100644 index 000000000000..978cea5b09e4 --- /dev/null +++ b/pkgs/development/coq-modules/compcert/default.nix @@ -0,0 +1,109 @@ +{ lib, fetchzip, mkCoqDerivation, coq, flocq, compcert +, ocamlPackages, fetchpatch, makeWrapper, coq2html +, stdenv, tools ? stdenv.cc +, version ? null +}: + +with lib; + +let compcert = mkCoqDerivation rec { + + pname = "compcert"; + owner = "AbsInt"; + + inherit version; + releaseRev = v: "v${v}"; + + defaultVersion = with versions; switch coq.version [ + { case = range "8.8" "8.13"; out = "3.8"; } + ] null; + + release = { + "3.8".sha256 = "1gzlyxvw64ca12qql3wnq3bidcx9ygsklv9grjma3ib4hvg7vnr7"; + "3.9".sha256 = "1srcz2dqrvmbvv5cl66r34zqkm0hsbryk7gd3i9xx4slahc9zvdb"; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = with ocamlPackages; [ ocaml findlib menhir menhirLib ] ++ [ coq coq2html ]; + propagatedBuildInputs = [ flocq ]; + + enableParallelBuilding = true; + + postPatch = '' + substituteInPlace ./configure \ + --replace \$\{toolprefix\}ar 'ar' \ + --replace '{toolprefix}gcc' '{toolprefix}cc' + ''; + + configurePhase = '' + ./configure -clightgen \ + -prefix $out \ + -coqdevdir $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ \ + -toolprefix ${tools}/bin/ \ + -use-external-Flocq \ + ${if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux"} + ''; + + 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/ + + # 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" ]; + + meta = with lib; { + description = "Formally verified C compiler"; + homepage = "https://compcert.org"; + license = licenses.inria-compcert; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ]; + }; +}; in +compcert.overrideAttrs (o: + { + patches = with versions; switch [ coq.version o.version ] [ + { cases = [ (range "8.12.2" "8.13.2") "3.8" ]; + out = [ + # Support for Coq 8.12.2 + (fetchpatch { + url = "https://github.com/AbsInt/CompCert/commit/06956421b4307054af221c118c5f59593c0e67b9.patch"; + sha256 = "1f90q6j3xfvnf3z830bkd4d8526issvmdlrjlc95bfsqs78i1yrl"; + }) + # Support for Coq 8.13.0 + (fetchpatch { + url = "https://github.com/AbsInt/CompCert/commit/0895388e7ebf9c9f3176d225107e21968919fb97.patch"; + sha256 = "0qhkzgb2xl5kxys81pldp3mr39gd30lvr2l2wmplij319vp3xavd"; + }) + # Support for Coq 8.13.1 + (fetchpatch { + url = "https://github.com/AbsInt/CompCert/commit/6bf310dd678285dc193798e89fc2c441d8430892.patch"; + sha256 = "026ahhvpj5pksy90f8pnxgmhgwfqk4kwyvcf8x3dsanvz98d4pj5"; + }) + # Drop support for Coq < 8.9 + (fetchpatch { + url = "https://github.com/AbsInt/CompCert/commit/7563a5df926a4c6fb1489a7a4c847641c8a35095.patch"; + sha256 = "05vkslzy399r3dm6dmjs722rrajnyfa30xsyy3djl52isvn4gyfb"; + }) + # Support for Coq 8.13.2 + (fetchpatch { + url = "https://github.com/AbsInt/CompCert/commit/48bc183167c4ce01a5c9ea86e49d60530adf7290.patch"; + sha256 = "0j62lppfk26d1brdp3qwll2wi4gvpx1k70qivpvby5f7dpkrkax1"; + }) + ]; + } + ] []; + } +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 16f7df766583..4ba603980bd6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10553,7 +10553,7 @@ in cmucl_binary = pkgsi686Linux.callPackage ../development/compilers/cmucl/binary.nix { }; - compcert = callPackage ../development/compilers/compcert {}; + compcert = coqPackages.compcert.override { version = "3.9"; }; computecpp-unwrapped = callPackage ../development/compilers/computecpp {}; computecpp = wrapCCWith rec { diff --git a/pkgs/top-level/coq-packages.nix b/pkgs/top-level/coq-packages.nix index 1ac8c4c40057..fb7e2113018a 100644 --- a/pkgs/top-level/coq-packages.nix +++ b/pkgs/top-level/coq-packages.nix @@ -1,5 +1,5 @@ -{ lib, callPackage, newScope, recurseIntoAttrs, ocamlPackages_4_05, ocamlPackages_4_09 -, ocamlPackages_4_10, compcert +{ lib, stdenv, callPackage, newScope, recurseIntoAttrs, ocamlPackages_4_05, ocamlPackages_4_09 +, ocamlPackages_4_10, fetchpatch, makeWrapper, coq2html }@args: let lib = import ../build-support/coq/extra-lib.nix {inherit (args) lib;}; in let @@ -21,6 +21,10 @@ let category-theory = callPackage ../development/coq-modules/category-theory { }; Cheerios = callPackage ../development/coq-modules/Cheerios {}; CoLoR = callPackage ../development/coq-modules/CoLoR {}; + compcert = callPackage ../development/coq-modules/compcert { + ocamlPackages = ocamlPackages_4_05; + inherit fetchpatch makeWrapper coq2html lib stdenv; + }; coq-bits = callPackage ../development/coq-modules/coq-bits {}; coq-elpi = callPackage ../development/coq-modules/coq-elpi {}; coq-ext-lib = callPackage ../development/coq-modules/coq-ext-lib {}; @@ -78,11 +82,7 @@ let topology = callPackage ../development/coq-modules/topology {}; Velisarios = callPackage ../development/coq-modules/Velisarios {}; Verdi = callPackage ../development/coq-modules/Verdi {}; - VST = callPackage ../development/coq-modules/VST (with lib.versions; - lib.switch coq.coq-version [ - { case = "8.11"; out = { compcert = compcert.override { coqPackages = self; version = "3.7"; }; }; } - { case = range "8.12" "8.13"; out = { compcert = compcert.override { coqPackages = self; version = "3.8"; }; }; } - ] {}); + VST = callPackage ../development/coq-modules/VST {}; zorns-lemma = callPackage ../development/coq-modules/zorns-lemma {}; filterPackages = doesFilter: if doesFilter then filterCoqPackages self else self; };