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 cachepot. (See the reddit comment for more details)
- cachepot: cargo install cachepot
- 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
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
- 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