warning: unfinished

The plan is a modern C11 compiler which can mostly work with Clang, GCC, and MSVC while also introducing some new ideas.

Why write a C compiler?

  • To improve the compile times on debug builds without sacrificing features like I would with TCC.
  • To test out my upcoming (and currently private) compiler backend.
  • To add some extensions to improve the workflow of C programmers.
  • Because I can.

How am I doing?

mostly aight, thanks for asking.

What are some cool new things?

One of my favorite new features are the live compiler (essentially an offline Godbolt but within a terminal) and the out of order declarations.

What architectures will you support?

I'll be starting with x64 but I plan on having Aarch64 support soon enough, it's mostly a matter of user-demand what other platforms I add though I probably won't be supporting anything with a segmented address space because I don't want to implement it.

What OSes will you support?

Ideally the essentials like Windows, Linux and MacOS but currently MacOS isn't setup and Linux has basic support (no live compiler)

Will it have optimizations?

It will eventually have a smart but non-aggressive optimizer but that's still a work in progress

What C extensions will you have?

I'll be supporting all the normal extensions such as:

  • pragma once
  • builtin bitmath (popcount, ffs, clz, ctz, etc)
  • __builtin_trap, __builtin_expect
  • x86 SIMD intrinsics
  • typeof
  • case ranges
  • computed goto

And some possibly novel extensions such as:

What's left?

It can currently compile programs using the subset of C it currently supports but it's still missing some essential details before it compiles any basic C program such as:

  • More tests
  • Bug fixes
  • Self hosting
  • Thread local
  • Atomics (halfway there)
  • MSVC extensions
  • GNU extensions
  • Proper Mac/Linux support

Sauce?

You can follow my development here

Recent Activity

&cuik I've been learning to parse LLVM bitcode, on the left is TB in it's flattened text form and on the right we have the disassembled LLVM bitcode, the goal being to eventually have a drop-in replacement for the llvm tool, llc, yes it does compile too (left is mine, right is LLVM, both unoptimized):

&cuik When im bored i toy around with TB's optimizer, in this example it's doing some dumb stuff with the regalloc but more importantly it folded the branch into a branchless select and that into a float max operation (in retrospect the code was slightly wrong but i fixed it :p)

&cuik Only a bit laggy :P, i'll be improving codegen on switch statements once i'm not up at 7am

&cuik a bit of GLSL parsing using the Cuik facilities along with some additional stuff, we winning :P (the qualifiers are being parsed, the dumper just doesn't show their results yet)

&cuik more stuff, we've got quads now so i can start on making the game logic in lua, ideally we get sword slashing tonight

&cuik ok we got a window showing up now, i had to fix some idiv bug because regalloc is lovely :P, time to make a GL2 context

&cuik Got the JIT to be able to call other functions, we can now printf from inside it

&cuik started work on the DLL side of libcuik, i'm calling libcuik from luajit using the fancy FFI and now i can introspect or compile C code from within lua, im hoping to setup a nice little library for this such that a lua project can easily embed C and call it when it needs performance or other C concerns. I purposefully made it error because if not it doesn't say anything lol

Cuik/TB can now emit EXEs directly, the feature is still early but it's almost capable of linking against libc. Here's a test of ciabatta compiling with the microsoft linker and the TBlink respectively. For the spall views you can see link.exe on the left and TBlink on the right. &cuik

&cuik started work on the user-friendly diagnostics option 🎉 , the idea being that some reporting methods play better with automated systems like editors but some play far better at removing the noise (there's both a highlighted options and caret version because colors aren't always available and i haven't decided on things yet). Compare this against the old way of dealing with these types of errors.

&cuik More debug info! this time i've got some basic support for structs

&cuik Guess who just got a little further into Codeview support in Cuik/TB! 🎉

&cuik Been making changes to the CLI, also the spinning triangle is doing as spinning triangles do... that's right, compile correctly

Getting closer to having parsed & type checked my entire compiler with itself 🥳, ignore the .cpp file, it won't be doing that one, instead i'll probably convert it to valid C file &cuik