From 6e3b5052186447104e28fe746ef291141cdece41 Mon Sep 17 00:00:00 2001 From: roblabla Date: Thu, 31 Mar 2022 12:58:26 +0200 Subject: [PATCH] Fix clang-cl treating file as a /U arg. On MacOS, paths will likely start with /Users, but clang-cl treats /U as an argument, which leads to the source being mistaken for a flag. To avoid this, we can pass -- before the source to ensure argument parsing is disabled. --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e3a2b98b..ae996594 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1311,6 +1311,10 @@ impl Build { if self.cuda && self.files.len() > 1 { cmd.arg("--device-c"); } + // Ensure src is not treated as a clang-cl argument, like /U. + if compiler.family == (ToolFamily::Msvc { clang_cl: true }) { + cmd.arg("--"); + } cmd.arg(&obj.src); if cfg!(target_os = "macos") { self.fix_env_for_apple_os(&mut cmd)?;