GitHub|Download|Report a bug Mucc Home|Documentation»Contributing

Contributing to Mucc

Bug reports and pull requests are welcome. The open issues are a good place to start.

Reporting a Bug

Open an issue with:

Testing

make -j test     # language, driver, error, assembler, linker and gdb tests
make t T=arith   # one of them: test/arith.c (T=errors.sh: test/errors.sh)
make -j check    # the tests and a short difftest, while working
make -j test-all # plus self-hosting, musl, the single binary, and cross-compiling
make difftest    # random programs, compared against gcc
make fuzz        # the same, without end (see Fuzzing)
make daily       # a day's start: fuzz finds, make check, speed, then fuzz
make bench       # the numbers in Performance

With -j the tests run at once. Each prints one line, and all it printed only if it fails.

The tests need gcc and glibc's headers (build-essential), since they also check --libc=system, and difftest compares against gcc. With gdb, qemu-user-binfmt and binutils-aarch64-linux-gnu installed they also cover debugging and ARM64.

The suite has test programs for the language with thousands of assertions, programs written from scratch for Linux, hundreds of checks of errors and warnings, and the assembler compared byte for byte with GNU as.

Differential Testing

make difftest N=2000 generates random programs with no undefined behavior, compiles each with mucc and with gcc, and compares what they print. Any difference is a bug. For ARM64, under qemu:

GCC='aarch64-linux-gnu-gcc -static' \
  MUCC='./mucc --target=aarch64-linux --libc=mucc' test/difftest.sh 2000

Fuzzing

make fuzz runs until Ctrl-C, and the next run starts where the last one stopped. Each bug it finds is a file in fuzz/, with a .txt that says what went wrong:

make fuzz             # mucc against gcc; a failure is shrunk by test/reduce.py
make fuzz MODE=arch   # mucc for x86-64 against mucc for ARM64, under qemu
make fuzz MODE=crash  # test/*.c broken at random: mucc must never crash or hang

To fix one, make the program in fuzz/ a test, fix mucc until it passes, and run make test-all. When fuzzing finds nothing, the bugs left are in what the generator can't make yet. Teach it one thing from the list at the top of test/gen_random.py, or test/mutate.py a new way to break code, and fuzz again.

Real Programs

test/thirdparty/*.sh each download a real program, build it with mucc and run its own test suite. On Ubuntu, Alpine, Fedora and CentOS 7, with no C compiler, binutils or C headers installed, CI has the single binary build zlib, Lua, Tcl, SQLite and mucc, and run their tests.

Sending a Change

A note on AI: it was used in this project to help automate tests and to write some of the comments that explain the logic.

License

Mucc is under the Mucc License, written by Dom-Yan, Mucc's creator. Anyone may read, use, change, share and sell Mucc, for any purpose, at no cost, under three rules:

The rules hold however the work is made, by hand or with an AI tool. Programs you compile with mucc are yours: the license puts no conditions on them, though mucc's headers and runtime end up inside them. Mucc 1.4.0 and earlier were released under the MIT License, and copies of those stay under it.

Contributions are accepted under the Mucc License. Every source file starts with its license header; a new file gets the same one.

Mucc started from Rui Ueyama's chibicc, and the parts that remain from it keep chibicc's MIT notice, in the license file. musl, in thirdparty/musl/, is MIT too.

Linux's headers, in thirdparty/linux-headers/, are GPL-2.0 WITH Linux-syscall-note. That note says programs that use the kernel through them aren't derived works of it, so they don't change the license of mucc or of the programs it builds.