Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exclude = [
resolver = "2"

[workspace.dependencies]
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "e97524f6b4816056b3edaa70c3e0e0c656392c05", default-features = false }
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "823b0c275e3eb8ab44ada5a6d989bdb57e8f9409", default-features = false }
anyhow = "1.0.98"
clap = { version = "4.5.41", features = ["derive"] }
crossterm = "0.29.0"
Expand All @@ -33,9 +33,6 @@ cargo-util-schemas = "0.8.2"
semver = "1.0.26"
dunce = "1.0.5"

# This crate MUST NEVER be upgraded, we need this particular "first" version to support old rust-gpu builds
legacy_target_specs = { package = "rustc_codegen_spirv-target-specs", version = "0.9.0", features = ["include_str"] }

[workspace.lints.rust]
missing_docs = "warn"

Expand Down
1 change: 0 additions & 1 deletion crates/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ default-run = "cargo-gpu"
cargo_metadata.workspace = true
anyhow.workspace = true
spirv-builder = { workspace = true, features = ["clap", "watch"] }
legacy_target_specs.workspace = true
clap.workspace = true
directories.workspace = true
env_logger.workspace = true
Expand Down
12 changes: 0 additions & 12 deletions crates/cargo-gpu/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use crate::spirv_source::{
get_channel_from_rustc_codegen_spirv_build_script, query_metadata, FindPackage as _,
};
use crate::target_specs::update_target_specs_files;
use crate::{cache_dir, spirv_source::SpirvSource};
use anyhow::Context as _;
use spirv_builder::SpirvBuilder;
Expand All @@ -17,8 +16,6 @@ pub struct InstalledBackend {
pub rustc_codegen_spirv_location: PathBuf,
/// toolchain channel name
pub toolchain_channel: String,
/// directory with target-specs json files
pub target_spec_dir: PathBuf,
}

impl InstalledBackend {
Expand Down Expand Up @@ -48,10 +45,6 @@ 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")?
)));
Ok(())
}
}
Expand Down Expand Up @@ -270,10 +263,6 @@ package = "rustc_codegen_spirv"
)?;
log::info!("selected toolchain channel `{toolchain_channel:?}`");

log::debug!("update_spec_files");
let target_spec_dir = update_target_specs_files(&source, &dummy_metadata, !skip_rebuild)
.context("writing target spec files")?;

log::debug!("ensure_toolchain_and_components_exist");
crate::install_toolchain::ensure_toolchain_and_components_exist(
&toolchain_channel,
Expand Down Expand Up @@ -336,7 +325,6 @@ package = "rustc_codegen_spirv"
Ok(InstalledBackend {
rustc_codegen_spirv_location: dest_dylib_path,
toolchain_channel,
target_spec_dir,
})
}
}
1 change: 0 additions & 1 deletion crates/cargo-gpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ mod lockfile;
mod metadata;
mod show;
mod spirv_source;
mod target_specs;
mod test;

pub use install::*;
Expand Down
44 changes: 1 addition & 43 deletions crates/cargo-gpu/src/show.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
//! Display various information about `cargo gpu`, eg its cache directory.

use crate::cache_dir;
use crate::spirv_source::{query_metadata, SpirvSource};
use crate::target_specs::update_target_specs_files;
use anyhow::bail;
use std::fs;
use std::path::Path;
use crate::spirv_source::SpirvSource;

/// Show the computed source of the spirv-std dependency.
#[derive(Clone, Debug, clap::Parser)]
Expand All @@ -26,9 +22,6 @@ pub enum Info {
Commitsh,
/// All the available SPIR-V capabilities that can be set with `--capabilities`
Capabilities,

/// All available SPIR-V targets
Targets(SpirvSourceDep),
}

/// `cargo gpu show`
Expand Down Expand Up @@ -70,13 +63,6 @@ impl Show {
println!(" {capability:?}");
}
}
Info::Targets(SpirvSourceDep { shader_crate }) => {
let (source, targets) = Self::available_spirv_targets_iter(shader_crate)?;
println!("All available targets for rust-gpu version '{source}':");
for target in targets {
println!("{target}");
}
}
}

Ok(())
Expand All @@ -90,32 +76,4 @@ impl Show {
let last_capability = spirv_builder::Capability::CacheControlsINTEL as u32;
(0..=last_capability).filter_map(spirv_builder::Capability::from_u32)
}

/// List all available spirv targets, note: the targets from compile time of cargo-gpu and those
/// in the cache-directory will be picked up.
fn available_spirv_targets_iter(
shader_crate: &Path,
) -> anyhow::Result<(SpirvSource, impl Iterator<Item = String>)> {
let source = SpirvSource::new(shader_crate, None, None)?;
let install_dir = source.install_dir()?;
if !install_dir.is_dir() {
bail!("rust-gpu version {} is not installed", source);
}
let dummy_metadata = query_metadata(&install_dir)?;
let target_specs_dir = update_target_specs_files(&source, &dummy_metadata, false)?;

let mut targets = fs::read_dir(target_specs_dir)?
.filter_map(|entry| {
let file = entry.ok()?;
if file.path().is_file() {
if let Some(target) = file.file_name().to_string_lossy().strip_suffix(".json") {
return Some(target.to_owned());
}
}
None
})
.collect::<Vec<_>>();
targets.sort();
Ok((source, targets.into_iter()))
}
}
135 changes: 0 additions & 135 deletions crates/cargo-gpu/src/target_specs.rs

This file was deleted.