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

David Spickett via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 05:48:22 PST 2020


DavidSpickett updated this revision to Diff 237643.
DavidSpickett edited the summary of this revision.
DavidSpickett added a comment.

Turns out I didn't have /usr/sbin on my PATH (due to some machine hopping).

In light of that I think it makes more sense to allow "file not found" to be raised normally, then if sysctl returns non zero print the warning that was suggested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72278/new/

https://reviews.llvm.org/D72278

Files:
  llvm/test/lit.cfg.py


Index: llvm/test/lit.cfg.py
===================================================================
--- llvm/test/lit.cfg.py
+++ llvm/test/lit.cfg.py
@@ -324,15 +324,18 @@
      ('--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):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72278.237643.patch
Type: text/x-patch
Size: 1260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/c3c8d218/attachment.bin>


More information about the llvm-commits mailing list