Do not use force-always-assert in xtask install by default

But add a flag to do so.
This commit is contained in:
Chayim Refael Friedman 2025-10-16 13:08:27 +03:00
parent 082ecd8f73
commit e9bba4f598
2 changed files with 24 additions and 3 deletions

View file

@ -49,6 +49,9 @@ xflags::xflags! {
/// build in release with debug info set to 2.
optional --dev-rel
/// Make `never!()`, `always!()` etc. panic instead of just logging an error.
optional --force-always-assert
/// Apply PGO optimizations
optional --pgo pgo: PgoTrainingCrate
}
@ -124,6 +127,7 @@ pub struct Install {
pub jemalloc: bool,
pub proc_macro_server: bool,
pub dev_rel: bool,
pub force_always_assert: bool,
pub pgo: Option<PgoTrainingCrate>,
}
@ -300,7 +304,12 @@ impl Install {
} else {
Malloc::System
};
Some(ServerOpt { malloc, dev_rel: self.dev_rel, pgo: self.pgo.clone() })
Some(ServerOpt {
malloc,
dev_rel: self.dev_rel,
pgo: self.pgo.clone(),
force_always_assert: self.force_always_assert,
})
}
pub(crate) fn proc_macro_server(&self) -> Option<ProcMacroServerOpt> {
if !self.proc_macro_server {

View file

@ -39,6 +39,18 @@ pub(crate) struct ServerOpt {
pub(crate) malloc: Malloc,
pub(crate) dev_rel: bool,
pub(crate) pgo: Option<PgoTrainingCrate>,
pub(crate) force_always_assert: bool,
}
impl ServerOpt {
fn to_features(&self) -> Vec<&'static str> {
let mut features = Vec::new();
features.extend(self.malloc.to_features());
if self.force_always_assert {
features.extend(["--features", "force-always-assert"]);
}
features
}
}
pub(crate) struct ProcMacroServerOpt {
@ -136,7 +148,7 @@ fn install_client(sh: &Shell, client_opt: ClientOpt) -> anyhow::Result<()> {
}
fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
let features = opts.malloc.to_features();
let features = &opts.to_features();
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
let mut install_cmd = cmd!(
@ -148,7 +160,7 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
let target = detect_target(sh);
let build_cmd = cmd!(
sh,
"cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --profile={profile} --locked --features force-always-assert {features...}"
"cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --profile={profile} --locked {features...}"
);
let profile = crate::pgo::gather_pgo_profile(sh, build_cmd, &target, train_crate)?;