From 6e800fe85305a450d9b679bd732f1ef5ec6223de Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Mon, 23 Dec 2024 00:35:08 +1100 Subject: [PATCH] Fix compiler family detection issue with clang-cl on macOS Fixed #1327 --- src/tool.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tool.rs b/src/tool.rs index cf49b6b9..a7e3f926 100644 --- a/src/tool.rs +++ b/src/tool.rs @@ -140,8 +140,17 @@ impl Tool { tmp_file.sync_data()?; drop(tmp_file); + let mut cmd = Command::new(path); + cmd.arg("-E"); + if compiler.family == (ToolFamily::Msvc { clang_cl: true }) { + // #513: For `clang-cl`, separate flags/options from the input file. + // When cross-compiling macOS -> Windows, this avoids interpreting + // common `/Users/...` paths as the `/U` flag and triggering + // `-Wslash-u-filename` warning. + cmd.arg("--"); + } let stdout = run_output( - Command::new(path).arg("-E").arg(tmp.path()), + cmd.arg(tmp.path()), path, // When expanding the file, the compiler prints a lot of information to stderr // that it is not an error, but related to expanding itself.