Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/dist.rs')
| -rw-r--r-- | xtask/src/dist.rs | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index dbfecdbe11..57a6a0eae1 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -45,11 +45,22 @@ impl flags::Dist { allocator, self.zig, self.pgo, + // Profiling requires debug information. + self.enable_profiling, )?; let release_tag = if stable { date_iso(sh)? } else { "nightly".to_owned() }; dist_client(sh, &version, &release_tag, &target)?; } else { - dist_server(sh, "0.0.0-standalone", &target, allocator, self.zig, self.pgo)?; + dist_server( + sh, + "0.0.0-standalone", + &target, + allocator, + self.zig, + self.pgo, + // Profiling requires debug information. + self.enable_profiling, + )?; } Ok(()) } @@ -92,9 +103,11 @@ fn dist_server( allocator: Malloc, zig: bool, pgo: Option<PgoTrainingCrate>, + dev_rel: bool, ) -> anyhow::Result<()> { let _e = sh.push_env("CFG_RELEASE", release); let _e = sh.push_env("CARGO_PROFILE_RELEASE_LTO", "thin"); + let _e = sh.push_env("CARGO_PROFILE_DEV_REL_LTO", "thin"); // Uncomment to enable debug info for releases. Note that: // * debug info is split on windows and macs, so it does nothing for those platforms, @@ -120,9 +133,20 @@ fn dist_server( None }; - let mut cmd = build_command(sh, command, &target_name, features); + let mut cmd = build_command(sh, command, &target_name, features, dev_rel); + let mut rustflags = Vec::new(); + if let Some(profile) = pgo_profile { - cmd = cmd.env("RUSTFLAGS", format!("-Cprofile-use={}", profile.to_str().unwrap())); + rustflags.push(format!("-Cprofile-use={}", profile.to_str().unwrap())); + } + + if target_name.ends_with("-windows-msvc") { + // https://github.com/rust-lang/rust-analyzer/issues/20970 + rustflags.push("-Ctarget-feature=+crt-static".to_owned()); + } + + if !rustflags.is_empty() { + cmd = cmd.env("RUSTFLAGS", rustflags.join(" ")); } cmd.run().context("cannot build Rust Analyzer")?; @@ -141,10 +165,12 @@ fn build_command<'a>( command: &str, target_name: &str, features: &[&str], + dev_rel: bool, ) -> Cmd<'a> { + let profile = if dev_rel { "dev-rel" } else { "release" }; cmd!( sh, - "cargo {command} --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --release" + "cargo {command} --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --profile {profile}" ) } |