2016-07-22 20:12:05 +00:00
|
|
|
-*-mode:org-*-
|
2016-10-10 21:24:44 +00:00
|
|
|
|
2017-04-02 15:01:29 +00:00
|
|
|
* SETUP
|
|
|
|
guix environment -l guix.scm #64 bit + 32bit
|
|
|
|
guix environment --system=i686-linux -l guix.scm #32 bit only
|
2017-05-28 16:32:53 +00:00
|
|
|
* BUILD
|
|
|
|
There are two major modes to build Mes: true bootstrap and
|
|
|
|
development.
|
|
|
|
|
|
|
|
** DEVELOPMENT BUILD
|
|
|
|
To help development we assume ./configure sets these variables for make
|
|
|
|
|
|
|
|
CC -- gcc
|
|
|
|
CC32 -- i686-unknown-linux-gnu-gcc (or on x86, also gcc)
|
|
|
|
GUILE -- guile
|
|
|
|
MES -- unset
|
|
|
|
|
|
|
|
Mes is supposed to serve as a full equivalent for GUILE, however mes is much, much
|
|
|
|
slower than guile. That's why we usually don't use mes during development.
|
|
|
|
|
|
|
|
gcc is used to verify the sanity of our C sources.
|
|
|
|
|
|
|
|
i686-unknown-linux-gnu-gcc is used to compare hex/assembly, to test
|
2017-06-03 10:11:57 +00:00
|
|
|
the gcc variant of mlbic: mlibc/libc-gcc.c and steal ideas.
|
2017-05-28 16:32:53 +00:00
|
|
|
|
|
|
|
guile is used to develop mescc, the C compiler in Scheme that during
|
|
|
|
bootstrapping will be executed by mes.
|
|
|
|
|
|
|
|
** BOOTSTRAP BUILD
|
|
|
|
In bootstrap mode, we don't have gcc (CC), we don't have pa 32 bit gcc
|
|
|
|
(CC32), we have no guile (GUILE)...but we should have a bootstrap mes
|
|
|
|
(MES). FIXME.
|
|
|
|
|
|
|
|
mes is built from src/*.c and some out/src/*.h files that are snarfed from
|
|
|
|
src/*.c by build-aux/mes-snarf.scm.
|
|
|
|
|
|
|
|
Also, during bootstrap we don't have make. Running `make build-scripts'
|
|
|
|
generates several recipies of sh build scripts in out/.
|
|
|
|
|
2017-03-29 06:05:18 +00:00
|
|
|
* ROADMAP
|
2017-04-02 15:01:29 +00:00
|
|
|
** TODO
|
|
|
|
*** release 0.x, unsorted
|
|
|
|
- discuss full source bootstrap strategy on guile-user with Jeremiah
|
|
|
|
Orians (stage0+) Luca Saiu (GNU Epsilon).
|
|
|
|
- fix bugs
|
2017-03-29 06:05:18 +00:00
|
|
|
- produce intermediate annotated assembly-like mes.S
|
2017-04-02 15:01:29 +00:00
|
|
|
- and/or: connect to OriansJ's stage0...LISP bootstrapping tools
|
|
|
|
- and/or: connect to GNU Epsilon's VM
|
|
|
|
- and/or: translate Mes.c interpreter into VM
|
|
|
|
- and/or: compile Scheme to C, rewrite Mes.c into Mes.scm.
|
2017-03-29 06:05:18 +00:00
|
|
|
- real module support, bonus for supporting Guile's define-module/define-public syntax
|
|
|
|
- get full source syntax-case up (Andre van Tonder?) OR drop
|
|
|
|
psyntax/syntax-case and rewrite Nyacc without syntax-case+R7RS Ellipsis
|
|
|
|
- support regexp OR rewrite Nyacc without regexps
|
|
|
|
- split-off Guile C compiler as standalone Guile project, still
|
|
|
|
respecting no-syntax-case bootstrap requirement
|
|
|
|
*** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
|
|
|
|
- build tcc (tinycc)
|
2017-04-02 15:01:29 +00:00
|
|
|
*** release 1.0
|
2017-03-29 06:05:18 +00:00
|
|
|
- work to replace GuixSD's bootstrap binaries for x86
|
|
|
|
- more architectures?
|
|
|
|
** DONE
|
2017-04-02 15:01:29 +00:00
|
|
|
** 0.5: Mutual self-hosting Scheme interpreter and C compiler: mes.c and mescc,
|
|
|
|
Support call-with-current-continuation, refactor catch/throw
|
2017-03-29 06:05:18 +00:00
|
|
|
** 0.4: Support Nyacc, Gcc-compiled Mes compiles minimal main.c using nyacc
|
|
|
|
** 0.3: Garbage collector
|
|
|
|
** 0.2: Support psyntax
|
|
|
|
** 0.1: Mes eval/apply feature complete; support syntax-rules, compile main.c using LALR, dump ELF
|
|
|
|
|
2016-12-24 16:22:34 +00:00
|
|
|
* Bugs
|
2017-04-02 15:01:29 +00:00
|
|
|
** eval_apply/gc + Nyacc bug
|
|
|
|
scripts/messc.mes intermittently exposes a bug in eval_apply/gc when
|
|
|
|
Nyacc parses mes.c-sized source. Running
|
|
|
|
|
|
|
|
MES_MAX_ARENA=<another-size> scripts/mescc.mes
|
|
|
|
|
|
|
|
may [un]cover the bug. So there is probably some eval_apply-construct
|
|
|
|
that Nyacc uses, possiblby indirectly via with-fluid, like (call/cc,
|
|
|
|
call-with-current-continuation), that breaks when GC triggers at the
|
|
|
|
wrong time.
|
|
|
|
** mescc can only compile itself, it cannot compile tcc, gcc or guile
|
|
|
|
** mes.mes cannot read sexps, only --dump's, mes.mes cannot --dump
|
|
|
|
** Bootstrap binary mes is too big and opaque to be considered source
|
|
|
|
68kB ELF binary which can be disassembled (objdump -d mes.mes).
|
|
|
|
** Psyntax is too big and opaque to be considered source
|
|
|
|
And needs a patched Guile-1.8 to [re]generate.
|
2017-04-01 13:06:07 +00:00
|
|
|
** test/match.test ("nyacc-simple"): hygiene problem in match
|
2017-04-02 15:01:29 +00:00
|
|
|
** Performance
|
|
|
|
*** mes is slow
|
|
|
|
*** The Scheme reader is very slow.
|
|
|
|
*** mescc is slow
|
|
|
|
**** compiling mes.c takes mescc.mes 2h30'
|
|
|
|
mescc.scm which runs on Guile takes 30"
|
2016-12-24 16:22:34 +00:00
|
|
|
** Fluids are a hack for Nyacc.
|
|
|
|
*** Translate C-prototype mes.c into annotated hex?
|
2017-01-22 13:16:22 +00:00
|
|
|
One idea is to use OriansJ's amazing self-hosting [[https://github.com/oriansj/stage0][stage0]] hex assembler
|
2016-10-15 09:54:24 +00:00
|
|
|
and minimal bootstrap binaries and rewrite the mes.c core to directly
|
|
|
|
bootstrap into Scheme.
|
|
|
|
|
2016-12-24 16:22:34 +00:00
|
|
|
*** Rewrite mes.c in Schemy/Sexp-C and generate annotated hex?
|
|
|
|
Another idea (thanks Rutger!) is to rewrite the mes.c core in a s-exp
|
2016-11-02 14:35:32 +00:00
|
|
|
C/Assembly variant and thave mescc produce the simple, annotated
|
2016-10-15 09:54:24 +00:00
|
|
|
bootstrap binary.
|
|
|
|
|
2016-12-24 16:22:34 +00:00
|
|
|
*** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
|
2016-10-16 12:00:40 +00:00
|
|
|
|
2017-04-02 15:01:29 +00:00
|
|
|
** Build tools do not run on mes
|
|
|
|
*** configure needs Bash, Guile
|
|
|
|
*** GNUmakefile needs Bash, Guile
|
|
|
|
*** build-aux/mes-snarf.scm needs Guile
|
|
|
|
*** build-aux/git-changelog needs Perl
|
2016-10-15 09:54:24 +00:00
|
|
|
* OLD: Booting from LISP-1.5 into Mes
|
2016-07-22 20:12:05 +00:00
|
|
|
|
|
|
|
Mes started out experimenting with booting from a hex-coded minimal
|
2016-10-15 09:54:24 +00:00
|
|
|
LISP-1.5 (prototype in mes.c), into an almost-RRS Scheme.
|
2016-07-22 20:12:05 +00:00
|
|
|
|
|
|
|
When EOF is read, the LISP-1.5 machine calls loop2 from loop2.mes,
|
|
|
|
which reads the rest of stdin and takes over control. The functions
|
|
|
|
readenv, eval and apply-env in mes.mes introduced define, define-macro
|
|
|
|
quasiquote and macro expansion.
|
|
|
|
|
|
|
|
While this works, it's amazingly slow. We implemented a full reader
|
|
|
|
in mes.c, which makes running mes:apply-env mes:eval somewhat
|
|
|
|
bearable, still over 1000x slower than running mes.c.
|
|
|
|
|
2016-10-15 09:54:24 +00:00
|
|
|
Bootstrapping has been removed and mes.c implements enough of RRS to
|
2016-07-22 20:12:05 +00:00
|
|
|
run a macro-based define-syntax and syntax-rules.
|
|
|
|
|
|
|
|
loop.mes and mes.mes are unused and lagging behind. Probably it's not
|
|
|
|
worth considering this route without a VM. GNU Epsilon is taking the
|
|
|
|
more usual VM-route to provide multiple personas. While that sounds
|
2016-10-15 09:54:24 +00:00
|
|
|
neat, Lisp/Scheme, bootstrapping and trusted binaries are probably not
|
|
|
|
in scope as there is no mention of such things; only ML is mentioned
|
|
|
|
while Guile is used for bootstrapping.
|
2016-07-22 20:12:05 +00:00
|
|
|
|
2016-10-15 09:54:24 +00:00
|
|
|
* Assorted ideas and info
|
2017-01-22 13:16:22 +00:00
|
|
|
** Using GDB on assembly/a.out
|
|
|
|
info registers
|
|
|
|
p/x $eax
|
|
|
|
p/x $edx
|
|
|
|
set disassemble-next-line
|
|
|
|
gdb-display-disassembly-buffer
|
|
|
|
b *0x804a79d
|
|
|
|
** Create memory dump with 32 bit Gcc compiled Mes
|
core: Always include reader.c, drop binary read-0-32.mo dependency.
* module/language/c99/compiler.mes (c99-input->full-ast): Remove
obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
(mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
[!MES_FULL]: Include reader.c.
(main) [!MES_FULL]: By default call load_env, only call bload_env
when --load is supplied. WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
(dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
module/mes/tiny-0-32.mo): Remove targets.
(CLEAN): Do not add them. Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.
2017-05-28 14:03:45 +00:00
|
|
|
make out/i686-unknown-linux-gnu-mes
|
|
|
|
out/i686-unknown-linux-gnu-mes --dump < module/mes/read-0.mes > module/mes/read-0-32.mo
|
2016-10-15 09:54:24 +00:00
|
|
|
** C parser/compiler
|
|
|
|
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
|
|
|
|
*** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
|
|
|
|
*** [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
|
|
|
|
*** [[http://www.t3x.org/subc/index.html][Sub C]]
|
|
|
|
*** [[https://groups.google.com/forum/#!topic/comp.lang.lisp/VPuX0VsjTTE][C intepreter in LISP/Scheme/Python]]
|
|
|
|
|
|
|
|
** C assembler/linker
|
|
|
|
*** [[http://www.tldp.org/HOWTO/Assembly-HOWTO/linux.html][Assembly HOWTO]]
|
|
|
|
*** ELF
|
|
|
|
7f 45 4c 46
|
|
|
|
*** [[http://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
|
|
|
|
*** [[http://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
|
2016-12-10 21:47:13 +00:00
|
|
|
** SC - c as s-expressions
|
|
|
|
sc: http://sph.mn/content/3d3
|
2016-10-15 09:54:24 +00:00
|
|
|
** RNRS
|
|
|
|
*** [[http://www.scheme-reports.org/][Scheme Reports]]
|
|
|
|
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-349.pdf][Scheme - Report on Scheme]]
|
|
|
|
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
** tiny schemes
|
|
|
|
http://forum.osdev.org/viewtopic.php?f=15&t=19937
|
|
|
|
|
|
|
|
http://www.stripedgazelle.org/joey/dreamos.html
|
|
|
|
http://armpit.sourceforge.net/
|
|
|
|
http://common-lisp.net/project/movitz/movitz.html
|
|
|
|
|
|
|
|
<civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
|
2017-03-29 06:05:18 +00:00
|
|
|
** Orians Jeremiah
|
|
|
|
<OriansJ> janneke: also, if you look at
|
|
|
|
https://github.com/oriansj/stage0/tree/master/stage2/High_level_prototypes
|
|
|
|
[the garbage collected lisp I implemented], if there are any pieces
|
|
|
|
I could add to finish off your mes lisp bootstrap just let me know
|
|
|
|
because I would be more than happy to do that :D
|
|
|
|
<janneke> OriansJ: that's what I'm hoping for, that our efforts can be
|
|
|
|
complementary and we can work together
|
|
|
|
*** lfam (~lfam@2601:47:4180:2ffb:7c05:17de:cf5f:23ef) has quit: Ping timeout:
|
|
|
|
246 seconds [00:22]
|
|
|
|
<janneke> exciting times! [00:23]
|
|
|
|
<janneke> OriansJ: i looked a few times and saw 'LISP empty', so thanks for
|
|
|
|
the pointer! [00:24]
|
|
|
|
<civodul> OriansJ, janneke: from that page, there's also:
|
|
|
|
https://web.archive.org/web/20160604035203fw_/http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
|
|
|
|
|
|
|
|
** C4/C500
|
|
|
|
https://web.archive.org/web/20160604041431/http://homepage.ntlworld.com/edmund.grimley-evans/cc500/cc500.c
|
|
|
|
https://github.com/rswier/c4/blob/master/c4.c
|
2017-04-02 15:01:29 +00:00
|
|
|
** Compilers for free
|
|
|
|
http://codon.com/compilers-for-free
|