-
Notifications
You must be signed in to change notification settings - Fork 17
zz note: self brain surgery
Sam Rushing edited this page May 11, 2017
·
2 revisions
If you're making significant changes to the compiler design, especially ones that impact the code in header.c, gc.c, etc... it can be pretty tricky to bootstrap your new design using the old one.
Here's one way to do it:
- make a 'tmphead' directory
- copy header.c, gc.c, pxll.h, rdtsc.h into it
- in tmphead, make a symbolic link to ../self
- in the top, build your new compiler using the old one: $ self/compile.o3 self/compile.scm
- cd tmphead
- ../self/compile ../self/compile.scm -c
- cd ..
- $ /usr/local/bin/clang -Itmphead/ self/compile.c -o self/compile.new
Now that there's a VM, self-neurosurgery can be done a little more safely by switching between the C and bytecode compilers. (Unless you're messing with the runtime, if so see the above).
$ self/compile self/compile.scm -b
$ vm/irkvm self/compile.byc self/compile.scm -b
You can continue to make 'dangerous' changes to the bytecode-compiled compiler, and then when you're feeling lucky, compile to C.
Also note that the Makefile target 'make safe' is careful to keep the last ten copies of the C binary.