[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74663":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":13,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},74663,"claudes-c-compiler","anthropics\u002Fclaudes-c-compiler","anthropics","Claude Opus 4.6 wrote a dependency-free C compiler in Rust, with backends targeting x86 (64- and 32-bit), ARM, and RISC-V, capable of compiling a booting Linux kernel.",null,"Rust",2704,231,31,49,0,3,7,9,71.7,"Creative Commons Zero v1.0 Universal",false,"main",[],"2026-06-12 04:01:15","# CCC — Claude's C Compiler\n\nA C compiler written entirely from scratch in Rust, targeting x86-64, i686,\nAArch64, and RISC-V 64. Zero compiler-specific dependencies — the frontend,\nSSA-based IR, optimizer, code generator, peephole optimizers, assembler,\nlinker, and DWARF debug info generation are all implemented from scratch.\nClaude's C Compiler produces ELF executables without any external toolchain.\n\n> Note: With the exception of this one paragraph that was written by a human, 100% of the code and documentation in this repository was written by Claude Opus 4.6. A human guided some of this process by writing test cases that Claude was told to pass, but never interactively pair-programmed with Claude to debug or to provide feedback on code quality. As a result, I do not recommend you use this code! None of it has been validated for correctness. Claude wrote this exclusively on a Linux host; it probably will not work on MacOS\u002FWindows — neither I nor Claude have tried. The docs may be wrong and make claims that are false. See [our blog post](https:\u002F\u002Fanthropic.com\u002Fengineering\u002Fbuilding-c-compiler) for more detail.\n\n## Prerequisites\n\n- **Rust** (stable, 2021 edition) — install via [rustup](https:\u002F\u002Frustup.rs\u002F)\n- **Linux host** — the compiler targets Linux ELF executables and relies on\n  Linux system headers \u002F C runtime libraries (glibc or musl) being installed\n  on the host\n- For cross-compilation targets (ARM, RISC-V, i686), the corresponding\n  cross-compilation sysroots should be installed (e.g.,\n  `aarch64-linux-gnu-gcc`, `riscv64-linux-gnu-gcc`)\n\n## Building\n\n```bash\ncargo build --release\n```\n\nThis produces five binaries in `target\u002Frelease\u002F`, all compiled from the same\nsource. The target architecture is selected by the binary name at runtime:\n\n| Binary | Target |\n|--------|--------|\n| `ccc` | x86-64 (default) |\n| `ccc-x86` | x86-64 |\n| `ccc-arm` | AArch64 |\n| `ccc-riscv` | RISC-V 64 |\n| `ccc-i686` | i686 (32-bit x86) |\n\n## Quick Start\n\nCompile and run a simple C program:\n\n```bash\n# Write a test program\ncat > hello.c \u003C\u003C 'EOF'\n#include \u003Cstdio.h>\nint main(void) {\n    printf(\"Hello from CCC!\\n\");\n    return 0;\n}\nEOF\n\n# Compile and run (x86-64)\n.\u002Ftarget\u002Frelease\u002Fccc -o hello hello.c\n.\u002Fhello\n\n# Cross-compile for AArch64 and run under QEMU\n.\u002Ftarget\u002Frelease\u002Fccc-arm -o hello-arm hello.c\nqemu-aarch64 -L \u002Fusr\u002Faarch64-linux-gnu .\u002Fhello-arm\n```\n\nCCC works as a drop-in GCC replacement. Point your build system at it:\n\n```bash\n# Build a project with make\nmake CC=\u002Fpath\u002Fto\u002Fccc-x86\n\n# Build a project with CMake\ncmake -DCMAKE_C_COMPILER=\u002Fpath\u002Fto\u002Fccc-x86 ..\n\n# Build a project with configure scripts\n.\u002Fconfigure CC=\u002Fpath\u002Fto\u002Fccc-x86\n```\n\n## Usage\n\n```bash\n# Compile and link\nccc -o output input.c                # x86-64\nccc-arm -o output input.c            # AArch64\nccc-riscv -o output input.c          # RISC-V 64\nccc-i686 -o output input.c           # i686\n\n# GCC-compatible flags\nccc -S input.c                       # Emit assembly\nccc -c input.c                       # Compile to object file\nccc -E input.c                       # Preprocess only\nccc -O2 -o output input.c            # Optimize (accepts -O0 through -O3, -Os, -Oz)\nccc -g -o output input.c             # DWARF debug info\nccc -DFOO=1 -Iinclude\u002F input.c       # Define macros, add include paths\nccc -Werror -Wall input.c            # Warning control\nccc -fPIC -shared -o lib.so lib.c    # Position-independent code\nccc -x c -E -                        # Read from stdin\n\n# Build system integration (reports as GCC 14.2.0 for compatibility)\nccc -dumpmachine     # x86_64-linux-gnu \u002F aarch64-linux-gnu \u002F riscv64-linux-gnu \u002F i686-linux-gnu\nccc -dumpversion     # 14\n```\n\nThe compiler accepts most GCC flags. Unrecognized flags (e.g., architecture-\nspecific `-m` flags, unknown `-f` flags) are silently ignored so `ccc` can\nserve as a drop-in GCC replacement in build systems.\n\n### Assembler and Linker Modes\n\nBy default, the compiler uses its **builtin assembler and linker** for all\nfour architectures. No external toolchain is required. You can verify this\nwith `--version`, which shows `Backend: standalone` when using the builtin\ntools.\n\nTo build with optional GCC fallback support (e.g., for debugging), enable\nCargo features at compile time:\n\n```bash\n# Build with GCC assembler and linker fallback\ncargo build --release --features gcc_assembler,gcc_linker\n\n# Build with GCC fallback for -m16 boot code only\ncargo build --release --features gcc_m16\n```\n\n| Feature | Description |\n|---------|-------------|\n| `gcc_assembler` | Use GCC as the assembler instead of the builtin |\n| `gcc_linker` | Use GCC as the linker instead of the builtin |\n| `gcc_m16` | Use GCC for `-m16` (16-bit real mode boot code) |\n\nWhen compiled with GCC fallback features enabled, `--version` shows which\ncomponents use GCC (e.g., `Backend: gcc_assembler, gcc_linker`).\n\n## Status\n\nThe compiler can build real-world C codebases across all four architectures,\nincluding the Linux kernel. Projects that compile and pass their test suites\ninclude PostgreSQL (all 237 regression tests), SQLite, QuickJS, zlib, Lua,\nlibsodium, libpng, jq, libjpeg-turbo, mbedTLS, libuv, Redis, libffi, musl,\nTCC, and DOOM — all using the fully standalone assembler and linker with no\nexternal toolchain. Over 150 additional projects have also been built\nsuccessfully, including FFmpeg (all 7331 FATE checkasm tests on x86-64 and\nAArch64), GNU coreutils, Busybox, CPython, QEMU, and LuaJIT.\n\n### Known Limitations\n\n- **Optimization levels**: All levels (`-O0` through `-O3`, `-Os`, `-Oz`) run\n  the same optimization pipeline. Separate tiers will be added as the compiler\n  matures.\n- **Long double**: x86 80-bit extended precision is supported via x87 FPU\n  instructions. On ARM\u002FRISC-V, `long double` is IEEE binary128 via\n  compiler-rt\u002Flibgcc soft-float libcalls.\n- **Complex numbers**: `_Complex` arithmetic has some edge-case failures.\n- **GNU extensions**: Partial `__attribute__` support. NEON intrinsics are\n  partially implemented (core 128-bit operations work).\n- **Atomics**: `_Atomic` is parsed but treated as the underlying type (the\n  qualifier is not tracked through the type system).\n\n## Testing\n\nThe compiler has two kinds of tests:\n\n**Unit tests** (in-source `#[test]` functions for individual passes and modules):\n\n```bash\ncargo test --release\n```\n\n**Integration tests** (end-to-end compilation tests in `tests\u002F`). Each test is\na directory containing a `main.c` source file and expected output files:\n\n```\ntests\u002F\n  some-test-name\u002F\n    main.c              # C source to compile\n    expected.stdout     # Expected stdout (if any)\n    expected.ret        # Expected exit code (if any)\n    expected.skip.arm   # Skip marker for specific architectures (optional)\n```\n\nTests are run by compiling `main.c` with `ccc`, executing the resulting binary,\nand comparing stdout and the exit code against the expected files.\n\n## Environment Variables\n\n| Variable | Purpose |\n|----------|---------|\n| `CCC_TIME_PHASES` | Print per-phase compilation timing to stderr |\n| `CCC_TIME_PASSES` | Print per-pass optimization timing and change counts to stderr |\n| `CCC_DISABLE_PASSES` | Disable specific optimization passes (comma-separated, or `all`) |\n| `CCC_KEEP_ASM` | Preserve intermediate `.s` files next to output |\n| `CCC_ASM_DEBUG` | Dump preprocessed assembly to `\u002Ftmp\u002Fasm_debug_\u003Cname>.s` |\n\n## Project Organization\n\n```\nsrc\u002F                Compiler source code (Rust)\n  frontend\u002F         C source -> typed AST (preprocessor, lexer, parser, sema)\n  ir\u002F               Target-independent SSA IR (lowering, mem2reg)\n  passes\u002F           SSA optimization passes (15 passes + shared loop analysis)\n  backend\u002F          IR -> assembly -> machine code -> ELF (4 architectures)\n  common\u002F           Shared types, symbol table, diagnostics\n  driver\u002F           CLI parsing, pipeline orchestration\n\ninclude\u002F            Bundled C headers (x86 SIMD: SSE through AVX-512, AES-NI, FMA, SHA, BMI2; ARM NEON)\ntests\u002F              Compiler tests (each test is a directory with main.c and expected output)\nideas\u002F              Future work proposals and improvement notes\n```\n\nEach `src\u002F` subdirectory has its own `README.md` with detailed design\ndocumentation. For the full architecture, compilation pipeline data flow,\nand key design decisions, see [DESIGN_DOC.md](DESIGN_DOC.md).\n","Claude's C Compiler (CCC) 是一个完全从零开始使用 Rust 语言编写的 C 编译器，支持 x86-64、i686、AArch64 和 RISC-V 64 架构。该项目的核心功能包括前端解析、基于 SSA 的中间表示、优化器、代码生成器、窥孔优化器、汇编器、链接器以及 DWARF 调试信息生成，所有这些组件均独立实现，不依赖任何外部工具链。CCC 可以编译出能在 Linux 系统上运行的 ELF 可执行文件，并且可以作为 GCC 的替代品在构建系统中直接使用。它特别适用于需要自定义编译流程或进行跨平台开发（如 ARM 或 RISC-V）的场景。然而需要注意的是，该编译器尚未经过充分验证，因此不建议在生产环境中使用。",2,"2026-06-11 03:50:20","high_star"]