Store enum constant value in struct decl
Implement variable length arrays
qbe: Add extra size for strict alignment with QBE instruction
(mirrored on GitHub)
cproc
is a C11 compiler using QBE as a backend. It is released
under the ISC license.
Some C23 features and GNU C extensions are also implemented.
There is still much to do, but it currently implements most of the language and is capable of building software including itself, mcpp, gcc 4.7, binutils, and more.
It was inspired by several other small C compilers including 8cc, c, lacc, and scc.
The compiler itself is written in standard C99 and can be built with any conforming C99 compiler.
The POSIX driver depends on POSIX.1-2008 interfaces, and the Makefile
requires a POSIX-compatible make(1).
At runtime, you will need QBE, an assembler, and a linker for the target system. Since the preprocessor is not yet implemented, an external one is currently required as well.
All architectures supported by QBE should work (currently x86_64, aarch64, and riscv64).
The following targets are tested by the continuous build and known to bootstrap and pass all tests:
x86_64-linux-musl
x86_64-linux-gnu
x86_64-freebsd
aarch64-linux-musl
aarch64-linux-gnu
riscv64-linux-gnu
Run ./configure
to create a config.h
and config.mk
appropriate for
your system. If your system is not supported by the configure script,
you can create these files manually. config.h
should define several
string arrays (static char *[]
):
startfiles
: Objects to pass to the linker at the beginning of
the link command.endfiles
: Objects to pass to the linker at the end of the link
command (including libc).preprocesscmd
: The preprocessor command, and any necessary flags
for the target system.codegencmd
: The QBE command, and possibly explicit target flags.assemblecmd
: The assembler command.linkcmd
: The linker command.You may also want to customize your environment or config.mk
with the
appropriate CC
, CFLAGS
and LDFLAGS
.
Once this is done, you can build with
make
The Makefile
includes several other targets that can be used for
bootstrapping. These targets require the ability to run the tools
specified in config.h
.
stage2
: Build the compiler with the initial (stage1
) output.stage3
: Build the compiler with the stage2
output.bootstrap
: Build the stage2
and stage3
compilers, and verify
that they are byte-wise identical.volatile
-qualified types (#7).long double
type (#3).There is a mailing list at ~mcf/cproc@lists.sr.ht. Feel free to use it for general discussion, questions, patches, or bug reports (if you don't have an sr.ht account).
Please report any issues to ~mcf/cproc@todo.sr.ht.
Patches are greatly appreciated. Send them to the mailing list (preferred), or as pull-requests on the GitHub mirror.