From patchwork Fri Feb 26 23:13:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Lepiller X-Patchwork-Id: 27321 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5926C27BEB7; Fri, 26 Feb 2021 23:15:13 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8319A27BEB8 for ; Fri, 26 Feb 2021 23:15:10 +0000 (GMT) Received: from localhost ([::1]:59318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFmKD-0002cN-HU for patchwork@mira.cbaines.net; Fri, 26 Feb 2021 18:15:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFmK6-0002cF-BF for guix-patches@gnu.org; Fri, 26 Feb 2021 18:15:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lFmK6-0002oa-3B for guix-patches@gnu.org; Fri, 26 Feb 2021 18:15:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lFmK5-0000lt-Th for guix-patches@gnu.org; Fri, 26 Feb 2021 18:15:01 -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: Fri, 26 Feb 2021 23:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46806 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46806@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16143812442881 (code B ref -1); Fri, 26 Feb 2021 23:15:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Feb 2021 23:14:04 +0000 Received: from localhost ([127.0.0.1]:42780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFmJ9-0000kP-IL for submit@debbugs.gnu.org; Fri, 26 Feb 2021 18:14:04 -0500 Received: from lists.gnu.org ([209.51.188.17]:60926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFmJ7-0000k6-J0 for submit@debbugs.gnu.org; Fri, 26 Feb 2021 18:14:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFmJ7-0002ZO-Dr for guix-patches@gnu.org; Fri, 26 Feb 2021 18:14:01 -0500 Received: from lepiller.eu ([2a00:5884:8208::1]:33066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFmJ2-0002F6-JM for guix-patches@gnu.org; Fri, 26 Feb 2021 18:14:00 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 841a9365 for ; Fri, 26 Feb 2021 23:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=8Vz /nnhEHTS8ku46lfeRYHa7+EaaYpjC4MP4CbhW+zI=; b=BSEOCnBJBkAQALgGa+w wfcfu9TrRmr2AZxFmcl2C0a4kVVcFyLa5RhOrWQxp6i9m9Xxw5ZBHqLJP+AX+o+/ BCAdFiDNUrxWTdWMB149OIh9o4gTHjrv3NBfOw7fiZr0xkSjbziv0bYPCCrlXzhd VzO9IDdUfclOLd6cw2g4qektEzrvKvmvrLiS46KZiO+QjKCJ3/Kh1YpLG8zDwPJc hwYNRK5qqAfXBSjouhmlrycjegaIiqrQgOFqksvNWYzkrbzkOME3FWM+G5KekWl1 ybxOCkjnEFAhyVbaBY4GBnZQc0YgXkFOp/Gk9q7vPIFruhXYGgJ6BmaTvBX6ZjdF fCA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id a78db312 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Fri, 26 Feb 2021 23:13:45 +0000 (UTC) Date: Sat, 27 Feb 2021 00:13:39 +0100 From: Julien Lepiller Message-ID: <20210227001244.17cc3833@tachikoma.lepiller.eu> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Guix! This small series adds camlboot, a project to reimplement a bootstrap for OCaml, which lets us remove the pre-built boot/ocaml{c,lex} :) The first patch builds the bootstraped ocamlc and ocamllex. This takes around 4 hours to build. The second patch rebuilds them using the source code for ocaml 4.07.1, instead of the modified sources used in camlboot, and reuse them to run the main Makefile (make world.opt). As a result, we have identical files for this bootstrap and the unbootstrapped OCaml (up to output store paths and hash of some files that get embedded in native files, which differ because of the different output path). From 8fa9e59c8d90339478d65e269b37cbb3b201232d 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 | 179 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 176 insertions(+), 3 deletions(-) diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm index 01c14a0ba0..272ed3a2d6 100644 --- a/gnu/packages/ocaml.scm +++ b/gnu/packages/ocaml.scm @@ -255,7 +255,7 @@ functional, imperative and object-oriented styles of programming.") (base32 "1v3z5ar326f3hzvpfljg4xj8b9lmbrl53fn57yih1bkbx3gr3yzj")))))) -(define-public ocaml-4.07 +(define ocaml-4.07-boot (package (inherit ocaml-4.09) (version "4.07.1") @@ -267,11 +267,102 @@ 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))) + (define (touch file) (invoke "touch" file)) + (touch "byterun/.depend") + (make "-C" "byterun" "depend") + (make "-C" "byterun" "all") + (copy-file "byterun/ocamlrun" "boot/ocamlrun") + (touch ".depend") + (make "ocamlyacc") + (copy-file "yacc/ocamlyacc" "boot/ocamlyacc") + (touch "stdlib/.depend") + (make "-C" "stdlib" "sys.ml") + (make "-C" "stdlib" "CAMLDEP=../boot/ocamlc -depend" "depend") + (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") + (touch "tools/.depend") + (make "-C" "tools" + "CAMLC=../boot/ocamlc -nostdlib -I ../boot -use-prims ../byterun/primitives -I .." + "make_opcodes" "cvt_emit") + (touch "lex/.depend") + (make "-C" "lex" "CAMLDEP=../boot/ocamlc -depend" "depend") + (make "CAMLDEP=boot/ocamlc -depend" "depend") + (make "CAMLC=boot/ocamlc -nostdlib -I boot -use-prims byterun/primitives" + "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"))) + (mkdir-p bin) + (install-file "ocamlc" bin) + (install-file "lex/ocamllex" bin) + (install-file "byterun/ocamlrun" bin))))))) + (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") + (copy-file (string-append ocaml "/bin/ocamlrun") "boot/ocamlrun") + (chmod "boot/ocamlrun" #o755) + (chmod "boot/ocamllex" #o755) + (chmod "boot/ocamlc" #o755)))) (replace 'configure (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) @@ -280,7 +371,89 @@ functional, imperative and object-oriented styles of programming.") ;; --prefix= syntax (with equals sign). (invoke "./configure" "--prefix" out - "--mandir" mandir)))))))))) + "--mandir" mandir)))) + (add-before 'build 'generate-depend + (lambda* (#:key parallel-build? #:allow-other-keys) + (define* (make . args) + (apply invoke "make" + (append (if parallel-build? + `("-j" ,(number->string (parallel-job-count))) + '()) + args))) + ;; These files were deleted in a snippet because they are + ;; pre-generated + (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") + (make "-C" "byterun" "depend") + (make "-C" "asmrun" "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") + (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 "-C" "lex" "CAMLDEP=../boot/ocamlc -depend" "depend") + (make "-C" "lex" "all") + (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")) + (make "-C" "tools" "depend") + (make "-C" "otherlibs/bigarray" "depend") + (make "-C" "otherlibs/graph" "depend") + (make "-C" "otherlibs/raw_spacetime_lib" "depend") + (make "-C" "otherlibs/str" "depend") + (make "-C" "otherlibs/systhreads" "depend") + (make "-C" "otherlibs/threads" "depend") + (make "-C" "otherlibs/unix" "depend") + (make "-C" "otherlibs/win32unix" "depend") + (make "-C" "debugger" "CAMLDEP=../boot/ocamlc -depend" "depend") + (make "-C" "ocamltest" "ocamldep=../boot/ocamlc -depend -slash" "depend") + (make "parsing/parser.mli") + (substitute* "ocamldoc/Makefile" + (("include Makefile.unprefix") + "include Makefile.unprefix +depend: $(STDLIB_MLIS) $(STDLIB_DEPS)")) + (make "-C" "ocamldoc" "OCAMLDEP=../boot/ocamlc -depend -slash" "depend") + (make "-C" "ocamldoc/stdlib_non_prefixed" + "OCAMLDEP=../../boot/ocamlc -depend -slash" "depend") + (make "CAMLDEP=boot/ocamlc -depend" "depend") + )))))) + (native-inputs + `(("ocaml" ,ocaml-4.07-boot) + ("perl" ,perl) + ("pkg-config" ,pkg-config))))) (define-public ocaml ocaml-4.11) -- 2.30.0