tcc, tiny C compiler

Seth David Schoen <[email protected]> Sat, 14 May 2005 00:43:33 -0700
Newsgroups gmane.linux.bbc.devel
Message-ID <[email protected]>
This is really quite remarkable.

http://fabrice.bellard.free.fr/tcc/

This is a very fast C compiler that produces tiny executables.
Perhaps more remarkably, it allows you to use C as a scripting
language, by putting #!/usr/local/bin/tcc -run at the top of a
C program.

One possibility for building small binaries on an lnx-bbc image
would to to use tcc to compile them, and another possibility
would be to include the source code of these programs and make it
executable scripts.

schoen@gardner:~ $ cat hello.c
#!/usr/local/bin/tcc -run

int main(int argc, char *argv[]){

        int i;
        for (i=1; i<=10; i++)
                printf("hello %s %d\n", argv[1], i);
        for (i=0; i<5; i++) { putchar(getchar()); putchar('\t'); }
        putchar('\n');
        exit(0);
}
schoen@gardner:~ $ echo hello | ./hello.c world
hello world 1
hello world 2
hello world 3
hello world 4
hello world 5
hello world 6
hello world 7
hello world 8
hello world 9
hello world 10
h       e       l       l       o
schoen@gardner:~ $

At the very least, tcc is a C compiler small enough to be included
comfortably on the lnx-bbc disk without including a full gcc.  And
the binaries it produces are very small.

This is also very amazing:

http://fabrice.bellard.free.fr/tcc/tccboot.html

-- 
Seth David Schoen <[email protected]> | Very frankly, I am opposed to people
     http://www.loyalty.org/~schoen/   | being programmed by others.
     http://vitanuova.loyalty.org/     |     -- Fred Rogers (1928-2003),
                                       |        464 U.S. 417, 445 (1984)