Skip to content

warning: Compiler family detection failed on MacOS #1445

Open
@LinusChen-yf

Description

@LinusChen-yf

When cross-compiling for Windows MSVC on macOS, I encounter a warning. My local machine has clang-cl installed, and the compiled output appears to be normal. The warning is as follows:

warning: VibeService@0.1.0: Compiler family detection failed due to error: ToolExecError: command did not execute successfully (status code exit status: 1): "clang-cl" "-E" "/Users/linuschen/rust_projects/my_project/target/x86_64-pc-windows-msvc/release/build/MyProject-0a0478fd59c1ac07/out/11385383916581809335detect_compiler_family.c"

I found that there was an issue before, but I still encountered this problem in the latest version 1.2.17
#1327

I found the problem by debugging the source code. After the first run_output judgment failed, an error was directly returned, and there was no chance to judge stdout.contains("-Wslash-u-filename"), which caused a warning to be thrown.

cc-rs/src/tool.rs

Lines 201 to 216 in 59578ad

let stdout = run_output(
Command::new(path).arg("-E").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)
}

I want to modify run_output so that there is output when it fails to determine whether it is a real failure. However, if the child fails to execute and I try to print stdout, it is empty, so I don't know if there is a better way to modify it.

pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Vec<u8>, Error> {
// We specifically need the output to be captured, so override default
let mut captured_cargo_output = cargo_output.clone();
captured_cargo_output.output = OutputKind::Capture;
let mut child = spawn(cmd, &captured_cargo_output)?;
let mut stdout = vec![];
child
.stdout
.take()
.unwrap()
.read_to_end(&mut stdout)
.unwrap();
// Don't care about this output, use the normal settings
wait_on_child(cmd, &mut child, cargo_output)?;
Ok(stdout)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-appleApple targets and toolchainsO-windowsWindows targets and toolchains

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions