4 ms·
Does it support all of C? Is this actually smaller than TCC? It's kind of hard to tell since TCC is split into files and I don't know what's actually necessar
by Dylan16807 7y ago
Does it support all of C?
Is this actually smaller than TCC? It's kind of hard to tell since TCC is split into files and I don't know what's actually necessary. And that question includes earlier, less featureful versions of TCC. Note that the more-or-less-C compiler it's based off of is absolutely miniscule: https://bellard.org/otcc/ https://bellard.org/otcc/
- z29LiTp5qUC30n 7y agoit is less than 15kb in size written in assembly supports structs, unions, inline assembly, gotos, breaks, function pointers Thus it support more than otcc supported in a fraction of the size
- Dylan16807 7y agoThe file you linked is 200KB. OTCC is <4KB. It's admittedly using tiny names to squeeze under a size limit, but even when you correct for that it's a lot smaller. (Edit: At the time of submission the link went to https://github.com/oriansj/stage0/blob/master/Linux%20Bootstrap/x86/cc_x86.M1 https://github.com/oriansj/stage0/blob/master/Linux%20Bootst... with a description of "World's Smallest C Compiler")
- z29LiTp5qUC30n 7y agoYes that is the size of the source code with comments, the binary is less than 15KB
- Dylan16807 7y agoThat's significantly larger than the OTCC binary.
- z29LiTp5qUC30n 7y agoOTCC's binary is more than 22KB Thus OTCC is larger
- Dylan16807 7y ago...no it's not. The binary compiled by the elf version is 9KB.
- binarycrusader 7y agoIt's entirely possible you're both right -- different compilers and different environments will produce different results. So instead of arguing back and forth, it would be more helpful for others reading your comments if you provided full information about the conditions under which those sizes were achieved.
- Dylan16807 7y agoI'm talking about the official one linked on the page. The one that's self-compiled, so it shouldn't vary much if at all.
- oriansj 7y agoIs it really fair to do a size comparision between a statically linked C compiler written in Assembly and designed for readability with an a dynamically linked binary which has none of those things and was designed to win the International Obfuscated C Code Contest?? Also if you add up the binaries used via dynamic linking you are looking at which in the case of /lib/x86_64-linux-gnu/libc.so.6 is 16MB in size? Did I mention it works on all x86+amd64 POSIX systems too?
- Dylan16807 7y agoThe un-obfuscated version is commented and readable and still only ~15KB of source code. It uses calloc, fopen, and fgetc, which can trivially forwarded to the same syscalls as stage0 with only a few bytes. It uses isalnum, isspace, isdigit, strcpy, and strstr, which are all trivial. Add all that up and maybe you need to penalize it by a kilobyte. I'm not sure exactly how it's using dlsym but it seems to also be worth few bytes. It's not using the other 16MB of libc.
- derefr 7y agoI imagine that it doesn’t need to support all of C, so much as it needs to support enough of C to compile a more featureful C compiler. Which makes for a pertinent question: can you compile GCC or Clang with this?