From bf64c23851ce11bed46fe822ba513a73a684edd4 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 12 Oct 2015 00:49:56 +0000 Subject: [PATCH] [Darwin] Need to add -isysroot on OS X otherwise the tests will fail if you don't have the command line tools package installed. This mirrors how other LLVM suites are configured for running on OS X. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@250003 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/libcxx/test/config.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py index 11e7cbed..d71ab100 100644 --- a/test/libcxx/test/config.py +++ b/test/libcxx/test/config.py @@ -6,6 +6,7 @@ import pkgutil import re import shlex import sys +import subprocess import lit.Test # pylint: disable=import-error,no-name-in-module import lit.util # pylint: disable=import-error,no-name-in-module @@ -42,6 +43,24 @@ def loadSiteConfig(lit_config, config, param_name, env_name): ld_fn(config, site_cfg) lit_config.load_config = ld_fn +def getSysrootFlagsOnDarwin(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) + return ["-isysroot", sdk_path] + return [] + class Configuration(object): # pylint: disable=redefined-outer-name @@ -339,6 +358,8 @@ class Configuration(object): # Configure extra flags compile_flags_str = self.get_lit_conf('compile_flags', '') self.cxx.compile_flags += shlex.split(compile_flags_str) + sysroot_flags = getSysrootFlagsOnDarwin(self.config, self.lit_config) + self.cxx.compile_flags.extend(sysroot_flags) def configure_default_compile_flags(self): # Try and get the std version from the command line. Fall back to