Merge _configs/ into config/ for single configuration directory. Update all path references. Changes: - Move _configs/* to config/ - Update .gitignore for new patterns - No code references to _configs/ found Impact: -1 root directory (layout_conventions.md compliance)
8.5 KiB
8.5 KiB
Bootstrap Compiler: Visual Diagrams and Flowcharts
Diagram 1: The Bootstrap Problem and Solution
WITHOUT BOOTSTRAP (Impossible):
To compile Rust source
↓
Need rustc compiler
↓
But rustc is written in Rust
↓
Need rustc compiler to compile rustc
↓
🔄 INFINITE LOOP!
WITH BOOTSTRAP (Working):
Need a working compiler
↓
Download pre-compiled Rust binary
↓
Run pre-compiled rustc
↓
Use rustc to compile more Rust
↓
🎉 LOOP BROKEN!
Diagram 2: Installation Timeline
Installation: curl https://sh.rustup.rs | bash
⏱️ T+0s ┌─────────────────────────┐
│ Download installer │
│ (50KB bash script) │
└────────┬────────────────┘
↓
⏱️ T+1s ┌─────────────────────────┐
│ Execute bash script │
│ (runs in memory) │
└────────┬────────────────┘
↓
⏱️ T+2s ┌─────────────────────────┐
│ Detect system: │
│ uname -s → Darwin │
│ uname -m → arm64 │
│ Target: aarch64-... │
└────────┬────────────────┘
↓
⏱️ T+30s ┌─────────────────────────┐
│ Download pre-compiled │
│ Rust (100-150MB) │
│ Network bandwidth limit │
└────────┬────────────────┘
↓
⏱️ T+40s ┌─────────────────────────┐
│ Extract and install │
│ to ~/.rustup/ │
└────────┬────────────────┘
↓
⏱️ T+45s ✅ Rust installed!
Total: ~45 seconds (mostly network download)
Diagram 3: Dependency Chain
PRE-COMPILED BOOTSTRAP (What Rust Does):
rustc (compiler)
│
├─ cargo (package manager)
├─ Standard library (pre-compiled)
└─ Other tools
Once rustc exists:
│
├─ Compile NuShell from source
├─ Compile Just from source
└─ Compile workspace binaries
Result: Everything ready! ✅
Diagram 4: Architecture Detection
Your System
↓
uname -s → "Darwin" (macOS) or "Linux"
↓
uname -m → "arm64", "x86_64", etc.
↓
Combine them:
├─ arm64 + Darwin = aarch64-apple-darwin
├─ x86_64 + Darwin = x86_64-apple-darwin
├─ aarch64 + Linux = aarch64-unknown-linux-gnu
└─ x86_64 + Linux = x86_64-unknown-linux-gnu
↓
Download from: https://static.rust-lang.org/dist/
rust-1.91.1-<target-triple>.tar.gz
↓
Extract and install
↓
rustc is now available!
Diagram 5: Installation Phases
Phase 1: System Detection
↓
Phase 2: Install Rust (Bootstrap)
├─ Download sh.rustup.rs (50KB)
├─ Execute installer script
├─ Download pre-compiled rustc (100MB)
└─ Install to ~/.rustup/
↓
Phase 3: Compile NuShell
└─ cargo install nu (1-2 minutes)
↓
Phase 4: Compile Just
└─ cargo install just (1-2 minutes)
↓
Phase 5: Clone Repository
↓
Phase 6: Build Project
└─ cargo build --release (5-10 minutes)
↓
Phase 7: Deploy Configuration
↓
Phase 8: Verify Installation
↓
✅ Everything ready!
Diagram 6: Size Comparison
APPROACH 1: Bootstrap Only ✅
├─ Installer script: 50KB
├─ Pre-compiled Rust: 100MB
└─ Total: ~150MB
APPROACH 2: Pre-Compile Everything ❌
├─ Rust for 50 archs: 5GB+
├─ NuShell for 50 archs: 500MB+
├─ Just for 50 archs: 200MB+
└─ Total: 10GB+ (bloated)
APPROACH 3: Source Code ❌
├─ Rust source: 2GB
├─ Dependencies: 1GB
└─ Total: 3GB+ (need C compiler)
Diagram 7: What Gets Pre-Compiled vs Compiled
PRE-COMPILED (Download):
├─ rustc (the compiler itself)
├─ cargo (package manager)
├─ rustfmt (formatter)
├─ clippy (linter)
└─ std library (standard library, pre-compiled for your arch)
COMPILED FROM SOURCE (Using rustc):
├─ NuShell
├─ Just
├─ syntaxis-core
├─ syntaxis-cli
├─ syntaxis-tui
├─ syntaxis-dashboard
└─ Other crates
Diagram 8: Supported Architectures
Over 50 supported:
┌─ macOS ─────────────────────┐
│ ├─ aarch64-apple-darwin │
│ └─ x86_64-apple-darwin │
└─────────────────────────────┘
┌─ Linux ──────────────────────┐
│ ├─ aarch64-unknown-linux-gnu │
│ ├─ x86_64-unknown-linux-gnu │
│ ├─ aarch64-unknown-linux-musl│
│ └─ x86_64-unknown-linux-musl │
└──────────────────────────────┘
┌─ Windows ────────────────────┐
│ ├─ x86_64-pc-windows-msvc │
│ ├─ aarch64-pc-windows-msvc │
│ └─ x86_64-pc-windows-gnu │
└──────────────────────────────┘
Plus: Android, iOS, FreeBSD, WebAssembly,
RISC-V, PowerPC, MIPS, s390x, and more...
Diagram 9: The Bootstrap Kernel
Traditional OS Bootstrap:
Power On
↓
BIOS/Firmware (built into chip)
↓
Bootloader (loads kernel)
↓
Kernel (core OS functionality)
↓
OS ready
Rust Bootstrap:
User runs: curl ... | bash
↓
sh.rustup.rs script (basic bash)
↓
Pre-compiled rustc (the "kernel")
↓
rustc compiles everything else
↓
Everything ready
Diagram 10: Why No Central Binary Repository
Option A: Host all binaries in our repo ❌
Repository size: 5GB+
Update frequency: Weekly (every Rust release)
Architectures: Maintain 50+ versions
Cost: $1000s/month CDN
Problem: Maintenance nightmare
Result: NOT VIABLE
Option B: Rely on Rust Foundation's repo ✅
Repository size: 150MB (just code)
Update frequency: Automatic (users get latest)
Architectures: Rust Foundation maintains 50+
Cost: Free (they handle it)
Benefit: Automatic updates
Result: PERFECT! 🎉
Diagram 11: The Complete Chain
Before Installation:
You have: bash, curl, tar, git
Installer downloads:
└─ sh.rustup.rs (50KB script)
Script downloads:
└─ Pre-compiled Rust (100MB)
Once Rust exists:
├─ Cargo installs NuShell (from source)
├─ Cargo installs Just (from source)
├─ Cargo builds workspace (from source)
└─ Script deploys configs
Result:
✅ Complete development environment
Diagram 12: Cargo's Target Selection
When you run: cargo build
Cargo asks: "What's my target?"
↓
Checks: Cargo.toml (no explicit target)
Checks: .cargo/config.toml (no override)
Checks: Environment variables (not set)
↓
Uses default: Current system (host platform)
↓
Calls: rustc --print host-tuple
↓
Rustc responds:
├─ On M1 Mac: aarch64-apple-darwin
├─ On Intel Mac: x86_64-apple-darwin
├─ On Linux ARM: aarch64-unknown-linux-gnu
└─ On Linux Intel: x86_64-unknown-linux-gnu
↓
Cargo uses this to:
├─ Select pre-compiled std library
├─ Choose linker
├─ Create target/<triple>/release/
└─ Pass hints to LLVM compiler
↓
Result: Binaries built for YOUR system,
ready to run immediately!
KEY: No manual configuration needed! ✅
Summary
These diagrams show:
- The circular dependency problem and solution
- Timeline showing the installation speed
- What gets pre-compiled vs compiled
- Automatic architecture detection
- Why bootstrap approach is better than alternatives
- The dependency chain from installer to final binaries
- How many architectures are supported
- Why we don't pre-compile in our repo