Compare commits

...

2 Commits

Author SHA1 Message Date
Eoin O'Neill 6898ee9a40
Merge 368f671912 into 36847f6af0 2024-02-09 22:50:58 +00:00
Eoin O'Neill 368f671912 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.
2024-02-09 14:49:07 -08:00
1 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import os
import subprocess import subprocess
import sys import sys
from SCons.Script import ARGUMENTS from SCons.Script import ARGUMENTS
from SCons.Tool import Tool
from SCons.Variables import * from SCons.Variables import *
from SCons.Variables.BoolVariable import _text2bool from SCons.Variables.BoolVariable import _text2bool
@ -24,7 +25,7 @@ def using_clang(env):
return "clang" in os.path.basename(env["CC"]) return "clang" in os.path.basename(env["CC"])
def is_vanilla_clang(env): def is_clang_type(env, family_string):
if not using_clang(env): if not using_clang(env):
return False return False
try: try:
@ -32,7 +33,7 @@ def is_vanilla_clang(env):
except (subprocess.CalledProcessError, OSError): except (subprocess.CalledProcessError, OSError):
print("Couldn't parse CXX environment variable to infer compiler version.") print("Couldn't parse CXX environment variable to infer compiler version.")
return False return False
return not version.startswith("Apple") return version.startswith(family_string)
# Main tool definition # Main tool definition
@ -125,10 +126,10 @@ def generate(env):
else: else:
env.Append(CCFLAGS=["-g2"]) env.Append(CCFLAGS=["-g2"])
else: else:
if using_clang(env) and not is_vanilla_clang(env): if using_clang(env) and is_clang_type(env, "Apple"):
# Apple Clang, its linker doesn't like -s. # Apple Clang, its linker doesn't like -s.
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"]) env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
else: elif using_clang(env) and is_clang_type(env, "clang"):
env.Append(LINKFLAGS=["-s"]) env.Append(LINKFLAGS=["-s"])
if env["optimize"] == "speed": if env["optimize"] == "speed":