Skip to content

Commit c9f007c

Browse files
committed
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.
1 parent ffac4a5 commit c9f007c

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/compiler/nvcc.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,9 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
14191419
take_arg!("--dependency-output", PathBuf, Separated, DepArgumentPath),
14201420
flag!("--device-c", DoCompilation),
14211421
flag!("--device-w", DoCompilation),
1422+
take_arg!("--diag-error", OsString, CanBeSeparated(b'='), PassThrough),
1423+
take_arg!("--diag-suppress", OsString, CanBeSeparated(b'='), PassThrough),
1424+
take_arg!("--diag-warn", OsString, CanBeSeparated(b'='), PassThrough),
14221425
flag!("--expt-extended-lambda", PreprocessorArgumentFlag),
14231426
flag!("--expt-relaxed-constexpr", PreprocessorArgumentFlag),
14241427
flag!("--extended-lambda", PreprocessorArgumentFlag),
@@ -1461,6 +1464,9 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
14611464
flag!("-cubin", DoCompilation),
14621465
flag!("-dc", DoCompilation),
14631466
take_arg!("-default-stream", OsString, CanBeSeparated(b'='), PassThrough),
1467+
take_arg!("-diag-error", OsString, CanBeSeparated(b'='), PassThrough),
1468+
take_arg!("-diag-suppress", OsString, CanBeSeparated(b'='), PassThrough),
1469+
take_arg!("-diag-warn", OsString, CanBeSeparated(b'='), PassThrough),
14641470
flag!("-dw", DoCompilation),
14651471
flag!("-expt-extended-lambda", PreprocessorArgumentFlag),
14661472
flag!("-expt-relaxed-constexpr", PreprocessorArgumentFlag),
@@ -2155,6 +2161,38 @@ mod test {
21552161
);
21562162
}
21572163

2164+
#[test]
2165+
fn test_parse_diag_suppress_separated() {
2166+
// The separated form (`--diag-suppress 1394,1388`, as OpenCV emits
2167+
// it) must not be mistaken for a second input file.
2168+
let a = parses!(
2169+
"-x=cu",
2170+
"-Xcudafe",
2171+
"--display_error_number",
2172+
"--diag-suppress",
2173+
"1394,1388",
2174+
"-diag-warn=68",
2175+
"-c",
2176+
"foo.c",
2177+
"-o",
2178+
"foo.o"
2179+
);
2180+
assert_eq!(Some("foo.c"), a.input.to_str());
2181+
assert_eq!(Language::Cuda, a.language);
2182+
assert_eq!(
2183+
ovec![
2184+
"-Xcudafe",
2185+
"--display_error_number",
2186+
"--diag-suppress",
2187+
"1394,1388",
2188+
"-diag-warn",
2189+
"68",
2190+
"-c"
2191+
],
2192+
a.common_args
2193+
);
2194+
}
2195+
21582196
#[test]
21592197
fn test_parse_no_capturing_of_xcompiler() {
21602198
let a = parses!(

0 commit comments

Comments
 (0)