Skip to content

Commit e366e5e

Browse files
committed
use new CargoCmd from spirv-builder to handle env vars centrally
1 parent 395f754 commit e366e5e

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exclude = [
1313
resolver = "2"
1414

1515
[workspace.dependencies]
16-
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "e6d017d5504c4441a84edcc27f4eca61de6fc8cf", default-features = false }
16+
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "de5a583abc748fa617b2b0b3065b2b85987da8ec", default-features = false }
1717
anyhow = "1.0.94"
1818
clap = { version = "4.5.37", features = ["derive"] }
1919
crossterm = "0.28.1"

crates/cargo-gpu/src/install.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::target_specs::update_target_specs_files;
77
use crate::{cache_dir, spirv_source::SpirvSource};
88
use anyhow::Context as _;
99
use spirv_builder::SpirvBuilder;
10-
use std::env;
1110
use std::path::{Path, PathBuf};
1211

1312
/// Represents a functional backend installation, whether it was cached or just installed.
@@ -279,8 +278,8 @@ package = "rustc_codegen_spirv"
279278
.context("remove Cargo.lock")?;
280279
}
281280

282-
crate::user_output!("Compiling `rustc_codegen_spirv` from source {}\n", source,);
283-
let mut cargo = std::process::Command::new("cargo");
281+
crate::user_output!("Compiling `rustc_codegen_spirv` from source {}\n", source);
282+
let mut cargo = spirv_builder::cargo_cmd::CargoCmd::new();
284283
cargo
285284
.current_dir(&install_dir)
286285
.arg(format!("+{toolchain_channel}"))
@@ -289,24 +288,7 @@ package = "rustc_codegen_spirv"
289288
cargo.args(["-p", "rustc_codegen_spirv", "--lib"]);
290289
}
291290

292-
// Clear Cargo environment variables that we don't want to leak into the
293-
// inner invocation of Cargo and mess with our `rustc_codegen_spirv` build.
294-
for (key, _) in env::vars_os() {
295-
let remove = key.to_str().is_some_and(|st| {
296-
st.starts_with("CARGO_FEATURES_") || st.starts_with("CARGO_CFG_")
297-
});
298-
if remove {
299-
cargo.env_remove(key);
300-
}
301-
}
302-
cargo
303-
.env_remove("RUSTC")
304-
.env_remove("RUSTC_WRAPPER")
305-
.env_remove("RUSTFLAGS")
306-
// ignore any externally supplied target dir, we want to build it in our cache dir
307-
.env_remove("CARGO_TARGET_DIR");
308-
309-
log::debug!("building artifacts with `{cargo:?}`");
291+
log::debug!("building artifacts with `{cargo}`");
310292
cargo
311293
.stdout(std::process::Stdio::inherit())
312294
.stderr(std::process::Stdio::inherit())

0 commit comments

Comments
 (0)