Discussion:
Mes 0.10 released
Jan Nieuwenhuizen
2017-09-10 20:29:22 UTC
Permalink
I am pleased to announce the release of Mes 0.10, representing 82
commits over 6 weeks. Mescc now compiles a bootstrappable-modified
TinyCC into a mes-tcc that in turn can successfully compile a trivial
C program.

* About

Mes[0] aims to create full source bootstrapping for GuixSD[1] as
part of the bootstrappable builds[2] project.

It currently consists of a mutual self-hosting [close to Guile-]
Scheme interpreter prototype in C and a Nyacc-based C compiler in
[Guile] Scheme. This C prototype will be rewritten in stage0[3]
M1 assembly (or possibly stage2 slow-LISP, or ...).

The Scheme interpreter prototype (mes.c) has a Garbage Collector,
a library of loadable Scheme modules-- notably Dominique Boucher's
LALR[4], Pre-R6RS portable syntax-case[5] with R7RS ellipsis, Matt
Wette's Nyacc[6], Guile's PEG[7] --and test suite just barely
enough to support a simple REPL (repl.mes) and simple C-compiler
(mescc.mes).

The simple C compiler can compile a modified TinyCC[8] that is
starting to work! A gcc-compiled tcc is known[9] to compile GCC.

Mes is inspired by The Maxwell Equations of Software: LISP-1.5[10]
-- John McCarthy page 13, GNU Guix's source/binary packaging
transparency and Jeremiah Orians's stage0 ~300 byte self-hosting
hex assembler.

* Download

git clone https://gitlab.com/janneke/mes

wget https://gitlab.com/janneke/mes/repository/archive.tar.gz?ref=v0.10 -O mes-0.10.tar.gz

Mes runs from the source tree and can also be built, packaged and
installed in Guix[SD] by the usual

guix package -f guix.scm

* Changes in 0.10 since 0.9
** Core
*** 2 new functions
logand, lognot.
** Mescc
*** Mes now includes M1 sources for full source bootstrapping up to tcc.
*** Mescc now depends on Nyacc 0.81.0.
*** Mescc now compiles a mes-tcc that compiles a trivial C to a running a.out.
*** Mescc now supports several (as used by tinycc) struct by value assignments.
*** Mescc now has _start in a separate crt1.c.
*** Mescc now supports initializer arithmetic.
*** Mescc now supports arrays of struct of arbitrary size.
*** Mescc now supports pointer arithmetic.
*** Mescc now defines __i386__, __linux__.
*** Mescc now supports --*p, ++*p.
*** Mescc now supports int foo[bar] = {baz,...}.
*** Mescc now supports \x00 in strings in M1.
*** Mescc now supports complex enum expressions. Thanks, rain1!
*** Mescc now supports short.
*** Mescc now supports foo.bar = foo.baz = bla.
*** Mescc now supports foo = bar < baz and comparison permutations.
*** Mescc now supports (anonymous) structs in unions.
*** Mescc now writes M1 strings if possible.
**** 2 improved mlibc functions
malloc, realloc.
**** 13 new mlibc functions
fclose, fgetc, fprintf, fwrite, memcpy, memmove, memset, snprintf, strcat,
strchr, strrchr, strtoull, vnsprintf.
**** 15 new tinycc-support tests
76-pointer-arithmetic.c, 77-pointer-assign.c, 78-union-struct.c,
79-int-array.c, 7a-struct-char-array.c, 7b-struct-int-array.c,
7c-dynarray.c, 7d-cast-char.c, 7e-struct-array-access.c,
7f-struct-pointer-arithmetic.c, 7g-struct-byte-word-field.c,
7h-struct-assign.c, 7i-struct-struct.c, 7j-strtoull.c,
7k-for-each-elem.c.
** Noteworthy bug fixes
*** Mescc has many fixes for foo.bar[baz], foo[bar].baz with ./-> permutations.
*** Many bugs and limitations in mescc have been fixed and removed.

Greetings,
janneke

[0] https://gitlab.com/janneke/mes
[1] https://www.gnu.org/software/guix
[2] http://bootstrappable.org
[3] https://github.com/oriansj/stage0
[4] https://github.com/schemeway/lalr-scm
[5] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
[6] https://www.nongnu.org/nyacc/
[7] https://www.gnu.org/software/guile/docs/master/guile.html/PEG-Parsing.html
[8] https://gitlab.com/janneke/tinycc
[9] https://lists.gnu.org/archive/html/tinycc-devel/2017-05/msg00103.html
[10] http://www.softwarepreservation.org/projects/LISP/book/LISP%25201.5%2520Programmers%2520Manual.pdf
--
Jan Nieuwenhuizen <***@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Arne Babenhauserheide
2017-09-11 17:14:53 UTC
Permalink
Post by Jan Nieuwenhuizen
I am pleased to announce the release of Mes 0.10, representing 82
commits over 6 weeks. Mescc now compiles a bootstrappable-modified
TinyCC into a mes-tcc that in turn can successfully compile a trivial
C program.
Nice! How big are your changes to TinyCC?

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
Jan Nieuwenhuizen
2017-09-11 17:29:38 UTC
Permalink
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
I am pleased to announce the release of Mes 0.10, representing 82
commits over 6 weeks. Mescc now compiles a bootstrappable-modified
TinyCC into a mes-tcc that in turn can successfully compile a trivial
C program.
Nice! How big are your changes to TinyCC?
About this big:

$ gl| head -30
6773110e lotsa debug printing
429e4366 bootstrappable: workaround mescc bugs.
5881b4cd bootstrap build scripts
2712a934 bootstrappable: struct by value assign.
54e9ae5b bootstrappable: constant pointer arithmetic.
10b7a57b bootstrappable: pointer arithmetic.
25f6dfa1 bootstrappable: mescc: use _start.
50af7c8c bootstrappable: gcc libraries, elf entry.
d783ec19 bootstrappable: uint16_t in struct on heap.
f0aed53b bootstrappable: nested foo ? bar : baz.
60a3181f bootstrappable: Complex field access.
13cc75c8 bootstrappable: str[r]chr (str, 0).
fc977c55 bootstrappable: sizeof *type.
2ed23278 bootstrappable: for (;;).
7ab3f511 bootstrappable: Multi-line strings.
871dc3bb bootstrappable: foo = bar = baz.
9413c474 bootstrappable: switch (*foo = *++bar).
a51c6757 bootstrappable: HAVE_BITFIELD.
ca8aa2f4 bootstrappable: HAVE_FLOAT
eff5bcf9 bootstrappable: char foo[][].
299e04fe bootstrappable: foo ()->bar.
cb487ef6 bootstrappable: Comma operator.
df8f57cf bootstrappable: Heterogeneous switch case.
4cd6da01 bootstrappable: Heterogeneous initializer list.
25d426a0 bootstrappable: Outline enums, structs, unions.

For details, see

[8] https://gitlab.com/janneke/tinycc

TinyCC uses (imho) unnecessarily complex C constructs. Therefore it is (imho)
not too well suited as a bootstrap dependency, at least not in an
unpatched state.

Pragmatically working towards a first full source boostrap success, I
have been patching TinyCC and simultaneously adding unfriendly
constructs to Mescc. So, not all patches are necessary (for Mescc) but
depending on what the TinyCC devs want we could take bootstrappability
even much further. Dunno ;-)

As long as we target TinyCC, I intend to try to upstream all patches
that Mescc needs. Much work to do.

janneke
--
Jan Nieuwenhuizen <***@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Arne Babenhauserheide
2017-09-11 22:08:18 UTC
Permalink
Post by Jan Nieuwenhuizen
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
I am pleased to announce the release of Mes 0.10, representing 82
commits over 6 weeks. Mescc now compiles a bootstrappable-modified
TinyCC into a mes-tcc that in turn can successfully compile a trivial
C program.
Nice! How big are your changes to TinyCC?
$ gl| head -30
6773110e lotsa debug printing
429e4366 bootstrappable: workaround mescc bugs.
5881b4cd bootstrap build scripts
2712a934 bootstrappable: struct by value assign.
54e9ae5b bootstrappable: constant pointer arithmetic.
10b7a57b bootstrappable: pointer arithmetic.
25f6dfa1 bootstrappable: mescc: use _start.
50af7c8c bootstrappable: gcc libraries, elf entry.
d783ec19 bootstrappable: uint16_t in struct on heap.
f0aed53b bootstrappable: nested foo ? bar : baz.
60a3181f bootstrappable: Complex field access.
13cc75c8 bootstrappable: str[r]chr (str, 0).
fc977c55 bootstrappable: sizeof *type.
2ed23278 bootstrappable: for (;;).
7ab3f511 bootstrappable: Multi-line strings.
871dc3bb bootstrappable: foo = bar = baz.
9413c474 bootstrappable: switch (*foo = *++bar).
a51c6757 bootstrappable: HAVE_BITFIELD.
ca8aa2f4 bootstrappable: HAVE_FLOAT
eff5bcf9 bootstrappable: char foo[][].
299e04fe bootstrappable: foo ()->bar.
cb487ef6 bootstrappable: Comma operator.
df8f57cf bootstrappable: Heterogeneous switch case.
4cd6da01 bootstrappable: Heterogeneous initializer list.
25d426a0 bootstrappable: Outline enums, structs, unions.
For details, see
[8] https://gitlab.com/janneke/tinycc
TinyCC uses (imho) unnecessarily complex C constructs. Therefore it is (imho)
not too well suited as a bootstrap dependency, at least not in an
unpatched state.
It still works with GCC, right?

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
Jan Nieuwenhuizen
2017-09-12 05:15:13 UTC
Permalink
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
I am pleased to announce the release of Mes 0.10, representing 82
commits over 6 weeks. Mescc now compiles a bootstrappable-modified
TinyCC into a mes-tcc that in turn can successfully compile a trivial
C program.
Nice! How big are your changes to TinyCC?
$ gl| head -30
6773110e lotsa debug printing
429e4366 bootstrappable: workaround mescc bugs.
5881b4cd bootstrap build scripts
2712a934 bootstrappable: struct by value assign.
..
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
For details, see
[8] https://gitlab.com/janneke/tinycc
TinyCC uses (imho) unnecessarily complex C constructs. Therefore it is (imho)
not too well suited as a bootstrap dependency, at least not in an
unpatched state.
It still works with GCC, right?
Yes. Luckily, GCC can still handle simple C constructs ;-)

When running i686-unknown-linux-tcc and mes-tcc to compile a trivial C
program, the output produced by `lotsa debug printing' from both
compiler runs is now identical, as is the resulting ELF binary.

janneke
--
Jan Nieuwenhuizen <***@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Arne Babenhauserheide
2017-09-12 17:08:56 UTC
Permalink
Post by Jan Nieuwenhuizen
Post by Arne Babenhauserheide
Post by Jan Nieuwenhuizen
For details, see
[8] https://gitlab.com/janneke/tinycc
TinyCC uses (imho) unnecessarily complex C constructs. Therefore it is (imho)
not too well suited as a bootstrap dependency, at least not in an
unpatched state.
It still works with GCC, right?
Yes. Luckily, GCC can still handle simple C constructs ;-)
When running i686-unknown-linux-tcc and mes-tcc to compile a trivial C
program, the output produced by `lotsa debug printing' from both
compiler runs is now identical, as is the resulting ELF binary.
That’s awesome!

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
Loading...