Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detect family: should detect emscripten as clang, closes #1185 #1186

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/detect_compiler_family.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
#ifdef __GNUC__
#pragma message "gcc"
#endif

#ifdef __EMSCRIPTEN__
#pragma message "emscripten"
#endif

15 changes: 8 additions & 7 deletions src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,19 @@ impl Tool {

let clang = stdout.contains(r#""clang""#);
let gcc = stdout.contains(r#""gcc""#);
let emscripten = stdout.contains(r#""emscripten""#);

match (clang, accepts_cl_style_flags, gcc) {
(clang_cl, true, _) => Ok(ToolFamily::Msvc { clang_cl }),
(true, false, _) => Ok(ToolFamily::Clang {
match (clang, accepts_cl_style_flags, gcc, emscripten) {
(clang_cl, true, _, false) => Ok(ToolFamily::Msvc { clang_cl }),
(true, _, _, _) | (_, _, _, true) => Ok(ToolFamily::Clang {
zig_cc: is_zig_cc(path, cargo_output),
}),
(false, false, true) => Ok(ToolFamily::Gnu),
(false, false, false) => {
cargo_output.print_warning(&"Compiler family detection failed since it does not define `__clang__`, `__GNUC__` or `_MSC_VER`, fallback to treating it as GNU");
(false, false, true, _) => Ok(ToolFamily::Gnu),
(false, false, false, false) => {
cargo_output.print_warning(&"Compiler family detection failed since it does not define `__clang__`, `__GNUC__` or `__EMSCRIPTEN__`, also does not accept cl style flag `-?`, fallback to treating it as GNU");
Err(Error::new(
ErrorKind::ToolFamilyMacroNotFound,
"Expects macro `__clang__`, `__GNUC__` or `_MSC_VER`, but found none",
"Expects macro `__clang__`, `__GNUC__` or `__EMSCRIPTEN__`, or accepts cl style flag `-?`, but found none",
))
}
}
Expand Down