diff --git a/src/lib.rs b/src/lib.rs index b703ac36c..d5aea846a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1342,7 +1342,14 @@ impl Build { if !msvc || !is_asm || !is_arm { cmd.arg("-c"); } - if self.cuda && self.files.len() > 1 { + if self.cuda + && self + .files + .iter() + .filter(|file| file.extension() == Some(OsStr::new("cu"))) + .count() + > 1 + { cmd.arg("--device-c"); } if compiler.family == (ToolFamily::Msvc { clang_cl: true }) { @@ -1999,7 +2006,14 @@ impl Build { self.assemble_progressive(dst, chunk)?; } - if self.cuda { + if self.cuda + && self + .files + .iter() + .filter(|file| file.extension() == Some(OsStr::new("cu"))) + .count() + > 0 + { // Link the device-side code and add it to the target library, // so that non-CUDA linker can link the final binary.