Skip to content

Commit e878b70

Browse files
Adjust clang version checking to account for other non-vanilla clangs
We can no longer make the assumption that all non-vanilla clang versions are Apple's clang or that all other non vanilla clangs will work with the given arguments. There are times where additional tools might use non vanilla clang and the presumed arguments here will break compilation on those platforms. We might want to consider adding tooling-specific optimazation functions long term to fetch desired optimizations on a platform basis.
1 parent 36847f6 commit e878b70

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/targets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def using_clang(env):
2424
return "clang" in os.path.basename(env["CC"])
2525

2626

27-
def is_vanilla_clang(env):
27+
def is_clang_type(env, family_string):
2828
if not using_clang(env):
2929
return False
3030
try:
3131
version = subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip().decode("utf-8")
3232
except (subprocess.CalledProcessError, OSError):
3333
print("Couldn't parse CXX environment variable to infer compiler version.")
3434
return False
35-
return not version.startswith("Apple")
35+
return version.startswith(family_string)
3636

3737

3838
# Main tool definition
@@ -125,10 +125,10 @@ def generate(env):
125125
else:
126126
env.Append(CCFLAGS=["-g2"])
127127
else:
128-
if using_clang(env) and not is_vanilla_clang(env):
128+
if using_clang(env) and is_clang_type(env, "Apple"):
129129
# Apple Clang, its linker doesn't like -s.
130130
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
131-
else:
131+
elif is_clang_type(env, "clang"):
132132
env.Append(LINKFLAGS=["-s"])
133133

134134
if env["optimize"] == "speed":

0 commit comments

Comments
 (0)