by michaelforney

michaelforney / cproc

C11 compiler (mirror)

189 Stars 9 Forks Last release: Not found Other 434 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

(mirrored on GitHub)

builds.sr.ht status

is a C11 compiler using QBE as a backend. It is released under the ISC license.

Several 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 C11 and can be built with any conforming C11 compiler.

The POSIX driver depends on POSIX.1-2008 interfaces, and the

requires a POSIX-compatible make(1).

At runtime, you will need QBE, an assembler, and a linker for the target system. Currently, my personal QBE branch is recommended, since it may address some issues that have not yet made it upstream. Since the preprocessor is not yet implemented, an external one is currently required as well.

Supported targets

All architectures supported by QBE should work (currently x86_64 and aarch64).

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



to create a
appropriate for your system. If your system is not supported by the configure script, you can create these files manually.
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

with the appropriate

If you don't have QBE installed, you can build it from the included submodule (NOTE: BSD users will need to use gmake here), then add it to your PATH so that the driver will be able to run it.

make qbe

Once this is done, you can build with




includes several other targets that can be used for bootstrapping. These targets require the ability to run the tools specified in
  • stage2
    : Build the compiler with the initial (
    ) output.
  • stage3
    : Build the compiler with the
  • bootstrap
    : Build the
    compilers, and verify that they are byte-wise identical.

What's missing

  • Digraph and trigraph sequences (6.4.6p3 and, will not be implemented).
  • Wide string literals (#35).
  • Variable-length arrays (#1).
  • volatile
    -qualified types (#7).
  • _Thread_local
    storage-class specifier (#5).
  • long double
    type (#3).
  • Inline assembly (#5).
  • Preprocessor (#6).
  • Generation of position independent code (i.e. shared libraries, modules, PIEs).

Mailing list

There is a mailing list at ~mcf/[email protected]. Feel free to use it for general discussion, questions, patches, or bug reports (if you don't have an sr.ht account).

Issue tracker

Please report any issues to https://todo.sr.ht/~mcf/cproc.


Patches are greatly appreciated. Send them to the mailing list (preferred), or as pull-requests on the GitHub mirror.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.