Windows/MSVC: Use hybrid CRT by default
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Now that the tier-1 Windows targets only support Windows 10 and up, I suggest that they use Microsoft's Hybrid CRT configuration by default. This way, any Rust user can easily distribute a standalone executable that runs on any Windows 10+ machine without having to install a specific version of the VC++ runtime, because that runtime is statically linked. But the UCRT is still dynamically linked, so the impact on executable size is minimal.
This can already be done in .cargo/config.toml as follows:
[target.'cfg(target_env = "msvc")']
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=/nodefaultlib:libucrt.lib", "-C", "link-arg=ucrt.lib"]
IMO, even though it's already possible to do this via .cargo/config.toml, it should be the default. That will eliminate one papercut that gives Windows native desktop development a reputation for being hard.
My company has shipped a desktop application using this configuration to thousands of Windows machines for over a year now, and this configuration hasn't caused any problems.
Here are executable sizes for a hello-world program compiled for x86_64-pc-windows-msvc with Rust 1.94.0:
- Fully dynamic CRT: 127 KB
- Hybrid CRT: 153 KB
- Fully static CRT: 226 KB
I think the Hybrid CRT option is the sweet spot: just-works distribution with modest impact on executable size.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the target-specific MSVC settings shown for .cargo/config.toml and trace how Rust applies default linker and CRT configuration for tier-1 Windows targets. Done means the hybrid CRT behavior is the default for supported Windows 10+ MSVC targets, without requiring users to add the configuration themselves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100