
TCC – Tiny C Compiler - mutin-sa
http://tinycc.org/
======
buserror
I'm a huge fan of tcc. I use it on embedded systems -- a good trick is to pre-
process any headers you need via cpp preprocessor, 'compress' them in a single
file, and add your .c to that. That way you don't need to cart around all the
-dev packages etc.

The 'hidden gem' of tcc is libtcc (the backend), which you can use as a JIT
subsystem in your own code. For example I've written a full JIT translator for
simavr [0] like that. The code translates each AVR opcode into it's own little
piece of C, then compile the whole 'firmware' and runs it.

[0]:
[https://github.com/buserror/simavr/tree/wip/jit](https://github.com/buserror/simavr/tree/wip/jit)

------
xvilka
Updated version here:
[http://repo.or.cz/tinycc.git](http://repo.or.cz/tinycc.git)

~~~
r1ch
Oddly this updated version has worse code generation than the last official
release (at least on Windows). It uses 3 instructions just to push one arg to
a function call!

------
napsy
From the website: "[Note: I am no longer working on TCC. Check the mailing
list to get up to date information.]"

------
voltagex_
Previously:
[https://news.ycombinator.com/item?id=13249851](https://news.ycombinator.com/item?id=13249851)

I'm sure it's been posted more than that, though.

------
8sigma
Fabrice Bellard's projects always make it to the front page every time they
are posted.

~~~
senatorobama
What does he work on nowadays?

~~~
exikyut
Well, he made it possible to run Windows 2000 in JavaScript:
[https://bellard.org/jslinux/vm.html?url=https://bellard.org/...](https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/win2k.cfg&mem=192&graphic=1&w=1024&h=768)

It works by running QEMU inside Linux inside a modified JSLinux, and then
running Win2K inside QEMU.

JSLinux was modified to incorporate AMD's hardware-assisted virtualization
instructions/extensions, so that QEMU could use KVM. This means that actual
x86 emulation gets done in JavaScript layer, and you have (JavaScript
(JSLinux(QEMU)) <-> Win2K) instead of (JavaScript(JSLinux(QEMU(Win2K))))),
which would be... well I tried running Mini vMac (Mac 128K emulator) inside
Basilisk II (PowerPC Mac emulator) one day... it was pretty much unusable,
even though Classic Mac OS was designed for a 7.8MHz CPU.

So basically this wouldn't have been possible without implementing
virtualization. Despite the fact that said virtualization is actually fake,
and it's really emulation.

------
anilakar
Is its preprocessor compliant yet? Last time I checked, the P99 project page
said it fails to compile on tinycc.

~~~
swiley
Last time I tried it chokes compiling toybox too.

------
faragon
There are few C99 compliant compilers. In my opinion, TCC is a very good tool,
and deserves being maintained.

------
fithisux
It is a pitty that the QCC (QEMU Codegen) and TCC has not been materialized.

~~~
ajdlinux
Any more info about QCC?

edit: googled it, [https://www.landley.net/qcc/](https://www.landley.net/qcc/)

------
maxpert
I would love to see it on Github rather than somewhere else, more people can
engage and watch (Just saying)

~~~
pulse7
GitHub mirror:
[https://github.com/TinyCC/tinycc](https://github.com/TinyCC/tinycc)

~~~
jmh530
How would I go about creating a github mirror for some other project? I mean I
get that I can just upload the project as it is, but what if I want it so that
updates to the original are reflected automatically in the mirror?

~~~
carussell
Create a repo on GitLab where mirroring is in the default featureset, then
create a repo on GitHub, then create a hook so that when the GitLab mirror
pulls in new commits, it pushes those to the GitHub "mirror".

Or just question why you're doing this to begin with.

~~~
jmh530
Interesting.

The motivation to put up the mirror is that the creator of the original
project has no interest in changing his project to work with the languages'
package manager, but has endorsed others mirroring it. So I could mirror the
original project on Github and add the files needed for the languages' package
manager to work with it.

