From afc1e776de7bede4cf782c79d9861c17ec475b43 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 13 Jul 2025 00:28:42 -0700 Subject: [PATCH] windows: Use new `hints.mostly-unused` Most users of the `windows` crate will use a fraction of its API surface area. Nightly rustc provides an option `-Zhint-mostly-unused` to tell it to defer as much compilation as possible, which provides a substantial performance improvement if most of that compilation doesn't end up happening. Cargo plumbs this option through using the new `[hints]` table. This will cause users of the `windows` crate to default to setting `hint-mostly-unused`. (Top-level crates can override this if they wish, using a new profile option.) Note that setting this hint does not increase the MSRV of the Windows crate, as old versions of Cargo will ignore it. New versions of Cargo will respect it automatically (and, until we stabilize it, Cargo will do nothing unless you pass `-Zprofile-hint-mostly-unused` to cargo). Some sample performance numbers: this takes `windows` compilation time with all Graphics and UI features enabled from 18.3s to 10.7s (a 42% improvement), and takes compilation time with *all* features enabled from 3m48s to 2m55s (a 23% improvement). --- crates/libs/windows/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/libs/windows/Cargo.toml b/crates/libs/windows/Cargo.toml index befaff741b..957182037e 100644 --- a/crates/libs/windows/Cargo.toml +++ b/crates/libs/windows/Cargo.toml @@ -13,6 +13,9 @@ readme = "readme.md" categories = ["os::windows-apis"] exclude = ["features.json"] +[hints] +mostly-unused = true + [dependencies] windows-collections = { workspace = true } windows-core = { workspace = true }