Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-20.03 73 lines 2.2 kB view raw
1{ stdenv, lib, fetchFromGitHub, makeWrapper 2, coq, ocamlPackages, coq2html 3, tools ? stdenv.cc 4}: 5 6assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02"; 7assert lib.versionAtLeast coq.coq-version "8.8.0"; 8 9let 10 ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir ]; 11 ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux"; 12in 13stdenv.mkDerivation rec { 14 pname = "compcert"; 15 version = "3.6"; 16 17 src = fetchFromGitHub { 18 owner = "AbsInt"; 19 repo = "CompCert"; 20 rev = "v${version}"; 21 sha256 = "1k9xhj7fgllhf7bn7rp3w6zfvs4clglnc4w39zp4678hrwvdcpha"; 22 }; 23 24 nativeBuildInputs = [ makeWrapper ]; 25 buildInputs = ocaml-pkgs ++ [ coq coq2html ]; 26 enableParallelBuilding = true; 27 28 patchPhase = '' 29 substituteInPlace ./configure \ 30 --replace '{toolprefix}gcc' '{toolprefix}cc' 31 ''; 32 33 configurePhase = '' 34 ./configure -clightgen \ 35 -prefix $out \ 36 -toolprefix ${tools}/bin/ \ 37 ${ccomp-platform} 38 ''; 39 40 installTargets = "documentation install"; 41 postInstall = '' 42 # move man into place 43 mkdir -p $man/share 44 mv $out/share/man/ $man/share/ 45 46 # move docs into place 47 mkdir -p $doc/share/doc/compcert 48 mv doc/html $doc/share/doc/compcert/ 49 50 # install compcert lib files; remove copy from $out, too 51 mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ 52 mv backend cfrontend common cparser driver flocq x86 x86_64 lib \ 53 $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ 54 rm -rf $out/lib/compcert/coq 55 56 # wrap ccomp to undefine _FORTIFY_SOURCE; ccomp invokes cc1 which sets 57 # _FORTIFY_SOURCE=2 by default, but undefines __GNUC__ (as it should), 58 # which causes a warning in libc. this suppresses it. 59 for x in ccomp clightgen; do 60 wrapProgram $out/bin/$x --add-flags "-U_FORTIFY_SOURCE" 61 done 62 ''; 63 64 outputs = [ "out" "lib" "doc" "man" ]; 65 66 meta = with stdenv.lib; { 67 description = "Formally verified C compiler"; 68 homepage = "http://compcert.inria.fr"; 69 license = licenses.inria-compcert; 70 platforms = [ "x86_64-linux" "x86_64-darwin" ]; 71 maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ]; 72 }; 73}