Skip to content

Commit 368f671

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 368f671

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/targets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import subprocess
33
import sys
44
from SCons.Script import ARGUMENTS
5+
from SCons.Tool import Tool
56
from SCons.Variables import *
67
from SCons.Variables.BoolVariable import _text2bool
78

@@ -24,15 +25,15 @@ def using_clang(env):
2425
return "clang" in os.path.basename(env["CC"])
2526

2627

27-
def is_vanilla_clang(env):
28+
def is_clang_type(env, family_string):
2829
if not using_clang(env):
2930
return False
3031
try:
3132
version = subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip().decode("utf-8")
3233
except (subprocess.CalledProcessError, OSError):
3334
print("Couldn't parse CXX environment variable to infer compiler version.")
3435
return False
35-
return not version.startswith("Apple")
36+
return version.startswith(family_string)
3637

3738

3839
# Main tool definition
@@ -125,10 +126,10 @@ def generate(env):
125126
else:
126127
env.Append(CCFLAGS=["-g2"])
127128
else:
128-
if using_clang(env) and not is_vanilla_clang(env):
129+
if using_clang(env) and is_clang_type(env, "Apple"):
129130
# Apple Clang, its linker doesn't like -s.
130131
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
131-
else:
132+
elif using_clang(env) and is_clang_type(env, "clang"):
132133
env.Append(LINKFLAGS=["-s"])
133134

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

0 commit comments

Comments
 (0)