github.com/zero9178/cld

A C99 compliant compiler

Open this visualization on its own page →

Contributors

1

Lines of Code

4,110

From

2019-02-19

To

2020-11-16

About zero9178/cld

cld is a C99-compliant compiler written in C++ that uses LLVM as its backend for code generation. The project features a custom-built frontend designed from scratch, with a command-line interface modeled after GCC. The compiler's architecture is modular, with each compilation phase cleanly separated and usable as a library, allowing developers to integrate individual components like the frontend or LLVM backend into their own projects.

The compiler currently targets x64 architecture on Windows and Linux, with ABI compatibility for other x64 operating systems. It has successfully compiled real-world projects including zlib and sqlite3 against both glibc and MinGW. The tool can be invoked similarly to GCC—for example, `cld -c test.c` produces object files—and the source code is structured to be easily embedded in other applications through CMake integration.

The project is still under active development with several planned improvements including better GCC command-line compatibility, linking capabilities, sysroot detection, enhanced preprocessor functionality, additional GCC extensions and builtins, and more complete debug information generation. It requires LLVM 12 as a dependency and supports C++17 with recent versions of Clang, GCC, and MSVC as build compilers.

Share this video