Skip to content

Commit 42ce2f1

Browse files
trxcllntsylvestre
authored andcommitted
Bail on nvcc -time and nvcc -fdevice-time-trace flags
1 parent f89b7a1 commit 42ce2f1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/compiler/nvcc.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,8 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
13951395
flag!("--expt-relaxed-constexpr", PreprocessorArgumentFlag),
13961396
flag!("--extended-lambda", PreprocessorArgumentFlag),
13971397
flag!("--fatbin", DoCompilation),
1398+
take_arg!("--fdevice-time-trace", OsString, CanBeSeparated, TooHard),
1399+
take_arg!("--fdevice-time-trace=", OsString, Concatenated, TooHard),
13981400
take_arg!("--generate-code", OsString, CanBeSeparated('='), PassThrough),
13991401
flag!("--generate-dependencies-with-compile", NeedDepTarget),
14001402
flag!("--generate-nonsystem-dependencies-with-compile", NeedDepTarget),
@@ -1415,6 +1417,8 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
14151417
flag!("--save-temps", UnhashedFlag),
14161418
take_arg!("--system-include", PathBuf, CanBeSeparated('='), PreprocessorArgumentPath),
14171419
take_arg!("--threads", OsString, CanBeSeparated('='), Unhashed),
1420+
take_arg!("--time", OsString, CanBeSeparated, TooHard),
1421+
take_arg!("--time=", OsString, Concatenated, TooHard),
14181422
take_arg!("--x", OsString, CanBeSeparated('='), Language),
14191423

14201424
take_arg!("-Werror", OsString, CanBeSeparated('='), PreprocessorArgument),
@@ -1434,6 +1438,8 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
14341438
flag!("-expt-relaxed-constexpr", PreprocessorArgumentFlag),
14351439
flag!("-extended-lambda", PreprocessorArgumentFlag),
14361440
flag!("-fatbin", DoCompilation),
1441+
take_arg!("-fdevice-time-trace", OsString, CanBeSeparated, TooHard),
1442+
take_arg!("-fdevice-time-trace=", OsString, Concatenated, TooHard),
14371443
take_arg!("-gencode", OsString, CanBeSeparated('='), PassThrough),
14381444
take_arg!("-isystem", PathBuf, CanBeSeparated('='), PreprocessorArgumentPath),
14391445
flag!("-keep", UnhashedFlag),
@@ -1446,6 +1452,8 @@ counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
14461452
flag!("-save-temps", UnhashedFlag),
14471453
take_arg!("-t", OsString, CanBeSeparated, Unhashed),
14481454
take_arg!("-t=", OsString, Concatenated, Unhashed),
1455+
take_arg!("-time", OsString, CanBeSeparated, TooHard),
1456+
take_arg!("-time=", OsString, Concatenated, TooHard),
14491457
take_arg!("-x", OsString, CanBeSeparated('='), Language),
14501458
]);
14511459

@@ -1955,6 +1963,7 @@ mod test {
19551963
])
19561964
);
19571965
}
1966+
19581967
#[test]
19591968
fn test_parse_cant_cache_flags() {
19601969
assert_eq!(
@@ -1982,5 +1991,52 @@ mod test {
19821991
CompilerArguments::CannotCache("-M", None),
19831992
parse_arguments_nvc(stringvec!["-x", "cu", "-c", "foo.c", "-o", "foo.o", "-M"])
19841993
);
1994+
1995+
// nvcc arg parsing is very permissive, so all these are valid and should yield CannotCache
1996+
for arg in [
1997+
"-fdevice-time-trace",
1998+
"--fdevice-time-trace",
1999+
"-time",
2000+
"--time",
2001+
] {
2002+
// {-,--}fdevice-time-trace
2003+
assert_eq!(
2004+
CompilerArguments::CannotCache(arg, None),
2005+
parse_arguments_gcc(stringvec![arg])
2006+
);
2007+
// {-,--}fdevice-time-trace -
2008+
assert_eq!(
2009+
CompilerArguments::CannotCache(arg, None),
2010+
parse_arguments_msvc(stringvec![arg, "-"])
2011+
);
2012+
// {-,--}fdevice-time-trace-
2013+
assert_eq!(
2014+
CompilerArguments::CannotCache(arg, None),
2015+
parse_arguments_msvc(stringvec![format!("{arg}-")])
2016+
);
2017+
// {-,--}fdevice-time-trace flamegraph.json
2018+
assert_eq!(
2019+
CompilerArguments::CannotCache(arg, None),
2020+
parse_arguments_nvc(stringvec![arg, "flamegraph.json"])
2021+
);
2022+
}
2023+
2024+
for arg_with_separator in [
2025+
"-fdevice-time-trace=",
2026+
"--fdevice-time-trace=",
2027+
"-time=",
2028+
"--time=",
2029+
] {
2030+
// {-,--}fdevice-time-trace=-
2031+
assert_eq!(
2032+
CompilerArguments::CannotCache(arg_with_separator, None),
2033+
parse_arguments_msvc(stringvec![format!("{arg_with_separator}-")])
2034+
);
2035+
// {-,--}fdevice-time-trace=flamegraph.json
2036+
assert_eq!(
2037+
CompilerArguments::CannotCache(arg_with_separator, None),
2038+
parse_arguments_nvc(stringvec![format!("{arg_with_separator}flamegraph.json")])
2039+
);
2040+
}
19852041
}
19862042
}

0 commit comments

Comments
 (0)