Skip to content

Commit 199e290

Browse files
committed
Build releases with static CRT for -windows-msvc targets.
This increases the binary size of `rust-analyzer.exe` from 42.4 MB to 42.6 MB. Which should be acceptable for eliminating 7 DLL dependencies. Fixes #20970
1 parent 2efc800 commit 199e290

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

xtask/src/dist.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,19 @@ fn dist_server(
134134
};
135135

136136
let mut cmd = build_command(sh, command, &target_name, features, dev_rel);
137+
let mut rustflags = Vec::new();
138+
137139
if let Some(profile) = pgo_profile {
138-
cmd = cmd.env("RUSTFLAGS", format!("-Cprofile-use={}", profile.to_str().unwrap()));
140+
rustflags.push(format!("-Cprofile-use={}", profile.to_str().unwrap()));
141+
}
142+
143+
if target_name.ends_with("-windows-msvc") {
144+
// https://github.com/rust-lang/rust-analyzer/issues/20970
145+
rustflags.push("-Ctarget-feature=+crt-static".to_string());
146+
}
147+
148+
if !rustflags.is_empty() {
149+
cmd = cmd.env("RUSTFLAGS", rustflags.join(" "));
139150
}
140151
cmd.run().context("cannot build Rust Analyzer")?;
141152

0 commit comments

Comments
 (0)