[Top][All Lists]

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

Re: [Tinycc-devel] Using tinycc for full source bootstrapping

From: grischka
Subject: Re: [Tinycc-devel] Using tinycc for full source bootstrapping
Date: Sun, 24 Sep 2017 19:40:32 +0200
User-agent: Thunderbird (Windows/20090812)

I wonder which would be the smaller patch:  The changes you propose
for tcc or a patch to support these constructs as is in the bootstrap

Otherwise if that is not your criterion what would be the arguments
for the semantics that you mention that they do not belong to
"simple enough C"?

Of course from our point of view tcc IS a simple C compiler almost by
definition, so, since it can compile itself, it must be written in
already sufficiently simple C ;)

Also as source tcc is supposed to be C89, except maybe 'long long'
and maybe some minor things here or there which we could change
indeed if that is wanted (for example usage of compound initializers
in arm-gen.c)

-- gr

Jan Nieuwenhuizen wrote:

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

reply via email to

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