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