Rust Unlinked: Rustc, Symbols, and Static Libraries
summary
Shows that linking can consume roughly half of compile time and demonstrates a reproducible experiment: compile foo.rs and bar.rs to object files, inspect symbol tables with nm/readelf, inspect LLVM IR, and try manual ld linking until an undefined core symbol (core is an rlib, not an .o) blocks progress. Solution is to build staticlib + build.rs, package .o files with ar, and let rust-lld (or cargo) link the archives — the example then links and runs.
AI-written summary · about
chapters (21)
- 0:00intro
- 0:26preamble
- 1:59understanding linking in rust
- 4:48compilation phases in rust
- 7:05lexing, parsing, and code analysis
- 9:56intermediate representations and optimizations
- 14:47llvm and code generation
- 18:00query-based compilation model
- 22:31introduction to object files
- 22:57introduction to object code
- 23:19experimenting with rust
- 23:37understanding the code example
- 24:01exploring symbol mangling
- 26:25compiling and linking object files
- 27:46using nm utility for symbol table
- 30:45examining elf file format
- 33:19manual linking with ld linker
- 34:12handling linking errors
- 35:55using static libraries in rust
- 39:47generating llvm ir
- 41:30conclusion and references








