The C compiler is mostly stable on RISC-V targets but is only designed for experienced programmers and can be a little rough around the edges, particularly as it’s mostly designed for system work instead of end user programs.
Current State
The compiler works well as an everyday tool for simple projects (and especially operating system development) but with many limitations, such as just crashing sometimes when it reaches some unexpected syntax. It doesn’t have optimisations and isn’t complete in terms of standards compliance, but does now have an impressive test setup as it’s used for developing the operating system.
History
The RISC-V code generation and many other features were developed anew for this product, but the compiler itself is based on some old and even older code:
Much of the original compiler code was taken from https://github.com/dorktype/LICE and I continued development from this codebase until it was able to compile itself, then added the RISC-V target and other features.
The C preprocessor code is even more ancient, and is based on DECUS CPP which has been around for decades (this legacy code is probably also used in many other preprocessors).
As well as developing code generation for the new RISC-V target I also added some features like support for typesafe vararg functions and OOP features, these will be documented as they stabilise (whereas core C features are very stable!).
CPU Targets
Code generation is supported for RISC-V targets, while limited support for x86-64/AMD64 is still usable. The legacy target will have some breakages compared to the RISC-V target, but should still work well enough to compile itself (the legacy target is not routinely tested).
I briefly considered an ARM port but found that RISC-V is simply a better platform to focus on supporting. ARM support can probably be implemented if someone pays for it, but isn’t a high priority for me.
Standard Options
The compiler supports most standard command line options.
Building Linux Programs
The compiler is generally preconfigured to work on Linux for RISC-V but will need a -I option pointing to the fakelibc directory to build against Linux libraries. This is because it doesn’t support the full range of features needed by some Linux system headers.
To compile a simple program hello.c on Linux, you would use a command line:
compilec -I /path/to/fakelibc hello.c -o hello