Skip to content

feat(spirv-builder): warn when RUSTGPU_CODEGEN_ARGS replaces extra_args - #697

Closed
sorinirimies wants to merge 2 commits into
Rust-GPU:mainfrom
sorinirimies:feat/spirv-builder-warn-codegen-args-override
Closed

sorinirimies wants to merge 2 commits into
Rust-GPU:mainfrom
sorinirimies:feat/spirv-builder-warn-codegen-args-override

Conversation

@sorinirimies

Copy link
Copy Markdown

Stacked on #693 (uses its EnvOverrides); only the last commit is new here. Will rebase once #693 lands.

Summary

RUSTGPU_CODEGEN_ARGS replaces SpirvBuilder::extra_args (documented on the field, but easy to miss): setting it ad hoc, e.g. RUSTGPU_CODEGEN_ARGS=--dump-post-link=... for debugging, silently drops codegen args the build depends on. Behavior unchanged; now it says so.

 invoke_rustc
   env_overrides = EnvOverrides { .. }
+  if let Some(warning) = self.ignored_extra_args_warning(&env_overrides)
+    forward_rustc_warnings ? println!("cargo::warning={warning}") : log::warn!("{warning}")
   rustflags = self.rustflags(..)
warning: `RUSTGPU_CODEGEN_ARGS` is set, ignoring the codegen args set via `SpirvBuilder::extra_arg`: ["--from-builder"]

Evidence

New test tests::rustflags::warns_about_extra_args_replaced_by_env_codegen_args — warns only when both are set.

cargo test -p spirv-builder --features watch,clap: 9 passed. Clippy -D warnings clean.

Merge Danger

Door: two-way

Blast Radius: tiny — one extra warning line, only when both are set. Builds with -Dwarnings on the outer build script are unaffected (cargo::warning isn't a lint).

Sorin Albu-Irimies added 2 commits November 7, 2026 16:26
`invoke_rustc` was ~270 lines mixing env var reads, flag building and
running cargo, so flag building was only tested through difftests.

- `RUSTGPU_*` env vars are read once into `EnvOverrides`.
- New pure `rustflags`, `llvm_args` and `target_features` methods,
  with unit tests.

No behavior change: the resulting rustc invocation is identical.
`RUSTGPU_CODEGEN_ARGS` silently replaces any `SpirvBuilder::extra_arg`s,
so e.g. setting it for a `--dump-*` flag drops args the build relies on.
Now emits a warning listing the ignored args (as `cargo::warning` when
forwarding warnings from a build script, else via `log::warn!`).
@Firestar99 Firestar99 closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants