From 789f3322720c6b500660f313078153a897571eca Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun, 13 Nov 2016 20:43:38 +0000
Subject: [PATCH] [libcxx, cmake] if a LIBCXX_SYSROOT is given, this
 pre-empts the use of xcrun to find the sdk

---
 libcxx/utils/libcxx/test/target_info.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py
index de2232ff418..179db775229 100644
--- a/libcxx/utils/libcxx/test/target_info.py
+++ b/libcxx/utils/libcxx/test/target_info.py
@@ -122,16 +122,18 @@ class DarwinLocalTI(DefaultTargetInfo):
         add_common_locales(features, self.full_config.lit_config)
 
     def add_cxx_compile_flags(self, flags):
-        if self.full_config.use_deployment:
-            _, name, _ = self.full_config.config.deployment
-            cmd = ['xcrun', '--sdk', name, '--show-sdk-path']
+        res = 0
+        if self.full_config.get_lit_conf('sysroot') != '':
+            # Other logic will add --sysroot= with this value, don't
+            # need to replicate, and don't want to override with whatever
+            # Xcode happens to have.
+            out = ''
         else:
             cmd = ['xcrun', '--show-sdk-path']
-        try:
-            out = subprocess.check_output(cmd).strip()
-            res = 0
-        except OSError:
-            res = -1
+            try:
+                out = subprocess.check_output(cmd).strip()
+            except OSError:
+                res = -1
         if res == 0 and out:
             sdk_path = out
             self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path)
