From 2347dc4cd70de8a1a30687f5b86c8f7c1d5bf9b5 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:30:55 +0200 Subject: [PATCH 1/2] Update dlmalloc and windows-sys for the library workspace Windows-sys isn't actually used as dlmalloc doesn't use it on any of the targets where std uses dlmalloc, but still ends up in the lockfile and thus gets vendored. This reduces the vendor size of the standard library from 93MB to 37MB. --- library/Cargo.lock | 73 +++----------------------------------- src/tools/tidy/src/deps.rs | 9 ----- 2 files changed, 4 insertions(+), 78 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index 0d978f5dcd49..ff859e9ffc0c 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "dlmalloc" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cdfe340b16dd990c54cce79743613fa09fbb16774f33a77c9fd196f8f3fa30" +checksum = "9f5b01c17f85ee988d832c40e549a64bd89ab2c9f8d8a613bdf5122ae507e294" dependencies = [ "cfg-if", "libc", @@ -451,78 +451,13 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-sys" -version = "0.60.2" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ "windows-link 0.2.1", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "wit-bindgen" version = "0.57.1" diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 1d12456d2bb2..ec21e2669523 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -544,15 +544,6 @@ pub(crate) struct WorkspaceInfo<'a> { "wasip3", "windows-link", "windows-sys", - "windows-targets", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", "wit-bindgen", // tidy-alphabetical-end ]; From b7f337e4b2b40f3fb2c4fd46300a8b1a7adee438 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 23 Apr 2026 18:01:21 +0200 Subject: [PATCH 2/2] Replace windows-sys with a dummy crate in the library workspace This reduces the vendor size of the standard library from 37MB to 20MB. --- library/Cargo.lock | 15 ++------------- library/Cargo.toml | 3 +++ library/windows-sys/Cargo.toml | 16 ++++++++++++++++ library/windows-sys/src/lib.rs | 1 + src/tools/tidy/src/deps.rs | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 library/windows-sys/Cargo.toml create mode 100644 library/windows-sys/src/lib.rs diff --git a/library/Cargo.lock b/library/Cargo.lock index ff859e9ffc0c..9a80a930e36e 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -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" diff --git a/library/Cargo.toml b/library/Cargo.toml index 87df966bb6b8..788c990c1634 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -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' } diff --git a/library/windows-sys/Cargo.toml b/library/windows-sys/Cargo.toml new file mode 100644 index 000000000000..eb27eff15e84 --- /dev/null +++ b/library/windows-sys/Cargo.toml @@ -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 = [] diff --git a/library/windows-sys/src/lib.rs b/library/windows-sys/src/lib.rs new file mode 100644 index 000000000000..112740ab2d1b --- /dev/null +++ b/library/windows-sys/src/lib.rs @@ -0,0 +1 @@ +compile_error!("This crate should never be compiled"); diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index ec21e2669523..7c3315127989 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -543,7 +543,7 @@ pub(crate) struct WorkspaceInfo<'a> { "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 ];