From c9f007cf84641fc263775dcca33853a89857a483 Mon Sep 17 00:00:00 2001 From: Jonas Heinle Date: Wed, 19 Aug 2026 10:42:57 +0200 Subject: [PATCH] nvcc: accept the --diag-error/--diag-suppress/--diag-warn family nvcc's diagnostic-control options take an error-number list and accept the SEPARATED form (--diag-suppress 1394,1388). None of the family was in the argument table, so the separated value parsed as a bare token, was taken for a second input file, and the whole compile was rejected as CannotCache(multiple input files). Measured on OpenCV 5.0.0 with CUDA: every one of its 155 .cu compiles carries exactly this flag pair (via -Xcudafe --display_error_number --diag-suppress 1394,1388) and was forwarded uncached; with the entries added the same command is cached. Adds double- and single-dash forms, CanBeSeparated('='), PassThrough, plus a regression test for the separated shape. --- src/compiler/nvcc.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index c594f8e1f..ccfb5408a 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1419,6 +1419,9 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ take_arg!("--dependency-output", PathBuf, Separated, DepArgumentPath), flag!("--device-c", DoCompilation), flag!("--device-w", DoCompilation), + take_arg!("--diag-error", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("--diag-suppress", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("--diag-warn", OsString, CanBeSeparated(b'='), PassThrough), flag!("--expt-extended-lambda", PreprocessorArgumentFlag), flag!("--expt-relaxed-constexpr", PreprocessorArgumentFlag), flag!("--extended-lambda", PreprocessorArgumentFlag), @@ -1461,6 +1464,9 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ flag!("-cubin", DoCompilation), flag!("-dc", DoCompilation), take_arg!("-default-stream", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("-diag-error", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("-diag-suppress", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("-diag-warn", OsString, CanBeSeparated(b'='), PassThrough), flag!("-dw", DoCompilation), flag!("-expt-extended-lambda", PreprocessorArgumentFlag), flag!("-expt-relaxed-constexpr", PreprocessorArgumentFlag), @@ -2155,6 +2161,38 @@ mod test { ); } + #[test] + fn test_parse_diag_suppress_separated() { + // The separated form (`--diag-suppress 1394,1388`, as OpenCV emits + // it) must not be mistaken for a second input file. + let a = parses!( + "-x=cu", + "-Xcudafe", + "--display_error_number", + "--diag-suppress", + "1394,1388", + "-diag-warn=68", + "-c", + "foo.c", + "-o", + "foo.o" + ); + assert_eq!(Some("foo.c"), a.input.to_str()); + assert_eq!(Language::Cuda, a.language); + assert_eq!( + ovec![ + "-Xcudafe", + "--display_error_number", + "--diag-suppress", + "1394,1388", + "-diag-warn", + "68", + "-c" + ], + a.common_args + ); + } + #[test] fn test_parse_no_capturing_of_xcompiler() { let a = parses!(