From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OCPBFTUAO2DKRQAA0tVLHw (envelope-from ) for ; Sun, 28 Feb 2021 02:30:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id ODmCETUAO2ATMwAAB5/wlQ (envelope-from ) for ; Sun, 28 Feb 2021 02:30:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B8E141B8DC for ; Sun, 28 Feb 2021 03:30:11 +0100 (CET) Received: from localhost ([::1]:37802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGBqU-0002Ht-B2 for larch@yhetil.org; Sat, 27 Feb 2021 21:30:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGBqM-0002Hi-OZ for guix-patches@gnu.org; Sat, 27 Feb 2021 21:30:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:34083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lGBqM-0002Sj-Gx for guix-patches@gnu.org; Sat, 27 Feb 2021 21:30:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lGBqM-0006ob-DL for guix-patches@gnu.org; Sat, 27 Feb 2021 21:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46806] [PATCH] gnu: ocaml-4.07: Bootstrap. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Feb 2021 02:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46806 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46806@debbugs.gnu.org Received: via spool by 46806-submit@debbugs.gnu.org id=B46806.161447938726146 (code B ref 46806); Sun, 28 Feb 2021 02:30:02 +0000 Received: (at 46806) by debbugs.gnu.org; 28 Feb 2021 02:29:47 +0000 Received: from localhost ([127.0.0.1]:45629 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGBq6-0006nd-I7 for submit@debbugs.gnu.org; Sat, 27 Feb 2021 21:29:47 -0500 Received: from lepiller.eu ([89.234.186.109]:58932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lGBq3-0006nQ-DB for 46806@debbugs.gnu.org; Sat, 27 Feb 2021 21:29:44 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 9c01c991 for <46806@debbugs.gnu.org>; Sun, 28 Feb 2021 02:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:in-reply-to:references:mime-version :content-type; s=dkim; bh=SZ+9yTKoZ0mr0AClhIVnkvWty0/l0muc6xNEGm P/6Jo=; b=lo31cpQbpJ8XxiHkId5vY7XNcLK+gvu7nz5snEWZYi10bwXqQc+SuP TTRDmDAS6+fSCg4kBShbsgnWNsfgU/qZFPgtIbwedKvHdcRQ0goZqN7EQoNWHN/Q 3lxvOOI9oOtv/ZncHxc1NwsVrj3oAak7hL+V24OL2xcVCP1xSnT5yKkwXmsogoPG LvqcBE4u8I/T4Br/O5WckSUU/mGbncfVyLo+SnPl636Ph9QgX3HwXFfEB3+fWfAd Zp1xsMSazl+AuLnyb/2T1iiDeMPebPOkx0wWbyCy0jMTy0OJNMN4CiIj40AuAniF w1QtunNQcIloYTlh7OK5i9GKJQ9E1d9w== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 85f1d9af (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for <46806@debbugs.gnu.org>; Sun, 28 Feb 2021 02:29:40 +0000 (UTC) Date: Sun, 28 Feb 2021 03:29:33 +0100 From: Julien Lepiller Message-ID: <20210228032933.6f84c90a@tachikoma.lepiller.eu> In-Reply-To: <20210228030905.78ccf557@tachikoma.lepiller.eu> References: <20210227001244.17cc3833@tachikoma.lepiller.eu> <20210228030905.78ccf557@tachikoma.lepiller.eu> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/UwmgCR6s5fLMNBYR7SkI6F1" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1614479413; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=d2erQtQ3dOCz44yz3kl6HitrY9rFf0ZsTRVPqjtSybU=; b=cukrNQHUwiOus5B4FzDmBUcTl+cP0sMqU8jQFF8MVfnvf3avYc+WKPYDQoFyooF+fcUrdT ugkS7CY7ZWhPCYk/vWeZ96t7+F2W6jTj1YioTutMFKf/AQfDE6HLiACpJ8WMkBbwu0WuK2 EI/pC8ebBRr+WQUYe8ONeTuiKNz3HN9MpcQvqF6gykw91Sg2YoY4lmhkoFXaSMcOMp5npZ a1e6pLdybt2gaw0q0rSJmM5jgztnyAR+sUkJTHlpPhK3zEViR919AWSkpqhk9r90GK0pzn 5TK8k7JjOuE6+WtkNegd7HlqeUbcmOM5xcIfg24uXw+Iu4YihtgRt5RCYMfL+Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1614479413; a=rsa-sha256; cv=none; b=GgTUifsXfbYKh9jfbk2mdEKHNwxX6EJB3v7khVyusbY5f+1JRnhAKKMI+dABNuJUWHFfVE JXEJp3JBk0vS26PRlTWlIaldV7/MyzNEz6GskUrSQm84rCTY1J6hfek/IexDC2O9ZNn1JE TRd2xOH25g+Z/gKS/PrYdMxA6zeTVfh/Iig7aHfO8/RoBsTVO7JmsURiRkbW7Suo4RaAGK /g9RsDbFCo412f2El+bM6K9odVLfrxHMN03HOoydgA8JsXOvvgVklBRYBoI/wngTXCm+1x UWxgAhMxiof6X/P+IanOkHYouTiqxo0gpYJAyKPogRr6F3pmzkYO6ECUGeUZIg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=lo31cpQb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.27 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=lo31cpQb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: B8E141B8DC X-Spam-Score: -1.27 X-Migadu-Scanner: scn0.migadu.com X-TUID: JPByQSAfZ9OM --MP_/UwmgCR6s5fLMNBYR7SkI6F1 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Of course I forgot to attach the patches ^^' --MP_/UwmgCR6s5fLMNBYR7SkI6F1 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-gnu-Add-camlboot.patch >From 8fd06caa83e55d27dc5998f7548a7d45c55c6a91 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sat, 27 Feb 2021 00:07:20 +0100 Subject: [PATCH 1/2] gnu: Add camlboot. * gnu/packages/ocaml.scm (camlboot): New variable. --- gnu/packages/ocaml.scm | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm index 9e68359a42..01c14a0ba0 100644 --- a/gnu/packages/ocaml.scm +++ b/gnu/packages/ocaml.scm @@ -52,6 +52,7 @@ #:use-module (gnu packages glib) #:use-module (gnu packages gnome) #:use-module (gnu packages gtk) + #:use-module (gnu packages guile) #:use-module (gnu packages libevent) #:use-module (gnu packages libffi) #:use-module (gnu packages llvm) @@ -105,6 +106,71 @@ ".tar.gz")) (sha256 (base32 hash)))) +(define-public camlboot + (let ((commit "506280c6e0813e0e794988151a8e46be55373ebc") + (revision "0")) + (package + (name "camlboot") + (version (git-version "0.0.0" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/Ekdohibs/camlboot") + (commit commit) + (recursive? #t))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0vimxl4karw9ih3npyc5rhxg85cjh6fqjbq3dzj7j2iymlhwfbkv")) + (modules '((guix build utils))) + (snippet + `(begin + ;; Remove bootstrap binaries and pre-generated source files, + ;; to ensure we actually bootstrap properly. + (for-each delete-file (find-files "ocaml-src" "^.depend$")) + (delete-file "ocaml-src/boot/ocamlc") + (delete-file "ocaml-src/boot/ocamllex") + ;; Ensure writable + (for-each + (lambda (file) + (chmod file (logior (stat:mode (stat file)) #o200))) + (find-files "." ".")))))) + (build-system gnu-build-system) + (arguments + `(#:make-flags (list "_boot/ocamlc"); build target + #:tests? #f; no tests + #:phases + (modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'no-autocompile + (lambda _ + ;; prevent a guile warning + (setenv "GUILE_AUTO_COMPILE" "0"))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin"))) + (mkdir-p bin) + (install-file "_boot/ocamlc" bin) + (rename-file "miniml/interp/lex.byte" "ocamllex") + (install-file "ocamllex" bin))))))) + (native-inputs + `(("guile" ,guile-3.0))) + (home-page "https://github.com/Ekdohibs/camlboot") + (synopsis "OCaml bootstrap") + (description "OCaml is written in OCaml. Its sources contain a pre-compiled +bytecode version of ocamlc and ocamllex that are used to build the next version +of the compiler. Camlboot implements a bootstrap for the OCaml compiler and +provides a bootstrapped equivalent to these files. + +It contains a compiler for a small subset of OCaml written in Guile Scheme, +an interpreter for OCaml written in that subset and a manually-written lexer +for OCaml. These elements eliminate the need for the binary bootstrap in +OCaml and can effectively bootstrap OCaml 4.07. + +This package produces a native ocamlc and a bytecode ocamllex.") + (license license:expat)))) + (define-public ocaml-4.11 (package (name "ocaml") -- 2.30.0 --MP_/UwmgCR6s5fLMNBYR7SkI6F1 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-gnu-ocaml-4.07-Bootstrap.patch >From ed2c4c1c221eb60ddc9e47b58c03d9194c6a2beb Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sat, 27 Feb 2021 00:07:30 +0100 Subject: [PATCH 2/2] gnu: ocaml-4.07: Bootstrap. * gnu/packages/ocaml.scm (ocaml-4.07): Implement bootstrap via camlboot. --- gnu/packages/ocaml.scm | 152 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 3 deletions(-) diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm index 01c14a0ba0..ec5ddce2ac 100644 --- a/gnu/packages/ocaml.scm +++ b/gnu/packages/ocaml.scm @@ -255,7 +255,11 @@ functional, imperative and object-oriented styles of programming.") (base32 "1v3z5ar326f3hzvpfljg4xj8b9lmbrl53fn57yih1bkbx3gr3yzj")))))) -(define-public ocaml-4.07 +;; This package is a bootstrap package for ocaml-4.07. It builds from camlboot, +;; using the upstream sources for ocaml 4.07. It installs a bytecode ocamllex +;; and ocamlc, the bytecode interpreter ocamlrun, and generated .depend files +;; that we otherwise remove for bootstrap purposes. +(define ocaml-4.07-boot (package (inherit ocaml-4.09) (version "4.07.1") @@ -267,11 +271,149 @@ functional, imperative and object-oriented styles of programming.") "/ocaml-" version ".tar.xz")) (sha256 (base32 - "1f07hgj5k45cylj1q3k5mk8yi02cwzx849b1fwnwia8xlcfqpr6z")))) + "1f07hgj5k45cylj1q3k5mk8yi02cwzx849b1fwnwia8xlcfqpr6z")) + (modules '((guix build utils))) + (snippet + `(begin + ;; Remove bootstrap binaries and pre-generated source files, + ;; to ensure we actually bootstrap properly. + (for-each delete-file (find-files "." "^.depend$")) + (delete-file "boot/ocamlc") + (delete-file "boot/ocamllex"))))) + (arguments + `(#:tests? #f + #:phases + (modify-phases %standard-phases + (add-before 'configure 'copy-bootstrap + (lambda* (#:key inputs #:allow-other-keys) + (let ((camlboot (assoc-ref inputs "camlboot"))) + (copy-file (string-append camlboot "/bin/ocamllex") "boot/ocamllex") + (copy-file (string-append camlboot "/bin/ocamlc") "boot/ocamlc") + (chmod "boot/ocamllex" #o755) + (chmod "boot/ocamlc" #o755)))) + (replace 'configure + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (mandir (string-append out "/share/man"))) + (invoke "./configure" + "--prefix" out + "--mandir" mandir)))) + (replace 'build + (lambda* (#:key parallel-build? #:allow-other-keys) + (define* (make . args) + (apply invoke "make" + (append (if parallel-build? + `("-j" ,(number->string (parallel-job-count))) + '()) + args))) + ;; create empty .depend files because they are included by various + ;; Makefiles, and they have no rule to generate them. + (invoke "touch" ".depend" "stdlib/.depend" "byterun/.depend" + "tools/.depend" "lex/.depend" "asmrun/.depend" + "debugger/.depend" "ocamltest/.depend" "ocamldoc/.depend" + "ocamldoc/stdlib_non_prefixed/.depend" + "otherlibs/bigarray/.depend" "otherlibs/graph/.depend" + "otherlibs/raw_spacetime_lib/.depend" "otherlibs/str/.depend" + "otherlibs/systhreads/.depend" "otherlibs/threads/.depend" + "otherlibs/unix/.depend" "otherlibs/win32unix/.depend") + ;; We cannot build ocamldep until we have created all the .depend + ;; files, so replace it with ocamlc -depend. + (substitute* "tools/Makefile" + (("\\$\\(CAMLRUN\\) ./ocamldep") "../boot/ocamlc -depend")) + (substitute* '("otherlibs/graph/Makefile" + "otherlibs/systhreads/Makefile" + "otherlibs/threads/Makefile" + "otherlibs/unix/Makefile") + (("\\$\\(CAMLRUN\\) ../../tools/ocamldep") + "../../boot/ocamlc -depend")) + (substitute* '("otherlibs/bigarray/Makefile" + "otherlibs/raw_spacetime_lib/Makefile" + "otherlibs/str/Makefile" + "otherlibs/win32unix/Makefile") + (("\\$\\(CAMLRUN\\) \\$\\(ROOTDIR\\)/tools/ocamldep") + "../../boot/ocamlc -depend")) + ;; Ensure we copy needed file, so we can generate a proper .depend + (substitute* "ocamldoc/Makefile" + (("include Makefile.unprefix") + "include Makefile.unprefix +depend: $(STDLIB_MLIS) $(STDLIB_DEPS)")) + ;; Generate required tools for `alldepend' + (make "-C" "byterun" "depend") + (make "-C" "byterun" "all") + (copy-file "byterun/ocamlrun" "boot/ocamlrun") + (make "ocamlyacc") + (copy-file "yacc/ocamlyacc" "boot/ocamlyacc") + (make "-C" "stdlib" "sys.ml") + (make "-C" "stdlib" "CAMLDEP=../boot/ocamlc -depend" "depend") + ;; Build and copy files later used by `tools' + (make "-C" "stdlib" "COMPILER=" + "CAMLC=../boot/ocamlc -use-prims ../byterun/primitives" + "all") + (for-each + (lambda (file) + (copy-file file (string-append "boot/" (basename file)))) + (cons* "stdlib/stdlib.cma" "stdlib/std_exit.cmo" "stdlib/camlheader" + (find-files "stdlib" ".*.cmi$"))) + (symlink "../byterun/libcamlrun.a" "boot/libcamlrun.a") + (make "parsing/parser.mli"); required for ocamldoc/stdlib_non_prefixed + ;; required for dependencies + (make "-C" "tools" + "CAMLC=../boot/ocamlc -nostdlib -I ../boot -use-prims ../byterun/primitives -I .." + "make_opcodes" "cvt_emit") + ;; generate all remaining .depend files + (make "alldepend" + (string-append "ocamllex=" (getcwd) "/boot/ocamlrun " + (getcwd) "/boot/ocamllex") + (string-append "CAMLDEP=" (getcwd) "/boot/ocamlc -depend") + (string-append "OCAMLDEP=" (getcwd) "/boot/ocamlc -depend") + (string-append "ocamldep=" (getcwd) "/boot/ocamlc -depend")) + ;; Build ocamllex + (make "CAMLC=boot/ocamlc -nostdlib -I boot -use-prims byterun/primitives" + "ocamlc") + ;; Build ocamlc + (make "-C" "lex" + "CAMLC=../boot/ocamlc -strict-sequence -nostdlib -I ../boot -use-prims ../byterun/primitives" + "all"))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (depends (string-append out "/share/depends"))) + (mkdir-p bin) + (mkdir-p depends) + (install-file "ocamlc" bin) + (install-file "lex/ocamllex" bin) + (for-each + (lambda (file) + (let ((dir (string-append depends "/" (dirname file)))) + (mkdir-p dir) + (install-file file dir))) + (find-files "." "^\\.depend$")))))))) + (native-inputs + `(("camlboot" ,camlboot) + ("perl" ,perl) + ("pkg-config" ,pkg-config))))) + +(define-public ocaml-4.07 + (package + (inherit ocaml-4.07-boot) (arguments (substitute-keyword-arguments (package-arguments ocaml-4.09) ((#:phases phases) `(modify-phases ,phases + (add-before 'configure 'copy-bootstrap + (lambda* (#:key inputs #:allow-other-keys) + (let ((ocaml (assoc-ref inputs "ocaml"))) + (copy-file (string-append ocaml "/bin/ocamllex") "boot/ocamllex") + (copy-file (string-append ocaml "/bin/ocamlc") "boot/ocamlc") + (chmod "boot/ocamllex" #o755) + (chmod "boot/ocamlc" #o755) + (let ((rootdir (getcwd))) + (with-directory-excursion (string-append ocaml "/share/depends") + (for-each + (lambda (file) + (copy-file file (string-append rootdir "/" file))) + (find-files "." "."))))))) (replace 'configure (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -280,7 +422,11 @@ functional, imperative and object-oriented styles of programming.") ;; --prefix= syntax (with equals sign). (invoke "./configure" "--prefix" out - "--mandir" mandir)))))))))) + "--mandir" mandir)))))))) + (native-inputs + `(("ocaml" ,ocaml-4.07-boot) + ("perl" ,perl) + ("pkg-config" ,pkg-config))))) (define-public ocaml ocaml-4.11) -- 2.30.0 --MP_/UwmgCR6s5fLMNBYR7SkI6F1--