Skip to content

Commit becdc41

Browse files
committed
Fix comma-separated llvm-args parsing in CodegenArgs::from_session
Previously, when multiple llvm-args were passed as comma-separated values (e.g., `-C llvm-args=--disassemble-fn=foo,--allow-fragment-no-output`), they were treated as a single argument instead of being properly split. This change modifies CodegenArgs::from_session to: - Split comma-separated llvm-args into individual arguments - Preserve existing functionality for single arguments - Enable proper parsing of multiple compiler flags Fixes parameter processing for compound llvm-args usage in rust-gpu.
1 parent 4bd6b70 commit becdc41

File tree

1 file changed

+14
-1
lines changed
  • crates/rustc_codegen_spirv/src/codegen_cx

1 file changed

+14
-1
lines changed

crates/rustc_codegen_spirv/src/codegen_cx/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,14 @@ pub struct CodegenArgs {
337337

338338
impl CodegenArgs {
339339
pub fn from_session(sess: &Session) -> Self {
340-
match CodegenArgs::parse(&sess.opts.cg.llvm_args) {
340+
// Split comma-separated arguments within each llvm_args entry
341+
// This handles cases like "--disassemble-fn=foo,--allow-fragment-no-output"
342+
let expanded_args: Vec<String> = sess.opts.cg.llvm_args
343+
.iter()
344+
.flat_map(|arg| arg.split(',').map(|s| s.to_string()))
345+
.collect();
346+
347+
match CodegenArgs::parse(&expanded_args) {
341348
Ok(ok) => ok,
342349
Err(err) => sess
343350
.dcx()
@@ -420,6 +427,11 @@ impl CodegenArgs {
420427
"disables SPIR-V Storage Class inference",
421428
);
422429
opts.optflag("", "no-structurize", "disables CFG structurization");
430+
opts.optflag(
431+
"",
432+
"allow-fragment-no-output",
433+
"allow fragment shaders with no output operations",
434+
);
423435

424436
opts.optmulti(
425437
"",
@@ -628,6 +640,7 @@ impl CodegenArgs {
628640
// FIXME(eddyb) deduplicate between `CodegenArgs` and `linker::Options`.
629641
spirv_metadata,
630642
keep_link_exports: false,
643+
allow_fragment_no_output: matches.opt_present("allow-fragment-no-output"),
631644

632645
// NOTE(eddyb) these are debugging options that used to be env vars
633646
// (for more information see `docs/src/codegen-args.md`).

0 commit comments

Comments
 (0)