id: FR-COMP-004 title: 100% Pure-Ridgun Native ELF64 Code Generation for x86_64 and ARM64 Without Rust or rustc status: implemented priority: must created: 2026-10-21 updated: 2026-10-25 depends_on:
- FR-COMP-001
- FR-COMP-002
- FR-COMP-003
verified_by: []
FR-COMP-004 — 100% Pure-Ridgun Native ELF64 Code Generation for x86_64 and ARM64 Without Rust or rustc
Statement
The ridgunc compiler and the Ridgun repository SHALL be 100% self-contained in pure Ridgun (.rg) with zero Rust or C source files (.rs, .c), zero Cargo.toml/Cargo.lock manifests, and zero invocations of rustc, clang, or gcc:
- Native ELF64 Binary Emission (
src/main/ridgun/lib/llvm.rgandsrc/main/ridgun/lib/elf64.rg):
ridgunc buildandridgunc runSHALL emit standalone Linux ELF64 executables without invokingrustc,clang, orgcc(using pure LLVM IR.llcompiled viallc -O2 -filetype=objand linked vialdonx86_64perADR-0002, and directelf64.rgemission onARM64).- The native backend SHALL support both Linux
x86_64(e_machine = EM_X86_64 = 62) and LinuxARM64/AArch64(e_machine = EM_AARCH64 = 183, Raspberry Pi 3/4/5).
- Native Codegen Backends (
src/main/ridgun/lib/llvm.rg,src/main/ridgun/lib/x86_64.rg, andsrc/main/ridgun/lib/arm64.rg):
- All reachable Ridgun functions (
fn ::andop ::), pattern matches, guards (|,|.), parallel DAGwhereblocks (||,||.), mutable bindings (mut), tail-call loops (TCO), andRMM1/RMM2memory management operations SHALL be compiled directly into nativex86_64orARM64machine instructions. - All runtime primitives (
Int,Real,String,Bool,List,Tuple,Adt,Tensor,einsum, Hadamard@+/@-/@*/@/,map,||map,filter,||filter,fold, channels/mailboxes,context/shared/atomic,with region, and POSIX/Linux OS built-ins) SHALL be embedded directly as native machine code inside the ELF64 binary.
- Complete Elimination of Legacy Rust Code:
- The legacy
src/main/rust/directory,Cargo.toml, andCargo.lockSHALL be removed from the repository. src/main/ridgun/lib/compiler.rgSHALL contain zero embedded Rust source code and zerorustcshell commands.
Rationale
- Eliminating the intermediate Rust transpilation step and
rustcdependency makes Ridgun a 100% self-hosted native compiler, reduces executable link/emission time from ~30s to milliseconds, supports cross-compilation toARM64(Raspberry Pi) out of the box, and removes all non-Ridgun source code from the project.
Acceptance Criteria
- AC-1 (Zero Rust / Zero
rustc): No.rsfiles,Cargo.toml, orrustcinvocations remain anywhere insrc/or the repository root. - AC-2 (Self-Hosting Stage 1 & Stage 2):
target/ridgunccompilessrc/main/ridgun/ridgunc/main.rgandsrc/main/ridgun/stable/main.rginto native ELF64 executables (Stage 1), andStage 1recompiles them into identicalStage 2native ELF64 executables withoutrustc. - AC-3 (Full Language & Test Suite Parity):
./target/stable check,./target/stable test(all 4 test suites:test_basics.rg,test_core_language.rg,test_parallel_and_tensors.rg,test_strings.rg), and./target/stable formatpass with 0 errors. - AC-4 (
x86_64andARM64ELF64 Target Support):ridgunc buildsupports emitting bothx86_64(EM_X86_64 = 62) andARM64(EM_AARCH64 = 183) ELF64 binaries.