MazuCC

A minimalist C compiler with x86_64 code generation

Github星跟蹤圖

MazuCC

MazuCC is a minimalist C compiler with x86_64 code generation.
It is intended to support partial C99 language features while keeping the code
as small and simple as possible.

Build

Run make to build:

$ make

MazuCC comes with unit tests. To run the tests, give "check" as an argument:

$ make check

MazuCC is known to work on both GNU/Linux and macOS.

Use MazuCC to compile C source:

$ ./mzcc  sample/nqueen.c

Alternatively, MazuCC accepts the stream from standard input. The equivalent
form for the above command is:

$ cat sample/nqueen.c, ./mzcc -

You will get the generated x86_64 assembly in AT&T syntax. The output can be
assembled and linked into a valid executable:

$ ./mzcc -o sample/nqueen.s sample/nqueen.c
$ gcc -no-pie -o sample/nqueen sample/nqueen.s

If MazuCC is compiled and executed on macOS, the above argument -no-pie
should be eliminated.

Reference output of MazuCC-compiled sample/nqueen:

Q . . . . . . .
. . . . Q . . .
. . . . . . . Q
. . . . . Q . .
. . Q . . . . .
. . . . . . Q .
. Q . . . . . .
. . . Q . . . .

Alternatively, you can dump internal abstract syntax tree:

echo 'struct {int x; char y; struct { int t; } z; } a;', ./mzcc --dump-ast -

The expected output in S-expression form:

(decl (struct (int)
              (char)
              ((struct (int)))) a)

Acknowledge

MazuCC is heavily inspired by 8cc.

License

MazuCC is freely redistributable under the BSD 2 clause license. Use of
this source code is governed by a BSD-style license that can be found in the
LICENSE file.

主要指標

概覽
名稱與所有者jserv/MazuCC
主編程語言C
編程語言Makefile (語言數: 4)
平台
許可證BSD 2-Clause "Simplified" License
所有者活动
創建於2019-04-21 19:45:22
推送於2020-10-09 03:11:18
最后一次提交2020-10-09 11:11:17
發布數0
用户参与
星數528
關注者數32
派生數66
提交數49
已啟用問題?
問題數10
打開的問題數5
拉請求數14
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?