From 61d16f9c1068af088e64698397062f878aa9ded1 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Sat, 30 Aug 2025 14:38:21 +0200 Subject: [PATCH 1/2] Implement `Default` for `InstalledBackend` --- crates/cargo-gpu/src/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cargo-gpu/src/install.rs b/crates/cargo-gpu/src/install.rs index cfbfdfb..e5f7359 100644 --- a/crates/cargo-gpu/src/install.rs +++ b/crates/cargo-gpu/src/install.rs @@ -10,7 +10,7 @@ use spirv_builder::SpirvBuilder; use std::path::{Path, PathBuf}; /// Represents a functional backend installation, whether it was cached or just installed. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] #[non_exhaustive] pub struct InstalledBackend { /// path to the `rustc_codegen_spirv` dylib From 0fdaba8a0ea40433949e9ef0549fb4a87107c02a Mon Sep 17 00:00:00 2001 From: firestar99 Date: Mon, 28 Jul 2025 15:19:29 +0200 Subject: [PATCH 2/2] target enum: fixup cargo gpu --- Cargo.lock | 38 ++++++++++++++++++++++++++++++--- Cargo.toml | 2 +- crates/cargo-gpu/src/install.rs | 14 ++++++------ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b68563..6755e31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,7 @@ dependencies = [ "env_logger", "log", "relative-path", - "rustc_codegen_spirv-target-specs", + "rustc_codegen_spirv-target-specs 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver", "serde", "serde_json", @@ -1053,10 +1053,20 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c89eaf493b3dfc730cda42a77014aad65e03213992c7afe0dff60a9f7d3dd94" +[[package]] +name = "rustc_codegen_spirv-target-specs" +version = "0.9.0" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=86842247a1b72e5e014ff84bdf1dc25cfc14f34c#86842247a1b72e5e014ff84bdf1dc25cfc14f34c" +dependencies = [ + "serde", + "strum", + "thiserror", +] + [[package]] name = "rustc_codegen_spirv-types" version = "0.9.0" -source = "git+https://github.com/Rust-GPU/rust-gpu?rev=3df836eb9d7b01344f52737bf9a310d1fb5a0c26#3df836eb9d7b01344f52737bf9a310d1fb5a0c26" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=86842247a1b72e5e014ff84bdf1dc25cfc14f34c#86842247a1b72e5e014ff84bdf1dc25cfc14f34c" dependencies = [ "rspirv", "serde", @@ -1236,7 +1246,7 @@ dependencies = [ [[package]] name = "spirv-builder" version = "0.9.0" -source = "git+https://github.com/Rust-GPU/rust-gpu?rev=3df836eb9d7b01344f52737bf9a310d1fb5a0c26#3df836eb9d7b01344f52737bf9a310d1fb5a0c26" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=86842247a1b72e5e014ff84bdf1dc25cfc14f34c#86842247a1b72e5e014ff84bdf1dc25cfc14f34c" dependencies = [ "cargo_metadata", "clap", @@ -1244,6 +1254,7 @@ dependencies = [ "memchr", "notify", "raw-string", + "rustc_codegen_spirv-target-specs 0.9.0 (git+https://github.com/Rust-GPU/rust-gpu?rev=86842247a1b72e5e014ff84bdf1dc25cfc14f34c)", "rustc_codegen_spirv-types", "semver", "serde", @@ -1263,6 +1274,27 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "syn" version = "2.0.101" diff --git a/Cargo.toml b/Cargo.toml index 75d6799..e44b714 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ exclude = [ resolver = "2" [workspace.dependencies] -spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "3df836eb9d7b01344f52737bf9a310d1fb5a0c26", default-features = false } +spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "86842247a1b72e5e014ff84bdf1dc25cfc14f34c", default-features = false } anyhow = "1.0.98" clap = { version = "4.5.41", features = ["derive"] } crossterm = "0.29.0" diff --git a/crates/cargo-gpu/src/install.rs b/crates/cargo-gpu/src/install.rs index e5f7359..7f7fc6a 100644 --- a/crates/cargo-gpu/src/install.rs +++ b/crates/cargo-gpu/src/install.rs @@ -6,7 +6,7 @@ use crate::spirv_source::{ use crate::target_specs::update_target_specs_files; use crate::{cache_dir, spirv_source::SpirvSource}; use anyhow::Context as _; -use spirv_builder::SpirvBuilder; +use spirv_builder::{IntoSpirvTarget, SpirvBuilder}; use std::path::{Path, PathBuf}; /// Represents a functional backend installation, whether it was cached or just installed. @@ -32,7 +32,7 @@ impl InstalledBackend { pub fn to_spirv_builder( &self, path_to_crate: impl AsRef, - target: impl Into, + target: impl IntoSpirvTarget, ) -> SpirvBuilder { let mut builder = SpirvBuilder::new(path_to_crate, target); self.configure_spirv_builder(&mut builder) @@ -48,10 +48,12 @@ impl InstalledBackend { pub fn configure_spirv_builder(&self, builder: &mut SpirvBuilder) -> anyhow::Result<()> { builder.rustc_codegen_spirv_location = Some(self.rustc_codegen_spirv_location.clone()); builder.toolchain_overwrite = Some(self.toolchain_channel.clone()); - builder.path_to_target_spec = Some(self.target_spec_dir.join(format!( - "{}.json", - builder.target.as_ref().context("expect target to be set")? - ))); + let file_name = builder + .target + .clone() + .context("expect target to be set")?? + .target_json_file_name(); + builder.path_to_target_spec = Some(self.target_spec_dir.join(file_name)); Ok(()) } }