[llvm] 9044224 - [test] Fix macOS triple check

Ben Langmuir via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 13:36:27 PDT 2022


Author: Ben Langmuir
Date: 2022-07-13T13:36:16-07:00
New Revision: 904422457564b5773b5f65c48c3954cb10a9ad1c

URL: https://github.com/llvm/llvm-project/commit/904422457564b5773b5f65c48c3954cb10a9ad1c
DIFF: https://github.com/llvm/llvm-project/commit/904422457564b5773b5f65c48c3954cb10a9ad1c.diff

LOG: [test] Fix macOS triple check

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

Added: 
    

Modified: 
    llvm/utils/lit/lit/util.py

Removed: 
    


################################################################################
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)


        


More information about the llvm-commits mailing list