rustc Basics
Purpose
Guide agents through Rust compiler invocation: RUSTFLAGS, Cargo profile configuration, build modes, MIR and assembly inspection, monomorphization, and common compilation error patterns.
Triggers
- "How do I configure a release build in Rust for maximum performance?"
- "How do I see the assembly output for a Rust function?"
- "What is monomorphization and why is it making my compile slow?"
- "How do I enable LTO in Rust?"
- "My Rust binary is too large — how do I shrink it?"
- "How do I read Rust MIR output?"
Workflow
1. Choose a build mode
2. Cargo.toml profile configuration
3. RUSTFLAGS
Persistent in .cargo/config.toml:
4. Inspect assembly output
5. Understand monomorphization
Rust generics are monomorphized — each concrete type instantiation produces separate code. This causes:
- Binary size bloat
- Longer compile times
- Potential i-cache pressure
Mitigation strategies:
6. Binary size reduction
7. Common error triage
8. Useful rustc flags
For RUSTFLAGS reference and Cargo profile patterns, see references/rustflags-profiles.md [blocked].
Related skills
- Use
skills/rust/cargo-workflowsfor workspace management and Cargo tooling - Use
skills/rust/rust-debuggingfor debugging Rust binaries with GDB/LLDB - Use
skills/rust/rust-profilingfor profiling and flamegraphs - Use
skills/rust/rust-sanitizers-mirifor memory safety validation


