5 ms·
Tiny C Compiler
- drtse4 10y agoFor those who missed it like me, Fabrice just released a RISC-V emulator, HN discussion here: https://news.ycombinator.com/item?id=13210711 https://news.ycombinator.com/item?id=13210711
- FullyFunctional 10y agoNow there's a fun little Xmas break project: port tinycc to RISC-V. I don't expect it to be too hard. Extra credit for using the compressed instruction where possible.
- kashyapc 10y agoRelated: Based on the Tiny C Compiler, a demo program ('TCCBOOT', also from Fabrice) mentioned in the "News" section in the URL from the OP was part of the QEMU Advent calendar: http://www.qemu-advent-calendar.org/2016/#day-16
- agumonkey 10y agoI looked at the source thinking I could port it to newer kernels but .. alas it's way above my level.
- satysin 10y agoPerhaps it is above your level today but why not give it a shot anyway? You won't get to that level without pushing yourself.
- agumonkey 10y agoI gave it a shot, and it was way above my head. tccboot involves kernel trickery that Belliard himself wrote as not safe at all and just there to make it run a bit. I'm not even kernel developper level, I have no idea how I could migrate this to linux 3.x or 4.x.
- kashyapc 10y ago/me nods. While preparing that QEMU Advent image, I spent little (admittedly too little) time to see if I can get newer Kernels work with TCC, and quickly came to a somewhat similar conclusion. (While also realizing limits on my abilities - not a Kernel developer either). Also a quick look at the upstream tinycc-devel list tells me that, a patched 2.4.26 Kernel (32 bit) was still the latest compatible version with TCC -- https://lists.nongnu.org/archive/html/tinycc-devel/2015-11/msg00071.html https://lists.nongnu.org/archive/html/tinycc-devel/2015-11/m...
- agumonkey 10y agobrohug
- satysin 10y agoAt least you gave it a shot! There are loads of things I can't do but I almost always try a couple of times to push myself. Sometimes I find I really love it even though I suck at it and muddle through, sometime I just suck and find no enjoyment so move on quickly. But I always learn something new, either about myself or the technology or whatever it was I was looking into. I don't see any time spent on giving something I don't know a go as time wasted. Merry Christmas/Happy Holidays my HN-friend! Have a great end of 2016 and a happy and healthy start to 2017 :)
- justinsaccount 10y agoI used TCC a lot back in 2003 or so for schoolwork. I had an ancient pentium 1 thinkpad someone had given me that I used for all my programming assignments. TCC compile times were basically instantaneous for simple C programs, I remember using the `tcc -run` hasbbang feature too.
- agumonkey 10y agoAs mentioned above, there's tccboot which is live from source linux. It took between 5 and 10 seconds on my centrino laptop...
- deleted 10y ago[deleted]
- jamesu 10y agoI experimented with using TCC as an experimental native code compilation backend for a scripting language. Was pretty impressed how easy it was to embed compared to some other solutions I tried.
- chubot 10y agoInteresting, did your scripting language compile to C first? I'd be interested to see how you integrated TCC if it's available.
- buserror 10y agoCheck my other post: I've recently made a Atmel AVR translator to C and JIT compile it with libtcc. It's actually pretty trivial! https://github.com/buserror/simavr/tree/jit-wip https://github.com/buserror/simavr/tree/jit-wip
- jamesu 10y agoThe language had a fairly basic AST, was fairly C-Like, and used fairly basic programming constructs (e.g. at most functions are just a call into a dispatcher) so it translates reasonably well to C. Didn't pursue the project too far, so not really anything concrete to show. @buserror's project sounds like a better example with code.
- faragon 10y agoPlease add "(2013)" to the title. TCC is an amazing project, and very useful, as there are few multiplatorm "C99 enough" compliant compilers. Also, it is suitable for using C as scripting language (!) P.S. Fabrice Bellard is a genius.
- irascible 10y agoHe is a straight up genius.
- buserror 10y agoI'm a HUGE fan of TCC -- I've recently added a pretty cool feature to simavr: a way to translate the whole AVR core into 'C' and JIT compile it using libtcc (the backend of tcc). Result is amazing speed for emulation! https://github.com/buserror/simavr/tree/jit-wip https://github.com/buserror/simavr/tree/jit-wip
- marktangotango 10y agoThat's awesome, can you give a quick rundown here, or have you blogged about it? One question I have is around symbol resolution. Can the in memory piece of tcc compiled code see all the symbols in your program (ie the host exe) for example?
- buserror 10y agoI haven't posted about it yet, as I wanted to clean up the branch before I do, and I ran out of time; work to catch up and so on :-) libtcc is /massively/ clever, it will 'link back' to your (exported) ELF symbols automatically. Basically it links the piece of code to your current running process, with all it's libs etc. So if you have a function blob(int); in your main program, just call it from the C you generate, and it'll Just Works. For my own purpose, I decided to trim down the headers I would have to include in the generated C and made some sort of simpler 'trampoline', but it's not strictly necessary.
- ww520 10y agoThat's an ingenious way of doing JIT. TCC sounds like an amazing project, a complete performant compiler framework and runtime in a small package.
- dwheeler 10y agoTiny C compiler (tcc) is really cool. I used it as a test case in my diverse double-compiling (DDC) work to counter the trusting trust attack: http://www.dwheeler.com/trusting-trust/ http://www.dwheeler.com/trusting-trust/ There has been some continued development of tcc; the GitHub repository here has changes through April 2016: https://github.com/TinyCC/tinycc https://github.com/TinyCC/tinycc
- nickpsecurity 10y agoAnother I found doing research for human-verifiable builds was the LCC compiler. It's specifically designed to be easy to understand despite producing good performance. People that mentioned it said the authors spent around 10 years on it trying to achieve that goal. Full description is in the book they sell to recoup some of that investment. Worth looking into if you hadnt heard of it. https://en.m.wikipedia.org/wiki/LCC_(compiler) https://en.m.wikipedia.org/wiki/LCC_(compiler) Note: It's not FOSS but is free for personal use. Should be fine if used for DDC.
- cygx 10y agoThe github repo is just a mirror, development happens on repo.or.cz [1] [1] http://repo.or.cz/tinycc.git http://repo.or.cz/tinycc.git
- kzrdude 10y agoEh what, on the mob branch? Master untouched for three years.
- cygx 10y agoMob is the main development branch, open to all. Master is the release branch, and as no release has been cut for a couple of years, it is indeed rather stale. edit: If you want to get an idea about what happens in TCC-land, you should check out the mailing list archives [1], eg a recent-ish status update [2]. [1] http://lists.nongnu.org/archive/html/tinycc-devel/ http://lists.nongnu.org/archive/html/tinycc-devel/ [2] http://lists.nongnu.org/archive/html/tinycc-devel/2016-11/msg00032.html http://lists.nongnu.org/archive/html/tinycc-devel/2016-11/ms...
- spc476 10y agoI've been using TCC for a few years, and even wrote a Lua module (https://github.com/spc476/lua-conmanorg/blob/master/src/tcc.c https://github.com/spc476/lua-conmanorg/blob/master/src/tcc....) for it. I used that to write another Lua module to load modules written in C directly from source (https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.lua https://github.com/spc476/lua-conmanorg/blob/master/lua/cc.l...). I still consider this use more for experiments than production level. I've also used it to get something like closures for C.
- fithisux 10y agoIt is a pitty that qcc (tcc + qemu codegen) never took off.