Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ wildcard_imports = "warn"
name = "rustup"
path = "src/lib.rs"

[[bin]]
name = "rustup-init"
path = "src/bin/rustup-init.rs"
# The binary has no unit tests or benchmarks. Its empty test and bench harnesses
# would otherwise be linked with the binary's delay-load list (see `build.rs`) but
# without the code that imports those DLLs, which `/WX` turns into a link error
# (LNK4199).
test = false
bench = false

[profile.release]
codegen-units = 1
lto = true
Expand Down
10 changes: 10 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ fn main() {
for dll in delay_load_dlls {
println!("cargo::rustc-link-arg-bin=rustup-init=/delayload:{dll}.dll");
}
// Also delay load system DLLs that the proxies never call. Every `cargo`,
// `rustc` etc. started through rustup is a separate process on Windows, and
// each of these DLLs (with what it pulls in, such as gdi32 for user32) costs
// start-up time when it is loaded eagerly.
let delay_load_for_startup = [
"user32", "shell32", "ole32", "oleaut32", "crypt32", "secur32", "ws2_32",
];
for dll in delay_load_for_startup {
println!("cargo::rustc-link-arg-bin=rustup-init=/delayload:{dll}.dll");
}
// When using delayload, it's necessary to also link delayimp.lib
// https://learn.microsoft.com/en-us/cpp/build/reference/dependentloadflag?view=msvc-170
println!("cargo::rustc-link-arg-bin=rustup-init=delayimp.lib");
Expand Down
Loading