Move disabling incr comp and denying warnings to the CI config

This commit is contained in:
bjorn3 2024-04-05 13:56:21 +00:00
parent 603b2800f7
commit f269cdd805
6 changed files with 18 additions and 21 deletions

View File

@ -13,4 +13,7 @@ task:
- ./y.sh prepare
test_script:
- . $HOME/.cargo/env
# Disabling incr comp reduces cache size and incr comp doesn't save as much
# on CI anyway.
- export CARGO_BUILD_INCREMENTAL=false
- ./y.sh test

View File

@ -10,6 +10,14 @@ defaults:
permissions: {}
env:
# Disabling incr comp reduces cache size and incr comp doesn't save as much
# on CI anyway.
CARGO_BUILD_INCREMENTAL: false
# Rust's CI denies warnings. Deny them here too to ensure subtree syncs don't
# fail because of warnings.
RUSTFLAGS: "-Dwarnings"
jobs:
rustfmt:
runs-on: ubuntu-latest

View File

@ -3,7 +3,7 @@
use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_file_name;
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
use crate::utils::{is_ci, is_ci_opt, maybe_incremental, CargoProject, Compiler, LogGroup};
use crate::utils::{is_ci, is_ci_opt, CargoProject, Compiler, LogGroup};
pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
@ -16,16 +16,12 @@ pub(crate) fn build_backend(
let _group = LogGroup::guard("Build backend");
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
maybe_incremental(&mut cmd);
let mut rustflags = rustflags_from_env("RUSTFLAGS");
rustflags.push("-Zallow-features=rustc_private".to_owned());
if is_ci() {
// Deny warnings on CI
rustflags.push("-Dwarnings".to_owned());
if !is_ci_opt() {
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
cmd.env("CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS", "true");

View File

@ -6,8 +6,7 @@
use crate::path::{Dirs, RelPath};
use crate::rustc_info::get_file_name;
use crate::utils::{
maybe_incremental, remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler,
LogGroup,
remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler, LogGroup,
};
use crate::{config, CodegenBackend, SysrootKind};
@ -270,7 +269,6 @@ fn build_clif_sysroot_for_triple(
}
compiler.rustflags.extend(rustflags);
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
maybe_incremental(&mut build_cmd);
if channel == "release" {
build_cmd.arg("--release");
}

View File

@ -61,15 +61,17 @@ fn main() {
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
if is_ci() {
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
env::set_var("CARGO_BUILD_INCREMENTAL", "false");
if !is_ci_opt() {
// Enable the Cranelift verifier
env::set_var("CG_CLIF_ENABLE_VERIFIER", "1");
}
}
// Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
env::set_var("CARGO_BUILD_INCREMENTAL", "true");
}
let mut args = env::args().skip(1);
let command = match args.next().as_deref() {
Some("prepare") => Command::Prepare,

View File

@ -288,13 +288,3 @@ fn drop(&mut self) {
IN_GROUP.store(false, Ordering::SeqCst);
}
}
pub(crate) fn maybe_incremental(cmd: &mut Command) {
if is_ci() || std::env::var("CARGO_BUILD_INCREMENTAL").map_or(false, |val| val == "false") {
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
} else {
// Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled
cmd.env("CARGO_BUILD_INCREMENTAL", "true");
}
}