Skip to content

Commit 126f739

Browse files
timon-schellingFirestar99
authored andcommitted
nix: use rustc_codegen_spirv.so from nix
1 parent dc74389 commit 126f739

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

node-graph/graster-nodes/shaders/build.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
66

77
let shader_crate = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/.."));
88

9-
// install the toolchain and build the `rustc_codegen_spirv` codegen backend with it
10-
let backend = cargo_gpu::Install::from_shader_crate(shader_crate.clone()).run()?;
9+
let rustc_codegen_spirv_path = std::env::var("RUSTC_CODEGEN_SPIRV_PATH").unwrap_or_default();
10+
let mut builder = if rustc_codegen_spirv_path.is_empty() {
11+
// install the toolchain and build the `rustc_codegen_spirv` codegen backend with it
12+
cargo_gpu::Install::from_shader_crate(shader_crate.clone())
13+
.run()?
14+
.to_spirv_builder(shader_crate, "spirv-unknown-naga-wgsl")
15+
} else {
16+
// use the `RUSTC_CODEGEN_SPIRV` environment variable to find the codegen backend
17+
let mut builder = cargo_gpu::spirv_builder::SpirvBuilder::new(shader_crate.clone(), "spirv-unknown-naga-wgsl");
18+
builder.rustc_codegen_spirv_location = Some(PathBuf::from(rustc_codegen_spirv_path));
19+
builder.toolchain_overwrite = Some("nightly".to_string());
20+
builder.path_to_target_spec = Some(PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/spirv-unknown-naga-wgsl.json")));
21+
builder
22+
};
1123

1224
// build the shader crate
13-
let mut builder = backend.to_spirv_builder(shader_crate, "spirv-unknown-naga-wgsl");
1425
builder.print_metadata = MetadataPrintout::DependencyOnly;
1526
builder.spirv_metadata = SpirvMetadata::Full;
1627
builder.shader_crate_features.default_features = false;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"allows-weak-linkage": false,
3+
"arch": "spirv",
4+
"crt-objects-fallback": "false",
5+
"crt-static-allows-dylibs": true,
6+
"crt-static-respected": true,
7+
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
8+
"dll-prefix": "",
9+
"dll-suffix": ".spv.json",
10+
"dynamic-linking": true,
11+
"emit-debug-gdb-scripts": false,
12+
"env": "naga-wgsl",
13+
"linker-flavor": "unix",
14+
"linker-is-gnu": false,
15+
"llvm-target": "spirv-unknown-naga-wgsl",
16+
"main-needs-argc-argv": false,
17+
"metadata": {
18+
"description": null,
19+
"host_tools": null,
20+
"std": null,
21+
"tier": null
22+
},
23+
"panic-strategy": "abort",
24+
"simd-types-indirect": false,
25+
"target-pointer-width": "32"
26+
}

0 commit comments

Comments
 (0)