Skip to content

Commit 2b074e6

Browse files
committed
Merge branch 'bryantdrewjones-fix-is-clang-macos-sdks'
2 parents 7e41347 + dddb6b3 commit 2b074e6

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

drivers/lang/c/src/gcc/driver.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,46 @@ const char *cc(
7070
}
7171
}
7272

73-
/* Is current compiler clang */
7473
static
75-
bool is_clang(bake_src_lang lang)
74+
bool is_compiler(
75+
const char *name,
76+
bake_src_lang lang)
7677
{
77-
if (!strncmp(cc(lang), "clang", 5)) {
78+
const char *compiler = cc(lang);
79+
size_t name_len = strlen(name);
80+
81+
/* First test if user is running clang from a non-standard path. */
82+
const char *cc_command = strrchr(compiler, UT_OS_PS[0]);
83+
if (!cc_command) {
84+
cc_command = name;
85+
} else {
86+
cc_command ++;
87+
}
88+
89+
if (!strncmp(cc_command, compiler, name_len)) {
7890
return true;
91+
} else {
92+
return false;
7993
}
80-
return false;
94+
}
95+
96+
/* Is current compiler clang */
97+
static
98+
bool is_clang(bake_src_lang lang)
99+
{
100+
return is_compiler("clang", lang);
81101
}
82102

83103
/* Is current compiler emcc */
84104
static
85105
bool is_emcc(void) {
86-
if (!strncmp(cc(false), "emcc", 4)) {
87-
return true;
88-
}
89-
return false;
106+
return is_compiler("emcc", 0);
90107
}
91108

92109
/* Is current compiler icc */
93110
static
94111
bool is_icc(void) {
95-
if (!strncmp(cc(false), "icc", 3)) {
96-
return true;
97-
}
98-
return false;
112+
return is_compiler("icc", 0);
99113
}
100114

101115
static

0 commit comments

Comments
 (0)