Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust clang version checking to account for other non-vanilla clangs #1380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tools/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import sys
from SCons.Script import ARGUMENTS
from SCons.Tool import Tool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like this import is used?

from SCons.Variables import *
from SCons.Variables.BoolVariable import _text2bool

Expand All @@ -24,15 +25,15 @@ def using_clang(env):
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):
return False
try:
version = subprocess.check_output([env.subst(env["CXX"]), "--version"]).strip().decode("utf-8")
except (subprocess.CalledProcessError, OSError):
print("Couldn't parse CXX environment variable to infer compiler version.")
return False
return not version.startswith("Apple")
return version.startswith(family_string)


# Main tool definition
Expand Down Expand Up @@ -125,10 +126,10 @@ def generate(env):
else:
env.Append(CCFLAGS=["-g2"])
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.
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"])

if env["optimize"] == "speed":
Expand Down
Loading