3 ms·
Nice hack! The next step would probably be a CC which compiles to a minimal virtual CPU instruction set so that we just need some Assembler macros to port it to
by progman 12y ago
Nice hack! The next step would probably be a CC which compiles to a minimal virtual CPU instruction set so that we just need some Assembler macros to port it to a native platform (x86, ARM, etc.), plus a library of formats (ELF etc.) to create applications for those platforms.
- vog 12y agoI believe this is how modern compilers work anyway. GCC as well as clang (via llvm) have multiple frontends (one for each programming language) and multiple backends (one for each target platform.)
- beagle3 12y agoThis was here just 3 days ago: https://news.ycombinator.com/item?id=8558822 https://news.ycombinator.com/item?id=8558822 ; Now, YOU just need to write those assumbler macros. But why? Are you in some shortage of working compilers?
- progman 12y ago> Are you in some shortage of working compilers? I am just interested in a small maintainable C compiler which can easily be adopted to bootstrap a new platform or cpu (on FPGA). I consider such a tiny C compiler just a convenient assembler to implement basic things on new platforms. I know GCC and Clang/LLVM but those tool chains are really big, and I guess it requires a lot of work to support a new platform and to polish all things so that everything works properly. A portable tiny GCC/LLVM replacement for small embedded systems would be really nice. GCC and Clang are great for powerful systems but I consider them overkill for small systems.
- qznc 12y agoDo you know the "portable c compiler" PCC? http://pcc.ludd.ltu.se/ http://pcc.ludd.ltu.se/
- progman 12y agoThanks! I will study it.
- MatzeBraun 12y agoMaybe cparser: https://github.com/MatzeB/cparser https://github.com/MatzeB/cparser
- beagle3 12y agoFabrice Bellard's "tiny cc"[0] is a great sweet spot between "not even a portable assembler" like CC500 and C4, and GCC/LLVM: It is a full-blown C compiler with enough extensions to compile the Linux kernel (and boot to it directly - look at the "tccboot" project). But it's also small enough and simple enough to retarget in a few days work (make that a few month if you want optimizations ... but you don't seem to). [0] http://bellard.org/tinycc http://bellard.org/tinycc