#build #tool #rust

build truck-rs

Supercharges cargo

3 unstable releases

0.2.5 Apr 24, 2022
0.2.0 Apr 24, 2022
0.1.0 Apr 24, 2022

#121 in Build Utils

MIT license

204 lines


For Supercharging cargo

What does it do?

It is based on this reddit comment. It improves cargo build speed.

How does it perform compared to Flex?

Both do the same thing, but Truck also comes with mold support and uses lesser number of lines for achieving the purpose.

Why does it exist in the first place?

This is created for newbies for their first PR. This project is barebones and can be extended. (Like adding colored output or fixing mistakes in the Readme.md file and if the PR makes sense, I will push it). It is only for educational purpose.

How does it work?

It creates a .cargo/config.toml file and rust-toolchain.toml file which replaces default linker with lld(Linux) or zld(MacOS) and mold(linux) and ccache with sccache. (See the reddit comment for more details)


  • sccache: cargo install sccache
  • zld(Mac Users): brew install michaeleisel/zld/zld
  • lld(Linux Users): Install using your package manager (For Arch users, sudo pacman -Syu lld)
  • mold(Linux Users): Install using your package manager (For Arch users, sudo pacman -Syu mold)
  • Rust Nightly(optional): But mandatory for -ffn option

How to install

cargo install truck-rs Make sure $CARGO_HOME/bin is in path

Quick Start

  • truck [TRUCK FLAGS] Creates optimisations on existing projects
  • truck new my_file [TRUCK FLAGS] Similar to cargo new myfile but with truck optimisations
  • truck init my_file [TRUCK FLAGS] Similar to cargo init but with truck optimisations

Run cargo build or run to see the magic

Truck Flags

  • noflags: Default build
  • -f: Fast(uses zld and lld)
  • -ff: Faster than -f(uses mold)
  • -ffn: Fastest (uses mold and sccache)


  • Like fleet, it doesn't work if you are not importing multiple crates.
  • Using truck replaces your existing .cargo/config.toml and .rust-toolchain.toml file.
  • Also, we don't guarrantee it will be perfect alternative for cargo since there is a reason cargo by default doesn't use mold or lld or zld or sccache. (Read the reddit comment for more details)



If you find anything that can impove Rust's performance, please add it in optimisations.md


~37K SLoC