diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c82cd6d08..3c4b828ec8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -161,6 +161,8 @@ jobs: with: components: rust-src - uses: mkroening/rust-toolchain-toml@main + - run: rustup component add llvm-tools + working-directory: . - uses: mkroening/rust-toolchain-toml@main with: toolchain-file: 'kernel/rust-toolchain.toml' diff --git a/xtask/src/ci/build.rs b/xtask/src/ci/build.rs index 5e69ec8c1a..cc82db4dfb 100644 --- a/xtask/src/ci/build.rs +++ b/xtask/src/ci/build.rs @@ -1,8 +1,9 @@ +use std::env; use std::path::PathBuf; +use std::process::Command; use anyhow::Result; use clap::Args; -use xshell::cmd; use crate::cargo_build::CargoBuild; @@ -24,23 +25,25 @@ impl Build { eprintln!("::group::cargo build") } - let sh = crate::sh()?; + let mut cargo = cargo(); - let _push_env = if self.package.contains("rftrace") { - Some(sh.push_env( + if self.package.contains("rftrace") { + cargo.env( "RUSTFLAGS", "-Zinstrument-mcount -Cpasses=ee-instrument", - )) - } else { - None + ); }; - sh.change_dir(".."); - cmd!(sh, "cargo build") + cargo + .current_dir("..") + .arg("build") .args(self.cargo_build.artifact.arch.ci_cargo_args()) .args(self.cargo_build.cargo_build_args()) - .args(&["--package", self.package.as_str()]) - .run()?; + .args(["--package", self.package.as_str()]); + + eprintln!("$ {cargo:?}"); + let status = cargo.status()?; + assert!(status.success()); if super::in_ci() { eprintln!("::endgroup::") @@ -53,3 +56,31 @@ impl Build { self.cargo_build.artifact.ci_image(&self.package) } } + +fn cargo() -> Command { + let cargo = { + let exe = format!("cargo{}", env::consts::EXE_SUFFIX); + // On windows, the userspace toolchain ends up in front of the rustup proxy in $PATH. + // To reach the rustup proxy nonetheless, we explicitly query $CARGO_HOME. + let mut cargo_home = PathBuf::from(env::var_os("CARGO_HOME").unwrap()); + cargo_home.push("bin"); + cargo_home.push(&exe); + if cargo_home.exists() { + cargo_home + } else { + PathBuf::from(exe) + } + }; + + let mut cargo = Command::new(cargo); + + // Remove rust-toolchain-specific environment variables from kernel cargo + cargo.env_remove("LD_LIBRARY_PATH"); + env::vars() + .filter(|(key, _value)| key.starts_with("CARGO") || key.starts_with("RUST")) + .for_each(|(key, _value)| { + cargo.env_remove(&key); + }); + + cargo +}