Skip to content

Updating target json support #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions crates/rustc_codegen_spirv-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ pub use compile_result::*;
// HACK(eddyb) allows downstream crates to access the correct version directly.
pub use serde;
pub use serde_json;

/// directory with all the `target-specs` jsons for our codegen backend
pub const TARGET_SPEC_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/target-specs");
16 changes: 7 additions & 9 deletions crates/spirv-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#![doc = include_str!("../README.md")]

mod depfile;
mod target_specs;
#[cfg(feature = "watch")]
mod watch;

Expand All @@ -90,8 +89,8 @@ use std::process::{Command, Stdio};
use thiserror::Error;

pub use rustc_codegen_spirv_types::Capability;
pub use rustc_codegen_spirv_types::TARGET_SPEC_DIR;
pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
pub use target_specs::TARGET_SPECS;

#[derive(Debug, Error)]
#[non_exhaustive]
Expand Down Expand Up @@ -975,13 +974,12 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
// target_spec jsons, some later version requires them, some earlier
// version fails with them (notably our 0.9.0 release)
if toolchain_rustc_version >= Version::new(1, 76, 0) {
cargo
.arg("--target")
.arg(builder.path_to_target_spec.clone().unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("target-specs")
.join(format!("{}.json", target))
}));
cargo.arg("--target").arg(
builder
.path_to_target_spec
.clone()
.unwrap_or_else(|| PathBuf::from(format!("{}/{}.json", TARGET_SPEC_DIR, target))),
);
} else {
cargo.arg("--target").arg(target);
}
Expand Down
63 changes: 0 additions & 63 deletions crates/spirv-builder/src/target_specs.rs

This file was deleted.

2 changes: 1 addition & 1 deletion docs/src/writing-shader-crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ how to build SPIR-V. Here are a few things we need to mention there.

- Path to a spec of a target you're compiling for (see [platform support](./platform-support.md)).
These specs reside in a directory inside the `spirv-builder` crate and an example relative path
could look like `../rust-gpu/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json`.
could look like `../rust-gpu/crates/rustc_codegen_spirv-types/target-specs/spirv-unknown-spv1.3.json`.
- Absolute path to the `rustc_codegen_spirv` dynamic library that we built above.
- Some additional options.

Expand Down
1 change: 1 addition & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ use-compiled-tools = ["rustc_codegen_spirv/use-compiled-tools"]
[dependencies]
compiletest = { version = "0.9.0", package = "compiletest_rs" }
rustc_codegen_spirv.workspace = true
rustc_codegen_spirv-types.workspace = true
clap = { version = "4", features = ["derive"] }
itertools = "0.10.5"
6 changes: 2 additions & 4 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::Parser;
use itertools::Itertools as _;
use rustc_codegen_spirv_types::TARGET_SPEC_DIR;
use std::{
env, io,
path::{Path, PathBuf},
Expand Down Expand Up @@ -30,10 +31,7 @@ impl Opt {
const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-";

fn target_spec_json(target: &str) -> String {
format!(
"{}/../crates/spirv-builder/target-specs/{target}.json",
env!("CARGO_MANIFEST_DIR")
)
format!("{TARGET_SPEC_DIR}/{target}.json")
}

#[derive(Copy, Clone)]
Expand Down