guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prototyping the full source bootstrap path


From: Jan Nieuwenhuizen
Subject: prototyping the full source bootstrap path
Date: Sun, 19 Nov 2017 23:31:50 +0100

Hi!

Now that MesCC starts to build TinyCC that starts to pass a large set of
the mescc C tests, it's time to get walking the bootstrap path.

Attached*) is my initial attempt for the full source bootstrap path in
GuixSD; to try it, do

    ./pre-inst-env guix build mes-boot
    ...
    /gnu/store/lj7h0s33qghgk4zw2nb133riz7xhara9-mes-boot-0.11-0.948dd79/bin/mes 
--help

The starting point is Jeremiah Orian's stage0 self hosting hex
assembler.  The binary seed of our bootstrap is made explicit in an
additional source download: stage0-seed (of ~400 bytes).  This binary
that is identical with it's ASCII source can be considered "source".

There are still many gaps in our full source bootstrap path to-be, I
"filled" these by adding additional binary seeds: mescc-tools-seed and
mes-seed.  We are working to remove these, that will take some time.

The mes-boot package needs a lot more work and tinycc-boot, gcc-boot
packages are still missing.

Greetings,
janneke


*) Or fetch branch wip-bootstrap: https://gitlab.com/janneke/guix

>From c64a0af956754a22a7900a96260b7615c62c14b1 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sun, 19 Nov 2017 10:03:43 +0100
Subject: [PATCH 1/3] gnu: Add stage0-boot.

* gnu/packages/mes.scm (stag0-boot): New variable.
---
 gnu/packages/mes.scm | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index dfa421177..1e3631a1e 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -19,6 +19,7 @@
 (define-module (gnu packages mes)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages gcc)
@@ -26,11 +27,85 @@
   #:use-module (gnu packages package-management)
   #:use-module (gnu packages perl)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix licenses)
   #:use-module (guix packages))
 
+(define-public stage0-boot
+ (let ((version "0.0.8")
+        (revision "0")
+        (commit "14843efa5ed13372b1ec32a76d19f27b3febab91"))
+  (package
+    (name "stage0-boot")
+    (version (string-append version "-" revision "." (string-take commit 7)))
+    (synopsis "Manually created initial hex programs for full source 
bootstrapping")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://gitlab.com/janneke/stage0";
+                                  "/repository/archive.tar.gz?ref="
+                                  commit))
+              (file-name (string-append name "-" version ".tar.xz"))
+              (sha256
+               (base32
+                "0ws5g4r1rnyfaxrnyqzh4qr3w2a3i3wljcc095rk897wi1xz23jz"))))
+    (native-inputs
+     `(("static-bash" ,@(assoc-ref %bootstrap-inputs "bash"))
+       ("bash" ,(search-bootstrap-binary "bash" (%current-system)))
+       ("tar" ,(search-bootstrap-binary "tar" (%current-system)))
+       ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
+       ("stage0-seed"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://gitlab.com/janneke/stage0-seed";
+                               "/repository/archive.tar.gz?ref="
+                               "87039121e9ab4d48e9bade513c6f328cc9968583"))
+           (file-name (string-append name "-seed" "-" version ".tar.xz"))
+           (sha256
+            (base32
+             "0m18mv825nykj738gg9il60xb8xxc4015ypxgimhygdqxx0n66bp"))))))
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((bash (assoc-ref %build-inputs "static-bash"))
+                (tar (assoc-ref %build-inputs "tar"))
+                (xz (assoc-ref %build-inputs "xz"))
+                (source (assoc-ref %build-inputs "source"))
+                (stage0-seed (assoc-ref %build-inputs "stage0-seed"))
+                (out (assoc-ref %outputs "out"))
+                (out/bin (string-append out "/bin")))
+           (setenv "PATH" (string-append bash "/bin:"
+                                         "../stage0-seed:"
+                                         tar "/bin:"
+                                         xz "/bin"))
+           (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
+           (mkdir-p "source")
+           (system* "tar" "--strip=1" "-C" "source" "-xvf" source)
+           (mkdir-p "stage0-seed")
+           (system* "tar" "--strip=1" "-C" "stage0-seed" "-xvf" stage0-seed)
+           (chdir "source")
+           (zero? (system (string-append
+"set -ex;"
+"mkdir -p " out/bin ";"
+"hex Linux\\ Bootstrap/hex.hex > " out/bin "/hex;"
+;; FIXME: exec-enable?
+;;"hex Linux\\ Bootstrap/exec_enable.hex > " out/bin "/exec_enable;"
+;;"exec_enable " out/bin "/hex"
+;;"exec_enable " out/bin "/exec_enable"
+"chmod +x " out/bin "/hex"
+)))))))
+    (description
+     "Stage0 is the initial stage of a full source bootstrapping process.  It
+contains hex0, the initial 400 byte self hosting hex assembler.  It also comes
+with a Knight VM that runs Forth and Lisp.")
+    (home-page "https://savannah.nongnu.org/projects/stage0/";)
+    (license gpl3+))))
+
 (define-public nyacc
   (package
     (name "nyacc")
-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

>From 700fc1d3f7ab451f1aca84cd06b02e3cca39eea8 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sun, 19 Nov 2017 11:35:59 +0100
Subject: [PATCH 2/3] gnu: Add mescc-tools-boot.

* gnu/packages/mes.scm (mescc-tools-boot): New variable.
---
 gnu/packages/mes.scm | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index 1e3631a1e..ef4d4a486 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -106,6 +106,102 @@ with a Knight VM that runs Forth and Lisp.")
     (home-page "https://savannah.nongnu.org/projects/stage0/";)
     (license gpl3+))))
 
+(define-public mescc-tools-boot
+ (let ((version "0.2")
+        (revision "0")
+        (commit "fbb9004499c533fd1df7270480a4ff9375ca1f55"))
+  (package
+    (name "mescc-tools-boot")
+    (version (string-append version "-" revision "." (string-take commit 7)))
+    (synopsis "Tools for the full source bootstrapping process")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://gitlab.com/janneke/mescc-tools";
+                                  "/repository/archive.tar.gz?ref="
+                                  commit))
+              (file-name (string-append name "-" version ".tar.xz"))
+              (sha256
+               (base32
+                "1m0syjc2f3pk5fl7msf0v8n7j29wh1bsma269sminp9wh7905m09"))))
+    (native-inputs
+     `(("static-bash" ,@(assoc-ref %bootstrap-inputs "bash"))
+       ("bash" ,(search-bootstrap-binary "bash" (%current-system)))
+       ("tar" ,(search-bootstrap-binary "tar" (%current-system)))
+       ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
+       ("stage0" ,stage0-boot)
+       ("mescc-tools-seed"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://gitlab.com/janneke/mescc-tools-seed";
+                               "/repository/archive.tar.gz?ref="
+                               "9ec08e82fe2cac94e776470afe1e6a6a59c79159"))
+           (file-name (string-append name "-seed" "-" version ".tar.xz"))
+           (sha256
+            (base32
+             "0liysc4gzsrmankfksd44wbr451sy3pf5c79y2bw74dcnjpx1df2"))))
+       ("mes-source" ,(package-source mes-boot))
+       ("mes-seed"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://gitlab.com/janneke/mes-seed";
+                               "/repository/archive.tar.gz?ref="
+                               "d53d5998666873a79fbd9b4f6742d11affa34b44"))
+           (file-name (string-append "mes-seed-0.11" ".tar.xz"))
+           (sha256
+            (base32
+             "00zk4vfxqjyy3x4s5bdx59zicfqvxyvsbb9mfs4zkwyka64flk34"))))))
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((bash (assoc-ref %build-inputs "static-bash"))
+                (tar (assoc-ref %build-inputs "tar"))
+                (xz (assoc-ref %build-inputs "xz"))
+                (source (assoc-ref %build-inputs "source"))
+                (mescc-tools-seed (assoc-ref %build-inputs "mescc-tools-seed"))
+                (mes-seed (assoc-ref %build-inputs "mes-seed"))
+                (mes-source (assoc-ref %build-inputs "mes-source"))
+                (out (assoc-ref %outputs "out"))
+                (out/bin (string-append out "/bin")))
+           (setenv "PATH" (string-append bash "/bin:"
+                                         "../mescc-tools-seed:"
+                                         tar "/bin:"
+                                         xz "/bin"))
+           (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
+           (mkdir-p "source")
+           (system* "tar" "--strip=1" "-C" "source" "-xvf" source)
+           (mkdir-p "mescc-tools-seed")
+           (system* "tar" "--strip=1" "-C" "mescc-tools-seed" "-xvf" 
mescc-tools-seed)
+           (mkdir-p "mes-source")
+           (system* "tar" "--strip=1" "-C" "mes-source" "-xvf" mes-source)
+           (mkdir-p "mes-seed")
+           (system* "tar" "--strip=1" "-C" "mes-seed" "-xvf" mes-seed)
+           (chdir "source")
+           (zero? (system (string-append
+"set -ex;"
+"mkdir -p " out/bin ";"
+"M1 --LittleEndian --Architecture=1 -f ../mes-source/stage0/x86.M1 -f 
../mescc-tools-seed/hex2.M1 > hex2.hex2;"
+"M1 --LittleEndian --Architecture=1 -f ../mes-source/stage0/x86.M1 -f 
../mes-seed/crt1.M1 > crt1.hex2;"
+"M1 --LittleEndian --Architecture=1 -f ../mes-source/stage0/x86.M1 -f 
../mes-seed/libc-mes+tcc.M1 > libc-mes+tcc.hex2;"
+
+"hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f 
../mes-source/stage0/elf32-header.hex2 -f crt1.hex2 -f libc-mes+tcc.hex2 -f 
hex2.hex2 -f ../mes-source/stage0/elf32-footer-single-main.hex2 > " out/bin 
"/hex2;"
+"chmod +x " out/bin "/hex2;"
+
+;; FIXME: MORTAL SIN HERE
+;; M1 cannot be bootstrapped yet
+"cp ../mescc-tools-seed/M1 " out/bin "/M1")))))))
+
+    (description
+     "Mescc-tools is a collection of tools for use in a full source
+bootstrapping process.  Currently consists of the M1 macro assembler and the
+hex2 linker.")
+    (home-page "https://github.com/oriansj/mescc-tools";)
+    (license gpl3+))))
+
+
 (define-public nyacc
   (package
     (name "nyacc")
-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

>From b7c5e34c0a2a298cb5f519249174d511f369a3c6 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sun, 19 Nov 2017 22:55:41 +0100
Subject: [PATCH 3/3] gnu: Add mes-boot.

* gnu/packages/mes.scm (mes-boot): New variable.
---
 gnu/packages/mes.scm | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/gnu/packages/mes.scm b/gnu/packages/mes.scm
index ef4d4a486..8a33ce8a5 100644
--- a/gnu/packages/mes.scm
+++ b/gnu/packages/mes.scm
@@ -201,6 +201,83 @@ hex2 linker.")
     (home-page "https://github.com/oriansj/mescc-tools";)
     (license gpl3+))))
 
+(define-public mes-boot
+ (let ((version "0.11")
+        (revision "0")
+        (commit "948dd793619ddd5d930deead082737d14db9674b"))
+  (package
+    (name "mes-boot")
+    (version (string-append version "-" revision "." (string-take commit 7)))
+    (synopsis "Scheme interpreter and C compiler for full source 
bootstrapping")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://gitlab.com/janneke/mes";
+                                  "/repository/archive.tar.gz?ref="
+                                  commit))
+              (file-name (string-append name "-" version ".tar.xz"))
+              (sha256
+               (base32
+                "1hcfaapq0lg9achkc4565glcy9i23ln7azashi7ncsdv9jy72hmr"))))
+    (build-system trivial-build-system)
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (native-inputs
+     `(("static-bash" ,@(assoc-ref %bootstrap-inputs "bash"))
+       ("bash" ,(search-bootstrap-binary "bash" (%current-system)))
+       ("tar" ,(search-bootstrap-binary "tar" (%current-system)))
+       ("xz"  ,(search-bootstrap-binary "xz" (%current-system)))
+       ("mescc-tools" ,mescc-tools-boot)
+       ("nyacc-source" ,(package-source nyacc))
+       ("mes-seed"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://gitlab.com/janneke/mes-seed";
+                               "/repository/archive.tar.gz?ref="
+                               "d53d5998666873a79fbd9b4f6742d11affa34b44"))
+           (file-name (string-append "mes-seed-0.11" ".tar.xz"))
+           (sha256
+            (base32
+             "00zk4vfxqjyy3x4s5bdx59zicfqvxyvsbb9mfs4zkwyka64flk34"))))))
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((bash (assoc-ref %build-inputs "static-bash"))
+                (mescc-tools (assoc-ref %build-inputs "mescc-tools"))
+                (tar (assoc-ref %build-inputs "tar"))
+                (xz (assoc-ref %build-inputs "xz"))
+                (source (assoc-ref %build-inputs "source"))
+                (mes-seed (assoc-ref %build-inputs "mes-seed"))
+                (out (assoc-ref %outputs "out"))
+                (out/bin (string-append out "/bin")))
+           (setenv "PATH" (string-append bash "/bin:"
+                                         mescc-tools "/bin:"
+                                         tar "/bin:"
+                                         xz "/bin"))
+           (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
+           (mkdir-p "source")
+           (system* "tar" "--strip=1" "-C" "source" "-xvf" source)
+           (mkdir-p "mes-seed")
+           (system* "tar" "--strip=1" "-C" "mes-seed" "-xvf" mes-seed)
+           (chdir "source")
+           (zero? (system (string-append
+"set -ex;"
+"mkdir -p " out/bin ";"
+"M1 --LittleEndian --Architecture=1 -f stage0/x86.M1 -f ../mes-seed/crt1.M1 > 
crt1.hex2;"
+"M1 --LittleEndian --Architecture=1 -f stage0/x86.M1 -f 
../mes-seed/libc-mes.M1 > libc-mes.hex2;"
+"M1 --LittleEndian --Architecture=1 -f stage0/x86.M1 -f ../mes-seed/mes.M1 > 
mes.hex2;"
+"hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f 
stage0/elf32-header.hex2 -f crt1.hex2 -f libc-mes.hex2 -f mes.hex2 -f 
stage0/elf32-footer-single-main.hex2 > " out/bin "/mes;"
+"chmod +x "  out/bin "/mes;"
+out/bin "/mes --version;")))))))
+    (description
+     "Mes [Maxwell Equations of Software] aims to create full source
+bootstrapping for GuixSD.  It consists of a mutual self-hosting [close to
+Guile-] Scheme interpreter prototype in C and a Nyacc-based C compiler in
+[Guile] Scheme.")
+      (home-page "https://gitlab.com/janneke/mes";)
+      (license gpl3+))))
+
+;;;
 
 (define-public nyacc
   (package
-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]