• Stars
    star
    706
  • Rank 64,138 (Top 2 %)
  • Language
    C
  • License
    Other
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C11 compiler (mirror)

(mirrored on GitHub)

builds.sr.ht status

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.

Requirements

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.

Supported targets

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

Building

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

Bootstrap

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.

What's missing

  • Digraph sequences (6.4.6p3, will not be implemented).
  • Variable-length arrays (#1).
  • volatile-qualified types (#7).
  • 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 ~mcf/[email protected].

Contributing

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

More Repositories

1

samurai

ninja-compatible build tool written in C
C
819
star
2

swc

a library for making a simple Wayland compositor
C
620
star
3

velox

velox window manager
C
490
star
4

wld

A primitive drawing library targeted at Wayland
C
81
star
5

sbase

Portable UNIX tools (personal repository)
C
56
star
6

st

C
49
star
7

libtls-bearssl

libtls implemented on top of BearSSL
C
37
star
8

qbe

Personal branch of git://c9x.me/qbe.git
C
36
star
9

dmenu

C
22
star
10

blake3-tiny

Tiny public-domain implementation of BLAKE3
C
20
star
11

oscmix

Mixer for RME Fireface UCX II
C
19
star
12

base64

public-domain base64 implementation
C
16
star
13

x509cert

Tool and library for generating X.509 certificates and certificate requests (mirror)
C
14
star
14

musl

C
12
star
15

ubase

personal branch of git://git.suckless.org/ubase
C
11
star
16

wl9

rio-wayland shim server
C
10
star
17

pax

pax archive utility
C
9
star
18

nine

wine for 9
C
9
star
19

upnp-av

UPnP AV server
C
7
star
20

libblit

C
6
star
21

dnssec-rr

Tools for working with DNSSEC (mirror)
C
6
star
22

inverse_kinematics

CS184 Final Project - Inverse Kinematics Solver
Haskell
5
star
23

tinyemu

C
5
star
24

sdhcp

C
5
star
25

coreboot

My fork of coreboot supporting Opus M4
C
5
star
26

tridactyla

tridactyla's exherbo repository, moved to git.exherbo.org
4
star
27

gefs

personal gefs branch
C
3
star
28

perp

persistent process supervision (http://b0llix.net/perp/)
C
3
star
29

resample

Public-domain audio resampler
Objective-C
3
star
30

trickle

Trickle is an extensible frontend to various BitTorrent clients. It runs on all platforms supported by KDE4, and can connect to any server running a supported BitTorrent backend, like rTorrent and XmlRpc, or uTorrent and WebUI.
C++
3
star
31

intpack

Integer encoding/decoding functions
C
3
star
32

tridactyla-personal

Tridactyla's exherbo repository for personal projects
2
star
33

opus_m4

Coreboot configuration and rom utilities for Opus M4
Shell
2
star
34

one_astronaut

C
2
star
35

smileys

smileys plugin for velox
C
2
star
36

playground

An area where I can play around with stuff
C++
2
star
37

fspec-extfs

WIP fspec extfs image builder
C
2
star
38

miniyacc

Personal branch of git://c9x.me/miniyacc.git
Yacc
1
star
39

libwl

Wayland client implementation in Myrddin
Python
1
star
40

surf

C
1
star
41

binutils-gdb

Personal binutils branch
C
1
star
42

fm

FM-Net implementation (https://docs.formality-lang.org/en/latest/theory/Formality-Net.html)
C
1
star
43

bearssl-util

1
star
44

arbor

arbor with musl support
1
star