diff --git a/.cargo/config.toml b/.cargo/config.toml index fcb07c1..7210779 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -10,3 +10,19 @@ incremental = true [profile.test] debug = "line-tables-only" incremental = false + +# rust-lld ships with the Rust toolchain (no extra install) and links +# 2-5x faster than MSVC's link.exe on link-heavy rebuilds. The dev +# profile already lives in the hot iteration loop; cutting the link +# step is the biggest single win there. Set per Windows target so +# unix/macos builds keep their platform default linker. +# +# Escape hatch if rust-lld trips on a foreign object file: +# RUSTFLAGS="-C linker=link.exe" cargo build +# +# See fbuild#744 and zackees/template-python-rust-cmd#2. +[target.x86_64-pc-windows-msvc] +linker = "rust-lld.exe" + +[target.aarch64-pc-windows-msvc] +linker = "rust-lld.exe" diff --git a/Cargo.toml b/Cargo.toml index 50543cb..f78d54b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,14 @@ homepage = "https://github.com/example/template-python-rust-cmd" [workspace.dependencies] anyhow = "1" pyo3 = { version = "0.23", features = ["extension-module"] } + +# Keep third-party crates release-grade even in the dev profile. +# `cargo build` (no --release) compiles first-party crates unoptimized +# for fast iteration; third-party deps (pyo3, serde, etc.) are compiled +# once and cached at opt-level 3 so the runtime hot path stays as fast +# as a release build. This is what makes "default to dev for local +# iteration" safe — see fbuild#744 (~5x faster Rust-edit rebuild on +# fbuild's workspace) and zackees/template-python-rust-cmd#2. +[profile.dev.package."*"] +opt-level = 3 +debug = false