[PATCH] Add detection of OS X relocatable SDK to compiler-rt as a lit.util function

Kuba Brecka kuba.brecka at gmail.com
Mon Jun 9 11:29:31 PDT 2014


Clang's lit cfg already detects the currently selected SDK via "xcrun --show-sdk-path". The same thing should be done for compiler-rt tests, to make them work on recent OS X versions. Instead of duplicating the detection code, this patch extracts the detection function into a lit.util method.

http://reviews.llvm.org/D4072

Files:
  cfe/trunk/test/lit.cfg
  compiler-rt/trunk/test/lit.common.cfg
  llvm/trunk/utils/lit/lit/util.py

Index: cfe/trunk/test/lit.cfg
===================================================================
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -471,18 +471,4 @@
 if use_gmalloc:
      config.environment.update({'DYLD_INSERT_LIBRARIES' : gmalloc_path_str})
 
-# On Darwin, support relocatable SDKs by providing Clang with a
-# default system root path.
-if 'darwin' in config.target_triple:
-    try:
-        cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
-                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        out, err = cmd.communicate()
-        out = out.strip()
-        res = cmd.wait()
-    except OSError:
-        res = -1
-    if res == 0 and out:
-        sdk_path = out
-        lit_config.note('using SDKROOT: %r' % sdk_path)
-        config.environment['SDKROOT'] = sdk_path
+lit.util.usePlatformSdkOnDarwin(config, lit_config)
Index: compiler-rt/trunk/test/lit.common.cfg
===================================================================
--- compiler-rt/trunk/test/lit.common.cfg
+++ compiler-rt/trunk/test/lit.common.cfg
@@ -7,6 +7,7 @@
 import platform
 
 import lit.formats
+import lit.util
 
 # Setup test format
 execute_external = (platform.system() != 'Windows'
@@ -77,3 +78,5 @@
 compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
 if not compiler_rt_debug:
   config.available_features.add('compiler-rt-optimized')
+
+lit.util.usePlatformSdkOnDarwin(config, lit_config)
Index: llvm/trunk/utils/lit/lit/util.py
===================================================================
--- llvm/trunk/utils/lit/lit/util.py
+++ llvm/trunk/utils/lit/lit/util.py
@@ -167,3 +167,20 @@
         err = str(err)
 
     return out, err, exitCode
+
+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:
+        try:
+            cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
+                                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            out, err = cmd.communicate()
+            out = out.strip()
+            res = cmd.wait()
+        except OSError:
+            res = -1
+        if res == 0 and out:
+            sdk_path = out
+            lit_config.note('using SDKROOT: %r' % sdk_path)
+            config.environment['SDKROOT'] = sdk_path
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4072.10243.patch
Type: text/x-patch
Size: 2403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140609/245f163d/attachment.bin>


More information about the llvm-commits mailing list