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.
English · 简体中文 · Documentation · Changelog · Contributing
- Zero External Dependencies:
Cargo.tomldepends 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, andrux testexecute 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-onlymmapcache lookup is permitted unless--no-cacheis passed).rux buildemits only the single target executable (zero companion files) and atomically updatestarget/.ruxcache(alignedRUXCACH1single-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 testsrunner withassert*!and RAII zero-leak verification),cache,clean,bloat(byte-exact size breakdown vs.rustc -Oandcargo target/),inspect,fuzz,lsp, andbench.
- Zero-Bloat Standard
.rsSubset & Zero-CRTstdPrimitives:- Compiles
struct,impl, user genericsstruct/enum/impl<T>/fn<T>with::<T>turbofish, closures, statictraits, taggedenum, exhaustivematch(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<_>>(), andfor (k, v) in &map), zero-vtable compile-timeformat!(...),trim/starts_with/parse::<i32>(), unsigned integers (u8/u16/u32/u64/usize/isize) withascasts, userimpl Drop for StructRAII, OS-pagedVec<T>/String/ open-addressedHashMap<K, V>, and 4-OS zero-CRTstd::fs::read_to_string/std::fs::read+ CLI arguments.
- Compiles
- Inter-Procedural View-Mask Field Borrowing: Embeds 16-bit fixed-point
(self_read_mask, self_write_mask)bitmasks into each 64-byte single-cache-lineFunctionSignature, allowing callers holding&mut obj.field_ato invoke&selfor&mut selfmethods that only touch disjoint fields—patterns thatrustcrejects withE0499/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 everycargo testrun (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 officialrustc -Obit-exact golden parity tests.
- Rust toolchain (Edition 2021; verified with
rustc 1.95.0/cargo 1.95.0) - Optional:
deslop-pleaseinPATHfor structural module-depth linting (automatically invoked when present duringcargo test)
# 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 testMeasured 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 integersi8–i64/u8–u64/isize/usize/bool/&str/&[u8], fixed[T; N]arrays, 2-tuples(A, B), single-layer fused iterators, RAII-reclaimedVec<T>/String/HashMap<K, V>, userimpl Drop,&bs[a..b]sub-slices, user genericstruct/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>(), statictraits, up to 16-parameter calls, and 4-OS zero-CRTstd::fs::read*& CLI args) rather than fullrustc+stdcoverage. See Language Support & Compatibility for the exact specification and known limitations.
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 Index (EN) | 文档总览 (中文)
- Architecture & MIT Axiomatic Design | 架构设计与 MIT 公理化设计
- Language Support, View-Mask Borrowing & Diagnostics | 语言支持、View-Mask 借用与诊断
- Compiler Pipeline Deep Dive | 编译管线深度指南
- CLI, Incremental Database & LSP Tooling | CLI、增量数据库与 LSP 工具链
- Verification & Reproducible Benchmarks | 验证体系与可复现基准测试
- Contributing Guide (中文版)
- Code of Conduct (中文版)
- Security Policy (中文版)
- Changelog (中文版)
- Licenses: MIT | Apache-2.0 (中文说明)
Dual-licensed under either of:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
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.
