From 396c94121cba10bc7a41fb0b6ec0debeb7669c68 Mon Sep 17 00:00:00 2001 From: ZRHann <2829442630@qq.com> Date: Tue, 12 May 2026 19:30:16 +0800 Subject: [PATCH 1/4] feat(nvcc): support argument --- src/compiler/gcc.rs | 1 + src/compiler/nvcc.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/compiler/gcc.rs b/src/compiler/gcc.rs index 7bd4f96891..f8391563be 100644 --- a/src/compiler/gcc.rs +++ b/src/compiler/gcc.rs @@ -470,6 +470,7 @@ where } } Argument::Raw(ref val) => { + println!("Saw raw argument: {:?}", val); if input_arg.is_some() { multiple_input = true; multiple_input_files.push(val.clone()); diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index 3b05ab3516..68a9e767bc 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1417,6 +1417,7 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ take_arg!("--generate-code", OsString, CanBeSeparated(b'='), PassThrough), flag!("--generate-dependencies-with-compile", NeedDepTarget), flag!("--generate-nonsystem-dependencies-with-compile", NeedDepTarget), + take_arg!("--dependency-output", PathBuf, Separated, DepArgumentPath), take_arg!("--gpu-architecture", OsString, CanBeSeparated(b'='), PassThrough), take_arg!("--gpu-code", OsString, CanBeSeparated(b'='), PassThrough), take_arg!("--include-path", PathBuf, CanBeSeparated(b'='), PreprocessorArgumentPath), @@ -1650,6 +1651,16 @@ mod test { assert_eq!(ovec!["-ccbin", "/usr/bin/", "-c"], a.common_args); } + // Without --dependency-output in nvcc::ARGS, its value (foo.o.d) is treated as an input file + // and the real .cu becomes a second input file, triggering "multiple input files". + // -c is required so gcc parser recognizes this as compilation (not NotCompilation). + #[test] + fn test_parse_arguments_dependency_output() { + let a = parses!("--dependency-output", "foo.o.d", "-c", "foo.cu"); + assert_eq!(Some("foo.cu"), a.input.to_str()); // not foo.o.d + assert_eq!(ovec!["--dependency-output", "foo.o.d"], a.dependency_args); + } + #[test] fn test_parse_threads_argument_simple_cu() { let a = parses!( From d31a76d424a8b94f0e05ab005bd4776929f0fca6 Mon Sep 17 00:00:00 2001 From: ZRHann <2829442630@qq.com> Date: Tue, 12 May 2026 19:32:49 +0800 Subject: [PATCH 2/4] fix order --- src/compiler/nvcc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index 68a9e767bc..ebaa94e95e 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1406,6 +1406,7 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ take_arg!("--compiler-options", OsString, CanBeSeparated(b'='), PreprocessorArgument), flag!("--cubin", DoCompilation), take_arg!("--default-stream", OsString, CanBeSeparated(b'='), PassThrough), + take_arg!("--dependency-output", PathBuf, Separated, DepArgumentPath), flag!("--device-c", DoCompilation), flag!("--device-w", DoCompilation), flag!("--expt-extended-lambda", PreprocessorArgumentFlag), @@ -1417,7 +1418,6 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ take_arg!("--generate-code", OsString, CanBeSeparated(b'='), PassThrough), flag!("--generate-dependencies-with-compile", NeedDepTarget), flag!("--generate-nonsystem-dependencies-with-compile", NeedDepTarget), - take_arg!("--dependency-output", PathBuf, Separated, DepArgumentPath), take_arg!("--gpu-architecture", OsString, CanBeSeparated(b'='), PassThrough), take_arg!("--gpu-code", OsString, CanBeSeparated(b'='), PassThrough), take_arg!("--include-path", PathBuf, CanBeSeparated(b'='), PreprocessorArgumentPath), From cccaabbbce34e2e82d9db957c595a1ddcf761393 Mon Sep 17 00:00:00 2001 From: ZRHann <2829442630@qq.com> Date: Wed, 13 May 2026 14:53:07 +0800 Subject: [PATCH 3/4] rm debug code --- src/compiler/gcc.rs | 1 - src/compiler/nvcc.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/compiler/gcc.rs b/src/compiler/gcc.rs index f8391563be..7bd4f96891 100644 --- a/src/compiler/gcc.rs +++ b/src/compiler/gcc.rs @@ -470,7 +470,6 @@ where } } Argument::Raw(ref val) => { - println!("Saw raw argument: {:?}", val); if input_arg.is_some() { multiple_input = true; multiple_input_files.push(val.clone()); diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index ebaa94e95e..551330d624 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1651,9 +1651,6 @@ mod test { assert_eq!(ovec!["-ccbin", "/usr/bin/", "-c"], a.common_args); } - // Without --dependency-output in nvcc::ARGS, its value (foo.o.d) is treated as an input file - // and the real .cu becomes a second input file, triggering "multiple input files". - // -c is required so gcc parser recognizes this as compilation (not NotCompilation). #[test] fn test_parse_arguments_dependency_output() { let a = parses!("--dependency-output", "foo.o.d", "-c", "foo.cu"); From 451aa436ecefb3666ca90476c35d3e1d0c3b1d29 Mon Sep 17 00:00:00 2001 From: ZRHann <2829442630@qq.com> Date: Wed, 13 May 2026 14:54:22 +0800 Subject: [PATCH 4/4] rm comment --- src/compiler/nvcc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index 551330d624..f74205363c 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1654,7 +1654,7 @@ mod test { #[test] fn test_parse_arguments_dependency_output() { let a = parses!("--dependency-output", "foo.o.d", "-c", "foo.cu"); - assert_eq!(Some("foo.cu"), a.input.to_str()); // not foo.o.d + assert_eq!(Some("foo.cu"), a.input.to_str()); assert_eq!(ovec!["--dependency-output", "foo.o.d"], a.dependency_args); }