Skip to content

xtao/c

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A smaller, faster C compiler suite.

Join the chat at https://gitter.im/andrewchambers/c

  • Fast.
  • Consistent.
  • Small.
  • High quality.
  • Low complexity.
  • No dependencies.
  • No fussy configuration.
  • Painless cross compiling.
  • Just work.

You should be able to get a C compiler, assembler, linker and libc for any supported target in less than 30 seconds just by typing make...

Building

Requires an external C compiler and gnu binutils (for now).

$ make

Testing

$ bash test.sh

Plan

Stage 1.

Self hosting x86_64, dumb backend.

Stage 2.

Self hosting arm, something like raspberry pi/android.

Stage 3.

Build small clean C code bases like 8cc, tcc, sbase.

Stage 4.

Build musl libc.

Beyond.

  • Build more programs.
  • Replace gnu as with our own assembler.
  • Replace ld with our own static linker.
  • Build OS kernels.
  • SSA backend.

Status

Pre stage 1.

See tests for what works.

Contributing

Contributors welcome, preferrably discuss on gitter before starting something. Even contributing self contained test cases is useful.

Code layout

  • Libraries are in src/*
  • Commands are in src/cmd/*

If you are unsure about the purpose of a library, check the header which should give a short description.

Code style

Follow Plan9 style conventions. Headers are not allowed to include other headers to eliminate circular dependencies and increase build speed. src/u.h is the only exception to this rule.

Bug fixes and issues

Try and attach a single source file which exibits your issue. If possible reduce the test case by hand until it is as small as possible.

Try and follow the general template changed where needed:

What are you trying to do:

I am trying to compile foo.c and your compiler has ruined my life by deleting all 
my files.

What you expected to happen:

The program works in many other C compilers, so should compile with no issue.

What actually hapened:

/ was deleted while the compiler printed "hahaha" many thousands of times.

Here is a small self contained file which reproduces the issue.

In general each bug fix or change should add a test file which triggers the bug.

Commit messages

General style:

Fix issue #3 post increment.

Post increment had a bug where it decremented instead of incremented.

Commits can be squashed to increase clarity.

Memory management

The compiler assumes a conservative garbage collector. For now, the header is stubbed out. This simplifies the code.

Useful Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.5%
  • Makefile 1.1%
  • Shell 0.4%