logoalt Hacker News

Tiny C Compiler

116 pointsby guerrillayesterday at 9:45 PM52 commentsview on HN

Comments

fjfaasetoday at 12:14 AM

The code of TCC (0.9.26) is kind hard to compile, I have discovered in the past year, while developing a minimal C compiler to compile the TCC sources [1]. For that reason, I have concluded that TCC is its own test set. It uses the constant 0x80000000, which is an edge case for if you want to print it as a signed integer only using 32-bit operators. There is a switch statement with an post-increment operator in the switch expression. There are also switch statements with fall throughs and with goto statements in the cases. It uses the ## operator where the result is the name of a macro. Just to name a few.

[1] https://github.com/FransFaase/MES-replacement

show 1 reply
RobotToastertoday at 1:36 AM

What advantage does this have over SDCC?

veltasyesterday at 11:48 PM

The unofficial repo continuing tcc has geoblocked the UK.

https://repo.or.cz/tinycc.git

show 1 reply
gnufxyesterday at 11:15 PM

Used in the impressive Guix bootstrap.

https://guix.gnu.org/manual/1.5.0/en/html_node/Full_002dSour...

show 1 reply
haunteryesterday at 10:42 PM

There is an actively maintained fork with RISC-V support and such

https://repo.or.cz/w/tinycc.git

https://github.com/TinyCC/tinycc

show 3 replies
pixelsorttoday at 1:12 AM

Currently striving towards my own TypeScript to native x86_64 physical compiler quine bootstrapped off of TCC and QuickJS. Bytecode and AST are there!

show 1 reply
kristianpyesterday at 11:09 PM

Does anyone use libtcc for a scripting language backend? Smaller and faster than llvm. You'd have to transpile to a C ast I imagine.

show 2 replies
asdefghyktoday at 12:02 AM

I recall, there where similar items back in late 70s and early 80s .

Tiny C, Small C are names I seem to recall, buts its very fuzzy - Not sure if they were compilers, may have been interpreters....

imwallytoday at 12:44 AM

Anyone know a good resource for getting started writing a compiler? I'm not trying to write a new LLVM, but being a "software engineer" writing web-based APIs for a living is leaving me wanting more.

show 3 replies
senfiajtoday at 12:39 AM

There is even smaller C compiler that fits within the 512 bytes https://xorvoid.com/sectorc.html

throwatdem12311yesterday at 10:47 PM

This was the compiler I was required to use for my courses in university. GCC was forbidden. The professor just really liked tcc for some reason.

show 3 replies
pbohunyesterday at 10:46 PM

There also is an unofficial mirror which has updates.

https://github.com/TinyCC/tinycc

show 1 reply
rustyhancockyesterday at 10:26 PM

What a blast from the past TCC!

Sad but not surprised to see it's no longer maintained (8 years ago!).

Even in the era of terabyte NVMe drives my eyes water when I install MSVC (and that's usually just for the linker!)

show 4 replies
olivia-banksyesterday at 11:11 PM

TCC is fantastic! I use it a lot to do fast native-code generation for language projects, and it works really really well.

kimixayesterday at 11:08 PM

Man I can't wait for tcc to be reposted for the 4th time this week with the license scrubbed and the comment of "The Latest AI just zero-shotted an entire C compiler in 5 minutes!"

show 5 replies
markus_zhangyesterday at 11:27 PM

I mixed it up with LCC which was used in Quake 3. Still this is pretty cool.

deividyesterday at 10:49 PM

TCC is fantastic! Very hackable, easy to compile to WASM for some interesting in-browser compilation

show 1 reply
MarginalGainzyesterday at 11:59 PM

[dead]