Replace windows-sys with a dummy crate in the library workspace

This reduces the vendor size of the standard library from 37MB to 20MB.
This commit is contained in:
bjorn3
2026-04-23 18:01:21 +02:00
parent 2347dc4cd7
commit b7f337e4b2
5 changed files with 23 additions and 14 deletions
+2 -13
View File
@@ -347,7 +347,7 @@ dependencies = [
"wasip1",
"wasip2",
"wasip3",
"windows-link 0.0.0",
"windows-link",
]
[[package]]
@@ -443,20 +443,9 @@ dependencies = [
name = "windows-link"
version = "0.0.0"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link 0.2.1",
]
version = "0.61.100"
[[package]]
name = "wit-bindgen"
+3
View File
@@ -85,3 +85,6 @@ rustflags = [
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
# See comments in `library/windows-sys/Cargo.toml` for why this is patched
windows-sys = { path = 'windows-sys' }
+16
View File
@@ -0,0 +1,16 @@
# dlmalloc has a dependency on windows-sys for when it gets compiled for Windows.
# std however never actually uses dlmalloc on Windows. As dlmalloc is the only
# user of windows-sys in the standard library, the windows-sys crate unnecessarily
# increases the size of the vendored crates. By replacing it with an empty crate
# we save about 19MB.
[package]
name = "windows-sys"
version = "0.61.100"
edition = "2024"
[features]
Win32_Foundation = []
Win32_System_Memory = []
Win32_System_Threading = []
Win32_System_SystemInformation = []
+1
View File
@@ -0,0 +1 @@
compile_error!("This crate should never be compiled");
+1 -1
View File
@@ -543,7 +543,7 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[
"wasip2",
"wasip3",
"windows-link",
"windows-sys",
"windows-sys@0.61.100", // Enforce the usage of our dummy windows-sys patch. Keep version in sync.
"wit-bindgen",
// tidy-alphabetical-end
];