From 6cd8d1b7f867e332e526f6eba75057e728b656cf Mon Sep 17 00:00:00 2001 From: LinusChen-yf Date: Wed, 2 Apr 2025 19:52:51 +0800 Subject: [PATCH 1/2] fix: clang-cl detect warning on MacOS --- src/tool.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/tool.rs b/src/tool.rs index e430d281d..e6ce66701 100644 --- a/src/tool.rs +++ b/src/tool.rs @@ -199,21 +199,12 @@ impl Tool { compiler_detect_output.warnings = compiler_detect_output.debug; let stdout = run_output( - Command::new(path).arg("-E").arg(tmp.path()), + Command::new(path).arg("-E").arg("--").arg(tmp.path()), &compiler_detect_output, )?; let stdout = String::from_utf8_lossy(&stdout); - if stdout.contains("-Wslash-u-filename") { - let stdout = run_output( - Command::new(path).arg("-E").arg("--").arg(tmp.path()), - &compiler_detect_output, - )?; - let stdout = String::from_utf8_lossy(&stdout); - guess_family_from_stdout(&stdout, path, args, cargo_output) - } else { - guess_family_from_stdout(&stdout, path, args, cargo_output) - } + guess_family_from_stdout(&stdout, path, args, cargo_output) } let detect_family = |path: &Path, args: &[String]| -> Result { let cache_key = [path.as_os_str()] From f15ad301bdfe3e06d0792cdbfa73e89572cbca73 Mon Sep 17 00:00:00 2001 From: LinusChen-yf Date: Thu, 3 Apr 2025 11:03:22 +0800 Subject: [PATCH 2/2] fix: missing clang-cl judgment --- src/tool.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/tool.rs b/src/tool.rs index e6ce66701..bee79a5c5 100644 --- a/src/tool.rs +++ b/src/tool.rs @@ -198,10 +198,19 @@ impl Tool { let mut compiler_detect_output = cargo_output.clone(); compiler_detect_output.warnings = compiler_detect_output.debug; - let stdout = run_output( - Command::new(path).arg("-E").arg("--").arg(tmp.path()), - &compiler_detect_output, - )?; + let mut detect_cmd = Command::new(path); + // If it is clang-cl, use -- to separate the path + // to prevent confusion between the path and the parameter. + let is_clang_cl = path + .file_name() + .map_or(false, |name| name.to_string_lossy().contains("clang-cl")); + if is_clang_cl { + detect_cmd.arg("-E").arg("--").arg(tmp.path()); + } else { + detect_cmd.arg("-E").arg(tmp.path()); + } + + let stdout = run_output(&mut detect_cmd, &compiler_detect_output)?; let stdout = String::from_utf8_lossy(&stdout); guess_family_from_stdout(&stdout, path, args, cargo_output)