There is the TCC. Adapting that would probably be a faster path to a full featured C compiler on esp32 than building up my xcc700. This is more of an educational sandbox project.
I would love to see how you handle variably-modified types, the way I retrofitted them onto chibicc never felt quite right, and I've never seen another non-gcc/clang compiler fully support noplate's VM type patterns.
Maybe I fill find the time to clean it up and make it public. But did not find VM-types difficult to implement, the type just depends on some run-time value, so at the point in time where the size expression is evaluated, one stores the result in a hidden variable which the type refers to.
What I found troublesome were not really the caching of array count, but when and where should the side effect be represented in AST, for example this one: https://godbolt.org/z/rcT1d8WWe the puts() call is a side effect for automatic variable but completely ignored for static variable.
Yes, it is a bit of mess. We started to make this more precise in the C standard when those expression have to be evaluated, but there are still issues. And when this is involved extensions there are more issues. I think in this example, such initializer would not be allowed in ISO C. I also fixed many bugs in GCC .
Right, Rust is more complex, and it is the complex bits that make it Rust. There are sure some shortcuts possible for starters, for example scope-based lifetimes like in early Rust versions, but still, to make it a worthwhile upgrade over C, it would take some intermediate representation, and definitely more than 700 lines.
There is a lively movement for coding in Rust for esp32, that works, just not on the device I think.
Thanks! That is just my small custom experimental mini shell. This project started as a retro DOS-like cyberdeck, and first thing I tried to run there was DOS programs, which is why it looks like that. Only got to COM files, when I learned about elf_loader, so I now focus on that. I might extract and release whatever is valuable/reusable in that shell later on.
Yeah, very cool. I was thinking about possibly porting it to risc-v and using it on my fpga based core. I was trying to build a monitor style shell, but C like environment would be very cool.
Porting to different CPU/bytecodes should be doable. Just keep in mind that in ESP-IDF we also get the dynamic linker and the libc for free (and any other C functions exposed in the firmware). On the other platforms, that may be some extra work for the compiler.
Thanks for posting this here. I star’d the project. Getting a portable computer with a minimal flexible and previously well supported operating system was one of my goals for the esp32 as well. I’ll be watching for more.
reply