Cross-Compiling Rust Projects to FreeBSD with cargo-zigbuild

Notes on cross-compiling a Rust project from Linux (x86_64) to FreeBSD x86_64 using cargo-zigbuild, and the pitfalls I ran into along the way. The project is a Discord bot that depends on crates like sysinfo, tikv-jemallocator, and sea-orm (SQLite). Background Zig ships with a multi-platform libc and cross-compilation toolchain. cargo-zigbuild leverages Zig as the linker to enable Rust cross-compilation — usually much more convenient than setting up a cross toolchain yourself. That said, targeting FreeBSD comes with some unique gotchas. ...

April 6, 2026 · 7 min

How I Improved My Rust Compilation Experience

Slow compilation and massive target/ directories — the classic Rust complaints. This post documents the techniques I’m currently using to make things better, using my project ClewdR (an async web service with 394 crate dependencies) as an example. Environment: Rust 1.94.1, CachyOS (Arch-based), NVMe SSD, Btrfs. rust-lld Linking is the final step of Rust compilation, and traditionally the slowest. GNU ld performs terribly here, especially with LTO enabled. The old approach was to manually install lld or mold and configure .cargo/config.toml: ...

April 6, 2026 · 5 min