Rust-GPU / Rust-GPU/rust-gpu

SPIR-V codegen complains about capabilities despite understanding them properly

Open
#324 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

I was trying to do this:

#[cfg(all(target_arch = "spirv", not(target_feature = "Int64")))]

And despite I see similar code in spirv-std, I'm getting a warning:

  warning: unexpected `cfg` condition value: `Int64`
    --> ../src/shader.rs:13:15
     |
  13 | #[cfg(all(target_arch = "spirv", not(target_feature = "Int64")))]
     |                                      ^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 251 more
     = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
     = note: `#[warn(unexpected_cfgs)]` on by default

I did some more testing. SPIR-V codegen backend actually understands both target_arch = "spirv" and target_feature = "Int64", here is a simple test case:

#[cfg(all(target_arch = "spirv", target_feature = "Int64"))]
compile_error!("Hello");

Yet it only generates a warning for target_feature = "Int64" and not target_arch = "spirv".

Regular rustc, obviously, complains about either unless unexpected_cfgs is used to suppress the warning. I don't think this is supposed to happen, both should be accepted without warnings by SPIR-V codegen.

Originally posted by @nazar-pc in https://github.com/Rust-GPU/rust-gpu/discussions/304

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning with the issue's cfg examples and inspect the SPIR-V codegen backend's handling of target_arch and target_feature. Compare its accepted configuration values with the unexpected_cfgs check; done means both spirv and Int64 compile without warnings while the demonstrated compile_error behavior still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.