Skip to content

Commit d3ff011

Browse files
authored
Fix detect family: should detect emscripten as clang, closes #1185 (#1186)
1 parent 9b77c3f commit d3ff011

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/detect_compiler_family.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
#ifdef __GNUC__
66
#pragma message "gcc"
77
#endif
8+
9+
#ifdef __EMSCRIPTEN__
10+
#pragma message "emscripten"
11+
#endif
12+

src/tool.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,19 @@ impl Tool {
169169

170170
let clang = stdout.contains(r#""clang""#);
171171
let gcc = stdout.contains(r#""gcc""#);
172+
let emscripten = stdout.contains(r#""emscripten""#);
172173

173-
match (clang, accepts_cl_style_flags, gcc) {
174-
(clang_cl, true, _) => Ok(ToolFamily::Msvc { clang_cl }),
175-
(true, false, _) => Ok(ToolFamily::Clang {
174+
match (clang, accepts_cl_style_flags, gcc, emscripten) {
175+
(clang_cl, true, _, false) => Ok(ToolFamily::Msvc { clang_cl }),
176+
(true, _, _, _) | (_, _, _, true) => Ok(ToolFamily::Clang {
176177
zig_cc: is_zig_cc(path, cargo_output),
177178
}),
178-
(false, false, true) => Ok(ToolFamily::Gnu),
179-
(false, false, false) => {
180-
cargo_output.print_warning(&"Compiler family detection failed since it does not define `__clang__`, `__GNUC__` or `_MSC_VER`, fallback to treating it as GNU");
179+
(false, false, true, _) => Ok(ToolFamily::Gnu),
180+
(false, false, false, false) => {
181+
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");
181182
Err(Error::new(
182183
ErrorKind::ToolFamilyMacroNotFound,
183-
"Expects macro `__clang__`, `__GNUC__` or `_MSC_VER`, but found none",
184+
"Expects macro `__clang__`, `__GNUC__` or `__EMSCRIPTEN__`, or accepts cl style flag `-?`, but found none",
184185
))
185186
}
186187
}

0 commit comments

Comments
 (0)