From 904422457564b5773b5f65c48c3954cb10a9ad1c Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Wed, 13 Jul 2022 12:10:20 -0700 Subject: [PATCH] [test] Fix macOS triple check While the inferred host triple for macOS is something like -apple-darwin, it's also valid to have -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 --- llvm/utils/lit/lit/util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py index 11112d8015db3..75cface848390 100644 --- a/llvm/utils/lit/lit/util.py +++ b/llvm/utils/lit/lit/util.py @@ -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) @@ -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)