-
Notifications
You must be signed in to change notification settings - Fork 1
/
RATIONAL
49 lines (28 loc) · 3.84 KB
/
RATIONAL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
My interest in implementing Knight ISA in Python is three fold:
* As an educational exercise to further my understanding of the https://bootstrappable.org effort and how to simulate a register machine.
* Create tooling for testing the well documented binary hex blobs in stage0 [0] and mescc-tools [1] . This includes the techniques of fuzzing [2] and diverse double compiling [3], the later of which will benefit from a Knight ISA implementation because stage0/stage2/cc_x86.s (x86 M2 compiler in Knight ISA assembler) can be compared against Linux\ Bootstrap/x86/cc_x86.M1 (x86 M2 compiler in x86 assembler). These kinds of tests are not a substitute for hand auditing that the hex 0/1/2 files co-respond to their assembler equivalents, but they'll provide empirical evidence.
* Leverage the amazing work of stage0 [0], mes [4], and the ongoing effort [5] to rewrite mes in M2 [6] to provide a portable bootstrap of the free world on platforms where a C compiler or Scheme is not available or trusted, where the architecture and/or linker formats of stage0 bootstraps, mescc-tools and m2-planet are incompatible, but where Python is still available for bootstrapping. This includes
i) Macintoshes from Mac OS X 10.2 onward that came with Python 2.2+, including Power Macs. (deprecated as of macOS 10.15, set to be out of the default install in a later release)
ii) Windows 10 releases that support a trusted version of CPython from the Microsoft store (now triggered by a python.exe available in default installs from 17763.0 [May 2n019] onward), including machines that ship in S mode (Windows store apps only). Windows is also interesting from a diverse double-compiling [3] perspective as these builds of CPython are compiled with Microsoft's C compiler (MSVC) which does not have GCC in its build heritage.
and
iii) Other exotic computers that may have Python such as SPARC machines running Solaris, GNU/Linux MIPS machines (Lemote), and PowerPC Amigas.
Implementing the Knight ISA and using these other projects won't provide a bootstrap path on its own. There would need to be something like stage0/stage2/cc_knight.s (M2 compiler written in knight ISA targeting knight ISA) or some other M2 to Knight ISA compiler as a way to compile M2-Planet to Knight ISA.
But, I don't expect the performance of interpreting a Knight ISA build of mescc (c compiler written in Scheme) in Python on an exotic old computer to be acceptable, even for a patient, one-time escape to the free world.
If the performance ends up unacceptable, I hope to have inspiration for my next bootstrap project, to write a Scheme compiler that compiles to stack-based virtual machines (easier than targeting register machines).
Once I bootstrap mescc from Python on exotic computers one way or another, I'd like to enable a quick escape to the free world. My idea, use mescc to build tccboot [7] [8] (which is for x86) using the mes modified tcc [9]. I could then move that to a compatible old x86 machine, have tccboot compile linux 2.4 on boot and have that execute and compile a userland where tcc-i386 is guided to bootstrap more. (including a GCC cross compiler targeting my original exotic equipment)
-----
Footnotes
[0] https://github.com/oriansj/stage0
[1] https://github.com/oriansj/mescc-tools
[2] https://en.wikipedia.org/wiki/Fuzzing
[3] Diverse-Double Compiling, David A. Wheeler, https://dwheeler.com/trusting-trust/
[4] https://www.gnu.org/software/mes/
[5] https://github.com/oriansj/mes-m2
[6] https://github.com/oriansj/m2-planet
[7] https://bellard.org/tcc/tccboot.html
[8] https://github.com/seyko2/tccboot
[9] https://gitlab.com/janneke/tinycc , see mes and wip-bootstrapable branches
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without any warranty.