rust

  • rustc uses stacker crate for segmented stacks to avoid stack overflow
  • cargo test -- --nocapture for println!()
  • rls removed in 1.65 for rust-analyzer
  • HashTable uses SwissTable(DoS resistance)
  • https://rust-lang.github.io/api-guidelines/checklist.html
  • reference counting can be checked by statically
  • default allocator can be changed to jemalloc to avoid heap fragmentation
  • cargo feature flag propagation can break for not additive features
    • libraries could use RUSTFLAGS='--cfg feature_name="FEATURE_VAL"' and a build.rs like the curve25519-dalek crate (cross compilation?)
  • cargo update -p PACKAGE --precise VERSION" to pin Cargo.lock.
  • cargo tree for dependency tree visual
  • CROSS_CONTAINER_ENGINE=podman cross build --target x86_64-unknown-freebsd
    • freebsd tests only run on qemu runner
    • set the image tag for newer cross
[target.x86_64-unknown-freebsd]
image = "ghcr.io/cross-rs/x86_64-unknown-freebsd:main"
#runner = "qemu-user"
  • rust-toolchain.toml to set nightly/beta and components like llvm-tools-preview
[profile.release]
lto = true
codegen-units = 1 # reduce parallel codegen for increased optimization
strip = true
opt-level = "z" # smallest binary instead of speed
panic = "abort"