Skip to content

Commit

Permalink
[test] Fix macOS triple check
Browse files Browse the repository at this point in the history
While the inferred host triple for macOS is something like
<arch>-apple-darwin, it's also valid to have <arch>-apple-macos.
Currently that globally changes whether an SDKROOT is provided in tests,
so make this check more portable.

Differential Revision: https://reviews.llvm.org/D129684
  • Loading branch information
benlangmuir committed Jul 13, 2022
1 parent 3ce78cb commit 9044224
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions llvm/utils/lit/lit/util.py
Expand Up @@ -385,10 +385,17 @@ def killProcess():
return out, err, exitCode


def isMacOSTriple(target_triple):
"""Whether the given target triple is for macOS,
e.g. x86_64-apple-darwin, arm64-apple-macos
"""
return 'darwin' in target_triple or 'macos' in target_triple


def usePlatformSdkOnDarwin(config, lit_config):
# On Darwin, support relocatable SDKs by providing Clang with a
# default system root path.
if 'darwin' in config.target_triple:
if isMacOSTriple(config.target_triple):
try:
cmd = subprocess.Popen(['xcrun', '--show-sdk-path', '--sdk', 'macosx'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand All @@ -404,7 +411,7 @@ def usePlatformSdkOnDarwin(config, lit_config):


def findPlatformSdkVersionOnMacOS(config, lit_config):
if 'darwin' in config.target_triple:
if isMacOSTriple(config.target_triple):
try:
cmd = subprocess.Popen(['xcrun', '--show-sdk-version', '--sdk', 'macosx'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down

0 comments on commit 9044224

Please sign in to comment.