[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Using tinycc for full source bootstrapping

From: Jan Nieuwenhuizen
Subject: [Tinycc-devel] Using tinycc for full source bootstrapping
Date: Sun, 24 Sep 2017 09:48:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)


Are you willing to consider discussing/taking patches that reduce the
variety and complexity of C constructs used in TinyCC source code?

I have a list of about 20 unpolished patches[0] for constructs like:
comma operator

-    p[0] = x & 255, p[1] = x >> 8 & 255;
+    p[0] = x & 255; p[1] = x >> 8 & 255;

or (heterogeneous) initialzer lists

-    uint8_t buf[1000], *p = buf;
+    uint8_t buf[1000];
+    uint8_t *p = buf;

or function return derefencing

-    v = tok_alloc(astr.data, astr.size - 1)->tok;
+    TokenSym *tk = tok_alloc(astr.data, astr.size - 1);
+    v = tk->tok;

or complex field access

-    return table_ident[v]->sym_define;
+    TokenSym *t = table_ident[v];
+    Sym *s = t->sym_define;
+    return s;

or even struct by value assign

-    vtop->type = *type;
+    memcpy (&vtop->type, type, sizeof (CType));

that allow tcc to be compiled with a simpler C compiler, so that in time
we could add to README something like

    - BOOTSTRAPPABLE!  Because tcc uses only a subset of C99 (C99--), it
    can be bootstrapped with a simple C compiler.

Knowing[1] that TinyCC can build Gcc (wow!) and building tcc is easier
than building gcc, it is a good candidate for use in a bootstrap path.

The past couple of months I have been working to bootstrap tcc using
mescc, a simple C compiler that can (almost) be bootstrapped from
source.  I have just released[2] Mes 0.10 which can compile a modified
version of mes-tcc, which can compile a trivial C program into a working

Much work will have to be done before mes-tcc will be able to build a
functional Gcc.  I would like to start by reducing the delta on tcc that
I'm carrying.

What do you think, is bootstrappable builds[4] something you would want
to support and what could C99-- look like?


[0] https://gitlab.com/janneke/tinycc/commits/wip-mescc
[1] https://lists.gnu.org/archive/html/tinycc-devel/2017-05/msg00099.html
[2] http://lists.gnu.org/archive/html/guile-user/2017-09/msg00027.html
[3] http://bootstrappable.org

Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]