[llvm] 952a540 - [test] On Mac, don't try to use result of sysctl command if calling it failed.

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 02:05:13 PST 2020


Author: David Spickett
Date: 2020-01-20T10:04:06Z
New Revision: 952a540b21993e44088ff2c345df884caabbb8c0

URL: https://github.com/llvm/llvm-project/commit/952a540b21993e44088ff2c345df884caabbb8c0
DIFF: https://github.com/llvm/llvm-project/commit/952a540b21993e44088ff2c345df884caabbb8c0.diff

LOG: [test] On Mac, don't try to use result of sysctl command if calling it failed.

If sysctl is not found at all, let the usual exception propogate
so that the user can fix their env. If it fails because of the
permissions required to read the property then print a warning
and continue.

Differential Revision: https://reviews.llvm.org/D72278

Added: 
    

Modified: 
    llvm/test/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index b57b87ad657f..e6e8d12a6e48 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -324,15 +324,18 @@ def have_ld64_plugin_support():
      ('--has-global-isel', {'ON': 'global-isel'})])
 
 if 'darwin' == sys.platform:
-    try:
-        sysctl_cmd = subprocess.Popen(['sysctl', 'hw.optional.fma'],
-                                      stdout=subprocess.PIPE)
-    except OSError:
-        print('Could not exec sysctl')
-    result = sysctl_cmd.stdout.read().decode('ascii')
-    if -1 != result.find('hw.optional.fma: 1'):
-        config.available_features.add('fma3')
-    sysctl_cmd.wait()
+    cmd = ['sysctl', 'hw.optional.fma']
+    sysctl_cmd = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+
+    # Non zero return, probably a permission issue
+    if sysctl_cmd.wait():
+        print(
+          "Warning: sysctl exists but calling \"{}\" failed, defaulting to no fma3.".format(
+          " ".join(cmd)))
+    else:
+        result = sysctl_cmd.stdout.read().decode('ascii')
+        if 'hw.optional.fma: 1' in result:
+            config.available_features.add('fma3')
 
 # .debug_frame is not emitted for targeting Windows x64.
 if not re.match(r'^x86_64.*-(windows-gnu|windows-msvc)', config.target_triple):


        


More information about the llvm-commits mailing list