From patchwork Tue Aug 17 10:19:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 32146 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 1037527BC78; Tue, 17 Aug 2021 11:23:47 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 59CD627BC6B for ; Tue, 17 Aug 2021 11:23:46 +0100 (BST) Received: from localhost ([::1]:57676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mFwG1-0002me-F1 for patchwork@mira.cbaines.net; Tue, 17 Aug 2021 06:23:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mFwFK-0001gj-Js for guix-patches@gnu.org; Tue, 17 Aug 2021 06:23:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mFwFK-0004Po-Cd for guix-patches@gnu.org; Tue, 17 Aug 2021 06:23:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mFwFK-00042B-8r for guix-patches@gnu.org; Tue, 17 Aug 2021 06:23:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50091] [PATCH 02/21] gnu: bootstrap: Add support for riscv64-linux. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Aug 2021 10:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50091 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50091@debbugs.gnu.org Cc: Efraim Flashner Received: via spool by 50091-submit@debbugs.gnu.org id=B50091.162919573615411 (code B ref 50091); Tue, 17 Aug 2021 10:23:02 +0000 Received: (at 50091) by debbugs.gnu.org; 17 Aug 2021 10:22:16 +0000 Received: from localhost ([127.0.0.1]:51769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mFwEZ-00040V-HK for submit@debbugs.gnu.org; Tue, 17 Aug 2021 06:22:16 -0400 Received: from flashner.co.il ([178.62.234.194]:45898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mFwEX-000409-Mf for 50091@debbugs.gnu.org; Tue, 17 Aug 2021 06:22:14 -0400 Received: from localhost (unknown [141.226.169.107]) by flashner.co.il (Postfix) with ESMTPSA id D562D402E0; Tue, 17 Aug 2021 10:22:07 +0000 (UTC) From: Efraim Flashner Date: Tue, 17 Aug 2021 13:19:00 +0300 Message-Id: <049e686bea6f7f4186fbc6da38315f707763bf3f.1629193993.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 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 On 7d93b21ab1c132990054372a9677c1639d54e631 gnu: glibc-for-bootstrap: Update patch. Run ./pre-inst-env guix build --target=riscv64-linux-gnu bootstrap-tarballs Producing /gnu/store/4hdzva9i0wyyfbgj1lmqc1wkk644pv07-bootstrap-tarballs-0 With guix hash -rx 1nj0fdgj08bbmfny01mp2blv7c3p2iciqh31zmf04ap5s7ygsqlp * gnu/packages/bootstrap.scm (%bootstrap-executables): Add entries for riscv64-linux. (%bootstrap-guile-hash, %bootstrap-coreutils&co, %bootstrap-binutils, %bootstrap-glibc, %bootstrap-gcc): Add entry for riscv64-linux. (raw-build-guile3): New procedure. (make-raw-bag): Use raw-build-guile3 for riscv64-linux. * gnu/packages/commencement.scm (findutils-boot0)[arguments]: Don't override TIME_T_32_BIT_OK on riscv64-linux. * guix/packages.scm (%supported-systems): Add riscv64-linux. (%cuirass-supported-systems): Remove riscv64-linux. * guix/utils.scm (target-64bit?): Add riscv64-linux. * m4/guix.m4: Add riscv64-linux as a supported system. --- gnu/packages/bootstrap.scm | 112 +++++++++++++++++++++++++++++++++- gnu/packages/commencement.scm | 4 +- guix/packages.scm | 4 +- guix/utils.scm | 3 +- m4/guix.m4 | 4 +- 5 files changed, 118 insertions(+), 9 deletions(-) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index 5a8028a465..260c1b5b91 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -144,7 +144,16 @@ ("tar" ,(base32 "150c8948cz8r208g6qgn2dn4f4zs5kpgbpbg6bwag6yw42rapw2l")) ("xz" - ,(base32 "0v5738idy9pqzcbrjdpxi5c6qs5m78zrpsydmrpx5cfcfzbkxzjh"))))) + ,(base32 "0v5738idy9pqzcbrjdpxi5c6qs5m78zrpsydmrpx5cfcfzbkxzjh"))) + ("riscv64-linux" + ("bash" + ,(base32 "0almlf73k6hbm495kzf4bw1rzsg5qddn7z2rf5l3d1xcapac2hj3")) + ("mkdir" + ,(base32 "0rg1amdcqfkplcy1608jignl8jq0wqzfkp430mwik3f62959gya6")) + ("tar" + ,(base32 "17d3x27qhiwk7h6ns0xrvbrq0frxz89mjjh2cdwx2rraq5x6wffm")) + ("xz" + ,(base32 "0nxn75xf386vdq3igmgm8gnyk4h4x0cm8jv71vlb2jvwxh0cyw1q"))))) (define %bootstrap-executable-base-urls ;; This is where the bootstrap executables come from. @@ -159,6 +168,7 @@ ("powerpc64le-linux" (string-append system "/20210106/" program)) ("i586-gnu" (string-append system "/20200326/" program)) ("powerpc-linux" (string-append system "/20200923/bin/" program)) + ("riscv64-linux" (string-append system "/20210725/bin/" program)) (_ (string-append system "/" program "?id=44f07d1dc6806e97c4e9ee3e6be883cc59dc666e")))) @@ -362,6 +372,8 @@ or false to signal an error." "/20200326/guile-static-stripped-2.0.14-i586-pc-gnu.tar.xz") ("powerpc64le-linux" "/20210106/guile-static-stripped-2.0.14-powerpc64le-linux-gnu.tar.xz") + ("riscv64-linux" + "/20210725/guile-3.0.2.tar.xz") (_ "/20131110/guile-2.0.9.tar.xz")))) @@ -383,7 +395,9 @@ or false to signal an error." ("i586-gnu" (base32 "0wgqpsmvg25rnqn49ap7kwd2qxccd8dr4lllzp7i3rjvgav27vac")) ("powerpc-linux" - (base32 "1by2p7s27fbyjzfkcw8h65h4kkqh7d23kv4sgg5jppjn2qx7swq4")))) + (base32 "1by2p7s27fbyjzfkcw8h65h4kkqh7d23kv4sgg5jppjn2qx7swq4")) + ("riscv64-linux" + (base32 "12pqmhsbbp7hh9r1bjdl14l3a4q06plpz6dcks9dysb4czay8p9f")))) (define (bootstrap-guile-origin system) "Return an object for the Guile tarball of SYSTEM." @@ -455,6 +469,76 @@ GUILE_SYSTEM_PATH=$out/share/guile/2.0 \ GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \ $out/bin/guile -c ~s $out ~a +# Sanity check. +$out/bin/guile --version~%" + (derivation->output-path mkdir) + (derivation->output-path xz) + (derivation->output-path tar) + (object->string wrapper) + (derivation->output-path bash))))) + (raw-derivation name + (derivation->output-path bash) `(,builder) + #:system system + #:inputs (map derivation-input + (list bash mkdir tar xz guile)) + #:sources (list builder) + #:env-vars `(("GUILE_TARBALL" + . ,(derivation->output-path guile)))))) + +(define* (raw-build-guile3 name inputs + #:key outputs system search-paths + #:allow-other-keys) + (define (->store file) + (lower-object (bootstrap-executable file system) + system)) + + (define (make-guile-wrapper bash guile-real) + ;; The following code, run by the bootstrap guile after it is unpacked, + ;; creates a wrapper for itself to set its load path. This replaces the + ;; previous non-portable method based on reading the /proc/self/exe + ;; symlink. + '(begin + (use-modules (ice-9 match)) + (match (command-line) + ((_ out bash) + (let ((bin-dir (string-append out "/bin")) + (guile (string-append out "/bin/guile")) + (guile-real (string-append out "/bin/.guile-real")) + ;; We must avoid using a bare dollar sign in this code, + ;; because it would be interpreted by the shell. + (dollar (string (integer->char 36)))) + (chmod bin-dir #o755) + (rename-file guile guile-real) + (call-with-output-file guile + (lambda (p) + (format p "\ +#!~a +export GUILE_SYSTEM_PATH=~a/share/guile/3.0 +export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/3.0/ccache +exec -a \"~a0\" ~a \"~a@\"\n" + bash out out dollar guile-real dollar))) + (chmod guile #o555) + (chmod bin-dir #o555)))))) + + (mlet* %store-monad ((tar (->store "tar")) + (xz (->store "xz")) + (mkdir (->store "mkdir")) + (bash (->store "bash")) + (guile (download-bootstrap-guile system)) + (wrapper -> (make-guile-wrapper bash guile)) + (builder + (text-file "build-bootstrap-guile.sh" + (format #f " +echo \"unpacking bootstrap Guile to '$out'...\" +~a $out +cd $out +~a -dc < $GUILE_TARBALL | ~a xv + +# Use the bootstrap guile to create its own wrapper to set the load path. +GUILE_SYSTEM_PATH=$out/share/guile/3.0 \ +GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/3.0/ccache \ +$out/bin/guile -c ~s $out ~a + # Sanity check. $out/bin/guile --version~%" (derivation->output-path mkdir) @@ -478,7 +562,9 @@ $out/bin/guile --version~%" (name name) (system system) (build-inputs inputs) - (build raw-build))) + (build (cond ((target-riscv?) + raw-build-guile3) + (else raw-build))))) (define %bootstrap-guile ;; The Guile used to run the build scripts of the initial derivations. @@ -518,6 +604,8 @@ $out/bin/guile --version~%" "/20200326/static-binaries-0-i586-pc-gnu.tar.xz") ("powerpc-linux" "/20200923/static-binaries.tar.xz") + ("riscv64-linux" + "/20210725/static-binaries.tar.xz") (_ "/20131110/static-binaries.tar.xz"))) %bootstrap-base-urls)) @@ -544,6 +632,9 @@ $out/bin/guile --version~%" ("powerpc-linux" (base32 "0kspxy0yczan2vlih6aa9hailr2inz000fqa0gn5x9d1fxxa5y8m")) + ("riscv64-linux" + (base32 + "0x0xjlpmyh6rkr51p00gp6pscgl6zjida1rsg8vk3rinyi6rrbkg")) ("mips64el-linux" (base32 "072y4wyfsj1bs80r6vbybbafy8ya4vfy7qj25dklwk97m6g71753")))))) @@ -596,6 +687,8 @@ $out/bin/guile --version~%" "/20200326/binutils-static-stripped-2.34-i586-pc-gnu.tar.xz") ("powerpc-linux" "/20200923/binutils-2.35.1.tar.xz") + ("riscv64-linux" + "/20210725/binutils-2.34.tar.xz") (_ "/20131110/binutils-2.23.2.tar.xz"))) %bootstrap-base-urls)) @@ -616,6 +709,9 @@ $out/bin/guile --version~%" ("powerpc64le-linux" (base32 "1klxy945c61134mzhqzz2gbk8w0n8jq7arwkrvz78d22ff2q0cwz")) + ("riscv64-linux" + (base32 + "0n9qf4vbilfmh1lknhw000waakj4q6s50pnjazr5137skm976z5m")) ("i586-gnu" (base32 "11kykv1kmqc5wln57rs4klaqa13hm952smkc57qcsyss21kfjprs")) @@ -681,6 +777,8 @@ $out/bin/guile --version~%" "/20200326/glibc-stripped-2.31-i586-pc-gnu.tar.xz") ("powerpc-linux" "/20200923/glibc-2.32.tar.xz") + ("riscv64-linux" + "/20210725/glibc-2.31.tar.xz") (_ "/20131110/glibc-2.18.tar.xz"))) %bootstrap-base-urls)) @@ -701,6 +799,9 @@ $out/bin/guile --version~%" ("powerpc64le-linux" (base32 "1a1df6z8gkaq09md3jy94lixnh20599p58p0s856p10xwjaqr1iz")) + ("riscv64-linux" + (base32 + "0d9x80vm7ca1pd2whcmpm1h14zxpb58kqajlxlwffzm04xfsjnxm")) ("i586-gnu" (base32 "14ddm10lpbas8bankmn5bcrlqvz1v5dnn1qjzxb19r57vd2w5952")) @@ -782,6 +883,8 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \ "/20200326/gcc-stripped-5.5.0-i586-pc-gnu.tar.xz") ("powerpc-linux" "/20200923/gcc-5.5.0.tar.xz") + ("riscv64-linux" + "/20210725/gcc-7.5.0.tar.xz") (_ "/20131110/gcc-4.8.2.tar.xz"))) %bootstrap-base-urls)) @@ -802,6 +905,9 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \ ("powerpc64le-linux" (base32 "151kjsai25vz2s667bgzpisx8f281fpl3n9pxz2yrp9jlnadz3m1")) + ("riscv64-linux" + (base32 + "1k4mbnb54wj2q37fgshf5dfixixqnhn002vhzvi9pnb57xb9v14d")) ("i586-gnu" (base32 "1j2zc58wzil71a34h7c70sd68dmqvcscrw3rmn2whq79vd70zvv5")) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index dc9b372132..d395b261c2 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -2496,7 +2496,9 @@ exec " gcc "/bin/" program ,@(substitute-keyword-arguments (package-arguments findutils) ((#:configure-flags flags ''()) `(append - ,(if (target-64bit?) + ;; TODO: Figure out exactly with architectures need this. + ,(if (and (target-64bit?) + (not (target-riscv?))) ''("TIME_T_32_BIT_OK=yes") ''()) ,(match (%current-system) diff --git a/guix/packages.scm b/guix/packages.scm index 2349bb4340..7e86da9aae 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -366,7 +366,7 @@ name of its URI." ;; This is the list of system types that are supported. By default, we ;; expect all packages to build successfully here. '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux" "mips64el-linux" "i586-gnu" - "powerpc64le-linux" "powerpc-linux")) + "powerpc64le-linux" "powerpc-linux" "riscv64-linux")) (define %hurd-systems ;; The GNU/Hurd systems for which support is being developed. @@ -377,7 +377,7 @@ name of its URI." ;; ;; XXX: MIPS is unavailable in CI: ;; . - (fold delete %supported-systems '("mips64el-linux" "powerpc-linux"))) + (fold delete %supported-systems '("mips64el-linux" "powerpc-linux" "riscv64-linux"))) (define-inlinable (sanitize-inputs inputs) "Sanitize INPUTS by turning it into a list of name/package tuples if it's diff --git a/guix/utils.scm b/guix/utils.scm index 134879feb1..3ca846f075 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -707,7 +707,8 @@ architecture (x86_64)?" (define* (target-64bit? #:optional (system (or (%current-target-system) (%current-system)))) - (any (cut string-prefix? <> system) '("x86_64" "aarch64" "mips64" "powerpc64"))) + (any (cut string-prefix? <> system) '("x86_64" "aarch64" "mips64" + "powerpc64" "riscv64"))) (define* (cc-for-target #:optional (target (%current-target-system))) (if target diff --git a/m4/guix.m4 b/m4/guix.m4 index e778a56004..c79d3c3bc5 100644 --- a/m4/guix.m4 +++ b/m4/guix.m4 @@ -1,7 +1,7 @@ dnl GNU Guix --- Functional package management for GNU dnl Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021 Ludovic Courtès dnl Copyright © 2014 Mark H Weaver -dnl Copyright © 2017, 2020 Efraim Flashner +dnl Copyright © 2017, 2020, 2021 Efraim Flashner dnl Copyright © 2021 Chris Marusich dnl dnl This file is part of GNU Guix. @@ -89,7 +89,7 @@ courageous and port the GNU System distribution to it (see # Currently only Linux-based systems are supported, and only on some # platforms. case "$guix_system" in - x86_64-linux|i686-linux|armhf-linux|aarch64-linux|powerpc64le-linux|powerpc-linux) + x86_64-linux|i686-linux|armhf-linux|aarch64-linux|powerpc64le-linux|powerpc-linux|riscv64-linux) ;; *) if test "x$guix_courageous" = "xyes"; then