Skip to content
GXSZonePublic

About

Zero-dependency native Rust compiler built on MIT Axiomatic Design

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Rux

Rux (rux) is a zero-dependency native compiler and ultra-lightweight toolchain for a systems-focused subset of standard Rust (.rs), built from first principles around MIT Axiomatic Design and Deep Modules—compiling directly to standalone zero-CRT executables for Windows x86_64 (PE32+), Linux x86_64 / AArch64 (ELF64), macOS Apple Silicon (Mach-O 64), and host W^X in-memory JIT without LLVM, external linkers, or bloated target/ artifacts.


Rux — Zero-Dependency Native Rust Compiler


English  ·  简体中文  ·  Documentation  ·  Changelog  ·  Contributing



Key Characteristics

  • Zero External Dependencies: Cargo.toml depends solely on the Rust standard library (std)—no LLVM, no system linker, no third-party crates.
  • Zero-Garbage Pipeline & Self-Cleaning Quota Cache (target/.ruxcache):
    • rux check, rux run, and rux test execute strictly in memory / host W^X JIT with 0 bytes written to disk—never emitting .o, .rmeta, .pdb, .lib, .exp, or temporary test binaries (read-only mmap cache lookup is permitted unless --no-cache is passed).
    • rux build emits only the single target executable (zero companion files) and atomically updates target/.ruxcache (aligned RUXCACH1 single-file container, default 4 MiB cap, --max-cache <size>, --no-cache, automatic orphan GC and LRU eviction).
    • Complete toolchain subcommands: check, run, build, test (in-memory #[test] / #[cfg(test)] mod tests runner with assert*! and RAII zero-leak verification), cache, clean, bloat (byte-exact size breakdown vs. rustc -O and cargo target/), inspect, fuzz, lsp, and bench.
  • Zero-Bloat Standard .rs Subset & Zero-CRT std Primitives:
    • Compiles struct, impl, user generics struct/enum/impl<T>/fn<T> with ::<T> turbofish, closures, static traits, tagged enum, exhaustive match (up to 8 bindings), Option<T> / Result<T, E> + ?, if let / while let, 2-tuples (A, B), single-layer fused iterators (.iter(), .copied(), .enumerate(), .map(), .filter(), .fold(), .sum(), .count(), .collect::<Vec<_>>(), and for (k, v) in &map), zero-vtable compile-time format!(...), trim/starts_with/parse::<i32>(), unsigned integers (u8/u16/u32/u64/usize/isize) with as casts, user impl Drop for Struct RAII, OS-paged Vec<T> / String / open-addressed HashMap<K, V>, and 4-OS zero-CRT std::fs::read_to_string / std::fs::read + CLI arguments.
  • Inter-Procedural View-Mask Field Borrowing: Embeds 16-bit fixed-point (self_read_mask, self_write_mask) bitmasks into each 64-byte single-cache-line FunctionSignature, allowing callers holding &mut obj.field_a to invoke &self or &mut self methods that only touch disjoint fields—patterns that rustc rejects with E0499/E0502—while still catching real overlapping field mutations.
  • Enforced Axiomatic Architecture: Nine physical domains form a strictly lower-triangular dependency matrix with orthogonal diagonal submatrices for ISA backends (x86_64 | aarch64) and binary emitters (pe | elf | macho | jit), mechanically verified on every cargo test run (PodExpr == 16 B, PodStmt == 16 B, Span == 8 B, FunctionSignature == 64 B).
  • Five-Way Differential Equivalence: Every compiler and runtime change is cross-checked across MirVm(O0), MirVm(O2), HostJit(O2), Arm64VerifierVm(O2), and official rustc -O bit-exact golden parity tests.

Quick Start

Prerequisites

  • Rust toolchain (Edition 2021; verified with rustc 1.95.0 / cargo 1.95.0)
  • Optional: deslop-please in PATH for structural module-depth linting (automatically invoked when present during cargo test)

Build and Run

# Build the release compiler binary
cargo build --release

# Check, run in W^X JIT (-O2), or run in-memory #[test] suites with 0 bytes written to disk
cargo run --release -- check samples/view_borrow_killer.rs
cargo run --release -- run samples/showcase.rs --opt
cargo run --release -- run samples/telemetry_engine --opt
cargo run --release -- run samples/rpn_calc --opt
cargo run --release -- test samples/showcase.rs --no-cache

# Emit a standalone zero-CRT executable (accepts a .rs file, Cargo.toml, or crate directory)
cargo run --release -- build samples/telemetry_engine --opt --target x86_64-windows --out target/telemetry_engine.exe

# Manage target/.ruxcache (4 MiB default quota), clean artifacts, or dissect binary bloat
cargo run --release -- cache
cargo run --release -- bloat samples/telemetry_engine
cargo run --release -- clean

# Inspect POD density, MIR optimization, register allocation, and 4-OS binary sizes
cargo run --release -- inspect samples/showcase.rs

# Run deterministic 4-way differential fuzzing, memory benchmark, or LSP server
cargo run --release -- fuzz --cases 200
cargo run --release -- bench --max-memory 48K
cargo run --release -- lsp

# Run the full test suite (architectural guards + e2e + 5-way rustc golden parity)
cargo test

Measured Reference Snapshot

Measured on Windows x86_64 with rustc 1.95.0 and rux 0.1.0 (--release) (see Verification & Benchmarks for reproduction commands and caveats):

Metric rustc -O rux --opt Notes
Single-file samples/showcase.rs Win64 .exe 125,440 B 2,048 B 61.3x smaller; zero CRT, dynamic Win64 IAT trimming, 640 B Code+Data
Full-stack crate samples/telemetry_engine Win64 .exe 128,000 B 5,120 B 25.0x smaller (3,565 B Code+Data); generics, closures, Vec<Struct>, String, Option/Result + ?, trait & View-Mask
Multi-module crate samples/rpn_calc Win64 .exe 129,024 B 11,264 B 11.5x smaller (9,989 B Code+Data); RAII-dropped Vec<i32>, sub-slices, Option/Result + ?, and trait
Linux x86_64 / AArch64 static ELF64 (showcase) — 933 B / 989 B Single PT_LOAD segment (telemetry_engine: 3,871 B / 3,906 B; rpn_calc: 10,343 B / 9,398 B)
Standalone macOS ARM64 Mach-O (showcase / telemetry / rpn) — 16,640 B Page-aligned 16 KB segment + ad-hoc SHA-256 signature
samples/view_borrow_killer.rs Rejected (E0502/E0499) Compiled & executed 2 inter-procedural View-Mask borrows proven disjoint

Scope note: Rux (0.1.0) targets a well-defined, statically verified subset of Rust (covering signed/unsigned integers i8–i64 / u8–u64 / isize / usize / bool / &str / &[u8], fixed [T; N] arrays, 2-tuples (A, B), single-layer fused iterators, RAII-reclaimed Vec<T> / String / HashMap<K, V>, user impl Drop, &bs[a..b] sub-slices, user generic struct/enum/impl<T>/fn<T> + turbofish, non-capturing & scalar-capturing closures, Option<T>/Result<T, E> + ?, if let/while let, format!, trim/starts_with/parse::<i32>(), static traits, up to 16-parameter calls, and 4-OS zero-CRT std::fs::read* & CLI args) rather than full rustc + std coverage. See Language Support & Compatibility for the exact specification and known limitations.

Architecture Overview

Rux is partitioned into nine physical domains (src/), enforced by tests/axiom_guard_test.rs:

Domain Path Responsibility Allowed Dependencies
core src/core/ 16 B PodExpr/PodStmt, 64 B FunctionSignature, AstTable, lock-free ConcurrentPodArena, OS mmap, SHA-256 / FNV-1a None
syntax src/syntax/ 64-bit SWAR lexer, acyclic DAG .rs parser, user generics, single-layer iterator loop fusion, closure & format!/println! lowering core
sema src/sema/ Polonius NLL BitSet256 borrow checker, 16-bit View-Mask fixed-point analyzer, match exhaustiveness, causal diagnostics & CodeFix core
mir src/mir/ u16 three-address MIR (ir, lower, opt, regalloc, vm), StackLoad/CSE/ICF prep, DropScopeTracker (impl Drop), SysIntrinsic, MirVm::execute_audited core
isa src/isa/ Orthogonal x86_64 (Win64/SysV64) and aarch64 (AAPCS64 + Arm64VerifierVm) encoders with 16-arg ABI & branch fusion core, mir
link src/link/ Static relocation linker, expanded ICF, suffix-merged rodata string pool, ImageLayoutStats, zero-CRT 4-OS + JIT runtimes core, mir, isa
emit src/emit/ Orthogonal pe (dynamic IAT trimming), elf, macho, and host W^X jit (execute_audited) backends core, link
service src/service/ Parallel DAG parsing, IncrementalDatabase with interface_hash early cutoff, target/.ruxcache (RUXCACH1 4 MiB quota + orphan GC), JSON-RPC 2.0 LspServer core..link
verify src/verify/ Deterministic SplitMix64 4-way differential fuzzer & standalone Rust test synthesizer core..emit

Documentation

Technical Documentation

Community & Project Standards

License

Dual-licensed under either of:

at your option. Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in Rux by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.

About

Zero-dependency native Rust compiler built on MIT Axiomatic Design

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages