This repository was archived by the owner on Apr 15, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
Build script complaining about cargo edition feature #99
Copy link
Copy link
Closed
Description
Im getting an error about cargo edition features when cargo gpu compiles my shader crate:
error: failed to parse manifest at` /workspace_root/shaders/Cargo.toml`
Caused by:
feature `edition2024` is required
The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.84.0-nightly (66221abde 2024-11-19)).
Consider adding `cargo-features = ["edition2024"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.
Error: BuildFailed
adding the line at the top of Cargo.toml (in both the workspace and shader crate) does work, but it also causes a warning about the feature no longer being neccesary (im guessing the warning comes from compiling the main crate, but the error would come from the shader crate being compiled)
just wondering if im doing something wrong, or if its just the version of rust nightly that something is currently using, and itll be fixed when the compiler version is changed?
here is the build script:
use cargo_gpu::spirv_builder::{MetadataPrintout, SpirvMetadata};
use std::path::PathBuf;
use std::{env, fs};
// mostly stolen from https://github.com/Rust-GPU/rust-gpu/issues/291#issuecomment-3004833358
fn main() -> Result<(), Box<dyn std::error::Error>> {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("Always set by Cargo; qed");
if target_arch != "spirv" {
let out_dir = env::var("OUT_DIR").expect("Always set by Cargo; qed");
// Skip compilation under Clippy, it doesn't work for some reason and isn't really needed
// anyway
if env::var("CLIPPY_ARGS").is_ok() {
let empty_file = PathBuf::from(out_dir).join("empty.bin");
fs::write(&empty_file, [])?;
println!("cargo::rustc-env=SHADER_PATH={}", empty_file.display());
return Ok(());
}
let profile = env::var("PROFILE").expect("Always set by Cargo; qed");
let shader_crate = PathBuf::from("./shaders");
// TODO: Workaround for https://github.com/Rust-GPU/cargo-gpu/issues/90
let cargo_target_dir = env::var("CARGO_TARGET_DIR").ok();
// SAFETY: Single-threaded
unsafe {
env::remove_var("CARGO_TARGET_DIR");
}
let backend = cargo_gpu::Install::from_shader_crate(shader_crate.clone()).run()?;
// TODO: Workaround for https://github.com/Rust-GPU/cargo-gpu/issues/90
if let Some(cargo_target_dir) = cargo_target_dir {
// SAFETY: Single-threaded
unsafe {
env::set_var("CARGO_TARGET_DIR", cargo_target_dir);
}
}
let mut builder = backend.to_spirv_builder(shader_crate, "spirv-unknown-vulkan1.2");
builder.print_metadata = MetadataPrintout::DependencyOnly;
builder.spirv_metadata = if profile == "debug" {
SpirvMetadata::NameVariables
} else {
SpirvMetadata::None
};
// Avoid Cargo deadlock
builder.target_dir_path.replace(out_dir.into());
let spv_result = builder.build()?;
let path_to_shaders = spv_result.module.unwrap_single();
let shader_fmt = "SPV";
println!("cargo::rustc-env=SHADER_PATH={}", path_to_shaders.display());
println!("cargo::rustc-env=SHADER_FMT={}", shader_fmt);
}
Ok(())
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
LegNeato commentedon Jul 8, 2025
yes, this should be fixed when one of the open PRs that bump the version of rustc we use in the codegen backend.
joshuamday commentedon Jul 9, 2025
Thanks, ill keep an eye out for when thats merged
nazar-pc commentedon Jul 10, 2025
Rust-GPU/rust-gpu#320 was merged, edition 2024 should be supported now
joshuamday commentedon Jul 10, 2025
yeah, it looks like it will be fixed as soon as the spirv-builder git hash is updated in the Cargo.toml
Firestar99 commentedon Jul 22, 2025
Actually, you just need to bump your
spirv-stdversion / git rev and it'll already work. We only need to bumpspirv-builderin this repo if there's some significant change in the "communication protocol" betweenspirv-builderand the codegen backend. See #91 (comment)