Skip to content

Repository files navigation

acc β€” Antigravity's C Compiler in Rust

CI Release Status Rust Architecture License: MIT

acc (Antigravity's C Compiler) is a high-ceiling, production-capable C compiler written completely from scratch in Rust. It features a complete clean-room frontend (preprocessor, lexer, recursive-descent parser, AST) and multi-target assembly code generators supporting 4 major Instruction Set Architectures: AArch64, x86_64, i686, and RISC-V 64.

System as / ld / cc are used only to assemble and link textual assembly (.s) emitted directly by acc β€” user .c files are never passed to external compilers.

πŸ›‘οΈ Clean-Room Commitment: This repository is written entirely from scratch without reading, vendoring, or deriving from third-party non-free compiler codebases. Evaluation methodology and acceptance criteria are backed by automated oracle suites, mutation testing, anti-bypass verification, and real-world project compilation.


🌟 Key Achievements

  • 🐧 ARM64 Linux Kernel 6.9 QEMU Boot (PASS_BOOT): Fully compiles Linux Kernel 6.9 and boots to an interactive BusyBox shell prompt (/#) in QEMU on ARM64 and x86_64 architectures.
  • πŸ—ƒοΈ SQLite 310,000+ Tests 100% PASS: Successfully compiles the full SQLite database engine and passes 317,930 tests in the official SQLite testfixture + test/veryquick.test test suite with 0 errors.
  • πŸš€ Redis 7.2.5 RESP Server: Compiles Redis Server 7.2.5 serving live RESP commands (PING, SET, GET, INCR) under real workloads.
  • πŸ–₯️ 4-ISA Architecture Support: Built-in native assembly generators for AArch64, x86_64, i686, and RISC-V 64 across Linux ELF and macOS Mach-O targets.

🚦 Verification & Compatibility Matrix

Goal: NOT COMPLETE β€” Status: IN_PROGRESS

Start here: docs/HANDOFF_CCC_STATUS_COMPLETE.md Β· living stamp: harness/progress.md.
Parity Gates status: Builtin M2/M4/M5 (PASS), C2 SQLite/Redis (PASS), C3 4-ISA (PASS), C1 BusyBox dual-arch QEMU (PASS), Postgres 237 (BLOCKED), Torture subset (77.0% pass rate, 77/100 passed, 23 failed; raw log: scratch/torture_gcc_subset.log).

Milestone / Gate Description Status Evidence & Metrics
Stage A Hello printf, core syntax, anti-bypass audit PASS 100% pass on baseline fixtures
Stage B Language surface, c-testsuite compliance PASS Stage A range 100/100; full suite ~95%+ (see harness logs)
Stage C1 (Linux Boot) Linux Kernel 6.9 compilation & QEMU boot PASS arm64 & x86_64 BusyBox shell prompt (/#) in QEMU (scratch/qemu_boot_a09.log, scratch/qemu_boot_x86_64.log)
Stage C2 (SQLite & Redis) SQLite veryquick & Redis RESP PASS 317,930 / 317,930 (0 errors); Redis live RESP markers
Stage C2 (Postgres 237) initdb + make check regression bar BLOCKED / PARTIAL initdb SEGV exit 139 under remediation (scratch/c2_postgres_237_summary.txt)
Stage C3 (4-ISA Multi-Arch) AArch64, x86_64, i686, RISC-V 64 support PASS 100/100 Γ—4 all ISAs (scratch/stage_c_4isa.log)
Builtin M4 / M5 In-tree assembler + linker PASS M4 freestanding & M5 hosted Hello static musl (scratch/builtin_m4_marker, scratch/builtin_m5_marker)
Stage C4 / C5 Clean-room enforcement & double-run parity PASS Mutation / anti-bypass harness green; double-run evidence verified (scratch/stage_c_rerun.log)

πŸ—οΈ High-Level Architecture

                       C Source File (.c)
                               |
                               v
                       +---------------+
                       |  preprocess   |   Macros, #if / #ifdef, #include, #pragma
                       +---------------+
                               |
                               v
                       +---------------+
                       |    lexer      |   Tokens, GNU attributes, sticky keywords
                       +---------------+
                               |
                               v
                       +---------------+
                       |    parser     |   Recursive descent β†’ Abstract Syntax Tree (AST)
                       +---------------+
                               |
                               v
                       +---------------+
                       |    codegen    |   AArch64 | x86_64 | i686 | RISC-V 64
                       +---------------+
                               |
                               v
                     System Assembler / Linker
                    (as / ld / cc for .s ONLY)
                               |
                               v
                    Executable Binary (ELF / Mach-O)

Unlike black-box compilers, acc emits clean, human-readable textual assembly (.s) and delegates host assembly and linking to standard system toolchains.


πŸ“¦ Installation

acc provides multiple installation methods for macOS and Linux users.

1. One-Line Shell Installer (Recommended)

Quickly download and install the latest acc binary for your OS and architecture:

curl -fsSL https://raw.githubusercontent.com/ImL1s/acc/main/install.sh | sh

By default, the script installs acc to ~/.local/bin (or /usr/local/bin if run as root). Ensure ~/.local/bin is in your PATH.

To install to a custom directory:

curl -fsSL https://raw.githubusercontent.com/ImL1s/acc/main/install.sh | ACC_INSTALL_DIR=/usr/local/bin sh

2. Pre-Built Binary Release

Download pre-built binary archives directly from GitHub Releases:

Target Platform Archive Name
Linux x86_64 acc-x86_64-linux.tar.gz
Linux AArch64 acc-aarch64-linux.tar.gz
macOS Intel acc-x86_64-macos.tar.gz
macOS Apple Silicon acc-aarch64-macos.tar.gz
# Example: Download and extract for macOS Apple Silicon
curl -LO https://github.com/ImL1s/acc/releases/download/v0.1.0/acc-aarch64-macos.tar.gz
tar -xzf acc-aarch64-macos.tar.gz
mkdir -p ~/.local/bin
mv acc ~/.local/bin/

3. Cargo Install (From Source)

If you have Rust 1.75+ installed, you can build and install directly via Cargo:

# Install from the latest main branch
cargo install --git https://github.com/ImL1s/acc.git acc

# Or install a specific release version
cargo install --git https://github.com/ImL1s/acc.git --tag v0.1.0 acc

πŸ› οΈ Quick Start

Building acc

Requires Rust 1.75+ toolchain:

cargo build --release

The compiled binary will be placed at target/release/acc.

Compiling & Running C Code

cat > main.c << 'EOF'
#include <stdio.h>

int main(void) {
    printf("Hello from acc (Antigravity's C Compiler)!\n");
    return 0;
}
EOF

./target/release/acc -o app main.c
./app

Quick Invocation Guide

acc -o app main.c               # Compile, assemble, and link to executable
acc -c main.c                   # Compile to object file (.o)
acc -S main.c                   # Emit target assembly file (.s)
acc -E main.c                   # Run preprocessor only to stdout
acc -m <isa> main.c             # Target ISA: aarch64 (default), x86_64, i686, riscv64
acc --target-os <os> main.c     # Target OS dialect: darwin (Mach-O) or linux (ELF)
acc -I include/ -DNAME=VALUE    # Include search paths and macro definitions

πŸ§ͺ Verification Harness & CI/CD

Local Harness Execution

Run the built-in test suites to verify compiler functionality:

# In-repo oracle suite (compile -> execute -> verify exit/stdout)
./harness/run_oracle.sh

# Vendored public c-testsuite (Stage A & B compliance bar)
CTEST_MIN_PASS=200 ./harness/run_ctestsuite.sh

# Dual-ISA multiarch suite (Stage C3)
./harness/run_multiarch.sh

# Multi-arch 4-ISA full matrix (host + Docker)
./harness/run_multiarch_4isa.sh

# Anti-bypass & mutation safety check
./harness/mutation_check.sh # or ./harness/run_mutation.sh
./scripts/anti_bypass_audit.sh

# Complete CCC Parity Baseline Harness
./harness/run_ccc_parity.sh

GitHub Actions Workflows

Automated CI/CD pipelines are defined in .github/workflows/:

  • CI Workflow (.github/workflows/ci.yml): Triggered on push or pull request to main/master. Executes:

    1. Rust code format & check (cargo check, cargo fmt)
    2. Cargo release unit tests & binary build (cargo test --release, cargo build --release)
    3. Binary target validation (./target/release/acc --help)
    4. In-repo oracle suite (./harness/run_oracle.sh)
    5. Public c-testsuite (CTEST_MIN_PASS=200 ./harness/run_ctestsuite.sh)
    6. Dual-ISA multiarch suite (./harness/run_multiarch.sh)
    7. Mutation & anti-bypass audit (./harness/mutation_check.sh, ./scripts/anti_bypass_audit.sh)
    8. Real-world project wrappers (miniz, lua, sqlite)
  • Release Workflow (.github/workflows/release.yml): Triggered on tag pushes (v*). Compiles release binaries across multi-platform targets and creates GitHub Releases containing:

    • acc-x86_64-linux.tar.gz (Linux x86_64 ELF)
    • acc-aarch64-linux.tar.gz (Linux AArch64 ELF)
    • acc-x86_64-macos.tar.gz (macOS x86_64 Mach-O)
    • acc-aarch64-macos.tar.gz (macOS Apple Silicon AArch64 Mach-O)

πŸš€ Real-World Applications

Linux Kernel 6.9

Detailed instructions for building Linux Kernel 6.9 are provided in BUILDING_LINUX.txt.

# Build Linux 6.9 kernel inside Docker:
KERNEL_ARCH=arm64 JOBS=4 bash harness/docker/build_kernel.sh

Real-World Projects (SQLite, Redis, Lua, Miniz)

CC=$PWD/target/release/acc third_party/real/sqlite/build.sh test
CC=$PWD/target/release/acc third_party/real/redis/build.sh test
CC=$PWD/target/release/acc third_party/real/lua/build.sh test
CC=$PWD/target/release/acc third_party/real/miniz/build.sh test

πŸ“ Repository Layout

src/                     Clean-room C compiler core (Rust)
  main.rs                CLI entry point & flag parsing
  driver.rs              Compiler pipeline orchestration
  preprocess.rs          Macro expansion & header resolution
  lexer.rs / token.rs    Lexical analyzer & C tokens
  parser.rs / ast.rs     AST parser & type system
  codegen.rs             AArch64 code generator
  codegen_x86_64.rs      x86_64 code generator
  codegen_i686.rs        i686 32-bit code generator
  codegen_riscv.rs       RISC-V 64 code generator
harness/                 Test harnesses, Docker runners, verification scripts
oracles/                 Test cases and expected outputs
third_party/             Vendored c-testsuite & real project test scripts
docs/                    Design specifications & architecture plans

πŸ“„ Documentation & Release Notes


βš–οΈ License

This project is open source under the MIT License.

About

A clean-room C compiler written from scratch in Rust with AArch64 & x86_64 backends. Compiles Linux Kernel 6.9 (QEMU boot to PID 1), SQLite Amalgamation (~86,515 tests green), and Redis Server 7.2.5.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages