[bug#55227,core-updates,2/8] commencement: Add stage0-posix.
Commit Message
Thiago Jung Bauermann writes:
Hello Thiago,
> This is great work!
Thanks!
> This is not an area I have experience in, so I didn't read it closely,
> at least as of yet. I have only one minor comment:
>> diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
>> index 663ffacd56..24e1e6ec8c 100644
>> --- a/gnu/packages/commencement.scm
>> +++ b/gnu/packages/commencement.scm
[..]
>> + (stage0-cpu
>> + (cond
>> + ((or (string-prefix? "x86_64-linux" target)
>
> IMHO the code is clearer and less error prone if the (guix utils)
> convenience functions are used to test the target rather than directly
> doing string pattern matching.
>
> In this case, ‘target-x86-64?’ is the one. There's no need to even pass
> an argument to it since the default is what you need.
>
> The check for Linux could be done separately in the body of the builder
> with ‘target-linux?’. What do you think?
>
>> + (string-prefix? "i686-linux" target))
>
> Here it would be ‘target-x86-32?’.
>
>> + "x86")
>> + ((or (string-prefix? "aarch64-linux" target)
>> + (string-prefix? "armhf-linux" target))
>
> This is a good case in point. There's a bug above: “armhf-linux” matches
> 32-bit ARM when building natively because that's what's in
> %current-target, but when cross-building %current-target-system will
> contain “arm-unknown-linux-gnueabihf” and this branch won't be taken.
>
> Using ‘target-arm32?’ avoids the bug.
Nice catch and good suggestion. Find a new version attached.
Greetings
Janneke
Comments
Jan Nieuwenhuizen <janneke@gnu.org> skribis:
>>From f013e88563f73a7513faa330c79eef2f653daf28 Mon Sep 17 00:00:00 2001
> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
> Date: Thu, 31 Dec 2020 18:25:21 +0100
> Subject: [PATCH core-updates v2 2/8] commencement: Add stage0-posix.
>
> Stage0-posix is a skeleton for bootstrapping all of Stage0 for POSIX systems.
> On x86-linux, from the 357-byte hex0-seed binary from the bootstrap-seeds, it
> builds hex0, kaem, hex1, catm, hex2, M0, cc_x86, M1, M2,
> get_machine, (mescc-tools), and M2-Planet.
>
> * gnu/packages/commencement.scm (stage0-posix): New variable.
[...]
> + (name "stage0-posix")
> + (version "1.4")
> + (source (bootstrap-origin
> + (origin
> + (method url-fetch)
> + (uri (string-append
> + "https://lilypond.org/janneke/guix/20220502/"
> + "stage0-posix-" version ".tar.gz"))
Same comment as earlier regarding ‘bootstrap-origin’ and the URL.
> + (supported-systems '("i686-linux" "x86_64-linux"
> + "arm-linux" "aarch64-linux"
> + "riscv64-linux"))
Woow. :-)
s/arm-linux/armhf-linux/
> + (native-inputs
> + `(("bootstrap-seeds" ,bootstrap-seeds)
> + ("mescc-tools"
> + ,(bootstrap-origin
> + (origin
> + (method url-fetch)
> + (uri (string-append
> + "https://lilypond.org/janneke/guix/20220502/"
> + "mescc-tools-" mescc-tools-version ".tar.gz"))
> + (sha256
> + (base32
> + "1xi6f48pf5bhajhfis189gpizxij7nbp1vzvsb1aafhz4skkiqvg")))))
> + ("m2-planet"
> + ,(bootstrap-origin
> + (origin
> + (method url-fetch)
> + (uri (string-append
> + "https://lilypond.org/janneke/guix/20220502/"
> + "M2-Planet-" m2-planet-version ".tar.gz"))
> + (sha256
> + (base32
> + "1xrn69sc5nz4hwaishqyrcidp1ncxwib9zswl45x378ddz3mmk7g")))))
> + ,@(%boot-gash-inputs)))
Here you can avoid ‘bootstrap-origin’ too and add mirror://gnu URLs.
The “new style” (with gexps) doesn’t work well with non-package inputs
in the sense that you cannot use ‘this-package-input’ to access them.
However, it might be simpler to not have them in ‘native-inputs’ and to
instead refer to them in the code, as in:
#~(begin
…
(invoke "tar" "xvf" #$mescc-tools)
…)
where:
(define mescc-tools
(origin …))
> + (synopsis "The initial bootstrap package, builds stage0 up to M2-Planet")
> + (description
> + "Starting from an 357-byte hex0 provided by the bootstrap-seeds,
> +stage0-posix builds hex0, kaem, hex1, catm, hex2, M0, cc_x86, M1,
> +M2, get_machine, (mescc-tools), and M2-Planet.")
Bonus points if you can make it a full sentence. :-)
(I feel ridiculous commenting on this on a patch series that’s this
important, but hey!)
Ludo’.
Ludovic Courtès writes:
Hi,
> Jan Nieuwenhuizen <janneke@gnu.org> skribis:
>
>>>From f013e88563f73a7513faa330c79eef2f653daf28 Mon Sep 17 00:00:00 2001
>> * gnu/packages/commencement.scm (stage0-posix): New variable.
> Same comment as earlier regarding ‘bootstrap-origin’ and the URL.
bootstrap-origin removed and URL changed to:
(uri (list
(string-append
"mirror://gnu/guix/mirror/"
"stage0-posix-" version ".tar.gz")
(string-append
"https://lilypond.org/janneke/guix/20220502/"
"stage0-posix-" version ".tar.gz")))
>
>> + (supported-systems '("i686-linux" "x86_64-linux"
>> + "arm-linux" "aarch64-linux"
>> + "riscv64-linux"))
>
> Woow. :-)
:-) Yeah, that will mean some work for us to come...
> s/arm-linux/armhf-linux/
Oops.
>> + (native-inputs
>> + `(("bootstrap-seeds" ,bootstrap-seeds)
>> + ("mescc-tools"
>> + ,(bootstrap-origin
>> + (origin
>> + (method url-fetch)
>> + (uri (string-append
>> + "https://lilypond.org/janneke/guix/20220502/"
>> + "mescc-tools-" mescc-tools-version ".tar.gz"))
>> + (sha256
>> + (base32
>> + "1xi6f48pf5bhajhfis189gpizxij7nbp1vzvsb1aafhz4skkiqvg")))))
>> + ("m2-planet"
>> + ,(bootstrap-origin
>> + (origin
>> + (method url-fetch)
>> + (uri (string-append
>> + "https://lilypond.org/janneke/guix/20220502/"
>> + "M2-Planet-" m2-planet-version ".tar.gz"))
>> + (sha256
>> + (base32
>> + "1xrn69sc5nz4hwaishqyrcidp1ncxwib9zswl45x378ddz3mmk7g")))))
>> + ,@(%boot-gash-inputs)))
>
> Here you can avoid ‘bootstrap-origin’ too and add mirror://gnu URLs.
Ok.
> The “new style” (with gexps) doesn’t work well with non-package inputs
> in the sense that you cannot use ‘this-package-input’ to access them.
>
> However, it might be simpler to not have them in ‘native-inputs’ and to
> instead refer to them in the code, as in:
>
> #~(begin
> …
> (invoke "tar" "xvf" #$mescc-tools)
> …)
>
> where:
>
> (define mescc-tools
> (origin …))
Ok. I put the mescc-tools and m2-planet in the initial let.
>> + (synopsis "The initial bootstrap package, builds stage0 up to M2-Planet")
>> + (description
>> + "Starting from an 357-byte hex0 provided by the bootstrap-seeds,
>> +stage0-posix builds hex0, kaem, hex1, catm, hex2, M0, cc_x86, M1,
>> +M2, get_machine, (mescc-tools), and M2-Planet.")
>
> Bonus points if you can make it a full sentence. :-)
I tried:
"Starting from the 357-byte hex0-seed binary provided by the
bootstrap-seeds, the stage0-posix package first builds hex0 and then all
the way up: hex1, catm, hex2, M0, cc_x86, M1, M2, get_machine (that's
all of MesCC-Tools), and finally M2-Planet."
> (I feel ridiculous commenting on this on a patch series that’s this
> important, but hey!)
(otoh, after putting in all this work, some polishing doesn't hurt, so:
thanks!)
Greetings,
Janneke
From f013e88563f73a7513faa330c79eef2f653daf28 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Thu, 31 Dec 2020 18:25:21 +0100
Subject: [PATCH core-updates v2 2/8] commencement: Add stage0-posix.
Stage0-posix is a skeleton for bootstrapping all of Stage0 for POSIX systems.
On x86-linux, from the 357-byte hex0-seed binary from the bootstrap-seeds, it
builds hex0, kaem, hex1, catm, hex2, M0, cc_x86, M1, M2,
get_machine, (mescc-tools), and M2-Planet.
* gnu/packages/commencement.scm (stage0-posix): New variable.
---
gnu/packages/commencement.scm | 110 ++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
@@ -306,6 +306,116 @@ (define bootstrap-seeds
M1, and M2-Planet.")
(license license:gpl3+)))
+(define stage0-posix
+ ;; The initial bootstrap package: no binary inputs except those from
+ ;; `bootstrap-seeds, for x86 a 357 byte binary seed: `x86/hex0-seed'.
+ (let ((mescc-tools-version "1.4.0")
+ (m2-planet-version "1.9.0"))
+ (package
+ (name "stage0-posix")
+ (version "1.4")
+ (source (bootstrap-origin
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://lilypond.org/janneke/guix/20220502/"
+ "stage0-posix-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1ammifkj33205qrpfm84yb1c99lwgbn4jsl1hd08aab8c9ffz6p4")))))
+ (supported-systems '("i686-linux" "x86_64-linux"
+ "arm-linux" "aarch64-linux"
+ "riscv64-linux"))
+ (native-inputs
+ `(("bootstrap-seeds" ,bootstrap-seeds)
+ ("mescc-tools"
+ ,(bootstrap-origin
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://lilypond.org/janneke/guix/20220502/"
+ "mescc-tools-" mescc-tools-version ".tar.gz"))
+ (sha256
+ (base32
+ "1xi6f48pf5bhajhfis189gpizxij7nbp1vzvsb1aafhz4skkiqvg")))))
+ ("m2-planet"
+ ,(bootstrap-origin
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://lilypond.org/janneke/guix/20220502/"
+ "M2-Planet-" m2-planet-version ".tar.gz"))
+ (sha256
+ (base32
+ "1xrn69sc5nz4hwaishqyrcidp1ncxwib9zswl45x378ddz3mmk7g")))))
+ ,@(%boot-gash-inputs)))
+ (build-system trivial-build-system)
+ (arguments
+ `(#:guile ,%bootstrap-guile
+ #:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils))
+ (let* ((bootstrap-seeds (assoc-ref %build-inputs "bootstrap-seeds"))
+ (mescc-tools (assoc-ref %build-inputs "mescc-tools"))
+ (m2-planet (assoc-ref %build-inputs "m2-planet"))
+ (source (assoc-ref %build-inputs "source"))
+ (tar (assoc-ref %build-inputs "bootar"))
+ (bash (assoc-ref %build-inputs "bash"))
+ (coreutils (assoc-ref %build-inputs "coreutils"))
+ (guile (assoc-ref %build-inputs "guile"))
+ (out (assoc-ref %outputs "out"))
+ (bindir (string-append out "/bin"))
+ (target (or ,(%current-target-system)
+ ,(%current-system)))
+ (stage0-cpu
+ (cond
+ ((or ,(target-x86-64?) ,(target-x86-32?))
+ "x86")
+ (,(target-arm?)
+ "armv7l")
+ (else
+ (error "stage0-posix: system not supported" target))))
+ (kaem (string-append "../bootstrap-seeds/POSIX/"
+ stage0-cpu "/kaem-optional-seed")))
+ (setenv "PATH" (string-append tar "/bin:"
+ coreutils "/bin:"
+ bash "/bin"))
+ (invoke "tar" "xvf" source)
+ (chdir (string-append "stage0-posix-" ,version))
+ (copy-recursively bootstrap-seeds "bootstrap-seeds")
+ (invoke "tar" "xvf" mescc-tools)
+ (rmdir "mescc-tools")
+ (symlink (string-append "mescc-tools-" ,mescc-tools-version)
+ "mescc-tools")
+ (invoke "tar" "xvf" m2-planet)
+ (rmdir "M2-Planet")
+ (symlink (string-append "M2-Planet-" ,m2-planet-version)
+ "M2-Planet")
+ (rmdir "M2libc")
+ (symlink "M2-Planet/M2libc" "M2libc")
+ (mkdir-p bindir)
+ (with-directory-excursion stage0-cpu
+ (with-output-to-file "mes-m2.kaem"
+ (lambda _ (display "")))
+ (with-output-to-file "mescc-tools-extra.kaem"
+ (lambda _ (display "")))
+ (invoke kaem "kaem.run"))
+ (with-directory-excursion "bin"
+ (install-file "hex2" bindir)
+ (install-file "M1" bindir)
+ (install-file "blood-elf" bindir)
+ (install-file "kaem" bindir)
+ (install-file "get_machine" bindir)
+ (install-file "M2-Planet" bindir))))))
+ (home-page "https://github.com/oriansj/stage0-posix/")
+ (synopsis "The initial bootstrap package, builds stage0 up to M2-Planet")
+ (description
+ "Starting from an 357-byte hex0 provided by the bootstrap-seeds,
+stage0-posix builds hex0, kaem, hex1, catm, hex2, M0, cc_x86, M1,
+M2, get_machine, (mescc-tools), and M2-Planet.")
+ (license license:gpl3+))))
+
(define %bootstrap-mes-rewired
(package
(inherit mes)
--
2.35.1