Rust

Dependencies

Update a dependency to the latest version

# 1. Edit Cargo.toml
[dependencies]
crate_name = "x.y"   # set to desired/latest version

# 2. Update
cargo update -p crate_name

# 3. Verify
cargo tree | grep crate_name
  • cargo update -p crate_name → updates only that dependency
  • cargo update → updates all dependencies
  • Loosen version in Cargo.toml if updates are blocked by constraints

Compiling

Types of builds

--dev builds are optimized at level 0, which means it's unoptimized, but is also faster to compile.

cargo build --dev

--release flag indicates an optimization level of 3, the maximum. It takes longer to compile.

cargo build --release

Cross Compiling from Archlinux

Requirements

You first need rustup to be able to add targets.

Windows

sudo pacman -S mingw-w64-gcc

Linux

Since we already on linux, we don't need much. However, to compile to ARM, we need:

sudo pacman -S aarch64-linux-gnu-gcc

and then set it as the linker for the ARM target in .cargo/config.toml(local):

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

Cargo ignores linker settings in Cargo.toml. It only reads them from .cargo/config.toml (project-local) or ~/.cargo/config.toml (global).

MacOS

I don't know yet...

Maybe this MacOS Cross-Compiler - github.com

https://studios.ptilouk.net/superfluous-returnz/blog/2022-03-16_macos.html https://doc.rust-lang.org/beta/rustc/platform-support/apple-darwin.html https://doc.rust-lang.org/beta/rustc/platform-support.html https://wapl.es/rust/2019/02/17/rust-cross-compile-linux-to-macos.html/ ← seems promissing

https://github.com/cross-rs/cross

https://github.com/tpoechtrager/osxcross