1 Subject: on bootstrapping: 2nd status report on Mes
2 Date: Sun, 25 Sep 2016 13:52:11 +0200
6 In June I announced[0] Mes as a project that seeks to reduce the size of/
7 dependency on bootstrap binaries, esp. for a system like GuixSD
9 The strategy was to create a minimal trusted binary (prototyped in C but
10 eventually to be hand-crafted in assembly/hex) that interpets a minimal
11 LISP. Then using this minimal but already convenient LISP, extend it
12 into Scheme and write a tiny C compiler/linker.
14 Last time I had a minimal LISP-1.5-resembling interpreter in 900 lines
15 of C that could interpret itself and an extension layer written in LISP
16 providing a minimal Scheme environment. I was stuck on adding macros in
17 LISP and had a broken macro implentation in C that I wanted to remove.
18 Also I hoped to greatly reduce the size of the C part.
22 * Provide Scheme primitives directly in 1400 lines of C
23 * Remove LISP-1.5 staging
24 * closures clue-bat, fixing bugs in begin, lambda, lexical
25 scoping etc. ... learned a lot!
26 * quasiquote, unquote, unquote-splicing (in C, too slow in Scheme)
28 * define-syntax, syntax-rules (in Scheme, using define-macro)
29 * all primitives needed to run LALR (strings, vectors, records,
30 some srfi bits; mostly in Scheme)
31 * test suite with 97 tests that run with Mes and also with Guile
32 * minimal and partial ANSI C parser for hello world
33 * minimal and simplistic 32 bit elf c-ast->elf generator
35 Mes can now create a running 32-bit elf binary from this hello
36 world C source with a simplistic for loop
42 for (i = 0; i < 4; ++i)
43 puts (" Hello, world!\n");
47 It takes Mes 1'20" to compile this program, Guile takes 0.5 seconds.
49 * cannot get psyntax.pp hooked-up or running
50 * do not understand syntax stuff [well enough] to implement in C
51 -> no let-syntax, no MATCH
52 -> no syntax-case, no PEG parser
54 In theory the bootstrapping problem I set out to solve seems to be
55 cracked. The remaining problem is reduced to `just work':
56 implementing a minimal C compiler in Scheme. Questions here: I'm not
57 convinced yet that this is a meaningful project...aaand I really not
58 want to tackle this without having MATCH, which Mes does not have yet.
60 Of the possible directions that I see
62 0 write the C compiler in Scheme without match
63 1 rewrite match without let-syntax
64 2 grok+write let-syntax/syntax-case using define-macro, some bits in C
65 3 run and hook-up psyntax.pp...BUT that would probably require:
66 4 address performance problem, possibly by
67 5 rewrite Mes into a VM-based solution
69 none I find really attractive. Option 5, a VM is proven to work but
70 that's quite a change of direction. Looking at other VM-based projects
71 (e.g. GNU Epsilon[2]) I fear that this must result in a much larger code
72 base in C, throwing out the minimal trusted binary idea. The other
73 puzzles and work 0, 2 or 3 still need to be done.
75 However, diving into syntax-macro or eval work (2 or 3) most probably
76 needs the performance issue addressed. And if it turns out that a big
77 VM solution is needed, that may still invalidate this project after
78 having done even more work.
85 [0] https://lists.gnu.org/archive/html/guile-user/2016-06/msg00061.html
86 [1] https://gitlab.com/janneke/mes
87 [2] http://git.savannah.gnu.org/cgit/epsilon.git