diff options
author | Jukka Jylanki <jujjyl@gmail.com> | 2014-04-09 23:19:11 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-04-10 00:37:55 +0300 |
commit | b239fb1ed3d91bd98ddafa1bfd6af6a57daa32ca (patch) | |
tree | c57c617735c6dc2686f0e51f68c8db0048e6ba67 /tools | |
parent | 19c1821f0e9740c6fcf6ed5b2bdf976d2b098558 (diff) |
When we build native OSX executables with Clang, we must tell Clang which OSX SDK version we are targeting. Add a function CLANG_NATIVE_ARGS() that returns a list of compiler args that need to be appended when building native executables for the current platform, which for OSX automatically find an SDK to target. Make the machinery lazy and cached so that it's not invoked if native executables are not built, and that it's invoked only once when needed. Fixed test other.test_bad_triple on OSX.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/shared.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/shared.py b/tools/shared.py index 5425d2c1..e912a700 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -495,6 +495,30 @@ def build_clang_tool_path(tool): else: return os.path.join(LLVM_ROOT, tool) +# Whenever building a native executable for OSX, we must provide the OSX SDK version we want to target. +def osx_find_native_sdk_path(): + try: + sdk_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs' + sdks = os.walk(sdk_root).next()[1] + sdk_path = os.path.join(sdk_root, sdks[0]) # Just pick first one found, we don't care which one we found. + logging.debug('Targeting OSX SDK found at ' + sdk_path) + return sdk_path + except: + logging.warning('Could not find native OSX SDK path to target!') + return None + +# These extra args need to be passed to Clang when targeting a native host system executable +CACHED_CLANG_NATIVE_ARGS=None +def get_clang_native_args(): + global CACHED_CLANG_NATIVE_ARGS + if CACHED_CLANG_NATIVE_ARGS is not None: return CACHED_CLANG_NATIVE_ARGS + CACHED_CLANG_NATIVE_ARGS = [] + if sys.platform == 'darwin': + sdk_path = osx_find_native_sdk_path() + if sdk_path: + CACHED_CLANG_NATIVE_ARGS = ['-isysroot', osx_find_native_sdk_path()] + return CACHED_CLANG_NATIVE_ARGS + CLANG_CC=os.path.expanduser(build_clang_tool_path('clang')) CLANG_CPP=os.path.expanduser(build_clang_tool_path('clang++')) CLANG=CLANG_CPP |