Skip to content

Commit e52c993

Browse files
committed
Merge pull request #2279 from juj/test_bad_triple
Fix other.test_bad_triple.
2 parents 158e8c4 + b239fb1 commit e52c993

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/test_other.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ def test_odin_validation(self):
25772577
assert 'asm.js' in output, 'spidermonkey should mention asm.js compilation: ' + output
25782578

25792579
def test_bad_triple(self):
2580-
Popen([CLANG, path_from_root('tests', 'hello_world.c'), '-c', '-emit-llvm', '-o', 'a.bc'], stdout=PIPE, stderr=PIPE).communicate()
2580+
Popen([CLANG, path_from_root('tests', 'hello_world.c'), '-c', '-emit-llvm', '-o', 'a.bc'] + get_clang_native_args(), stdout=PIPE, stderr=PIPE).communicate()
25812581
out, err = Popen([PYTHON, EMCC, 'a.bc'], stdout=PIPE, stderr=PIPE).communicate()
25822582
assert 'warning' in err, err
25832583
assert 'incorrect target triple' in err, err

tools/shared.py

+24
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,30 @@ def build_clang_tool_path(tool):
495495
else:
496496
return os.path.join(LLVM_ROOT, tool)
497497

498+
# Whenever building a native executable for OSX, we must provide the OSX SDK version we want to target.
499+
def osx_find_native_sdk_path():
500+
try:
501+
sdk_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs'
502+
sdks = os.walk(sdk_root).next()[1]
503+
sdk_path = os.path.join(sdk_root, sdks[0]) # Just pick first one found, we don't care which one we found.
504+
logging.debug('Targeting OSX SDK found at ' + sdk_path)
505+
return sdk_path
506+
except:
507+
logging.warning('Could not find native OSX SDK path to target!')
508+
return None
509+
510+
# These extra args need to be passed to Clang when targeting a native host system executable
511+
CACHED_CLANG_NATIVE_ARGS=None
512+
def get_clang_native_args():
513+
global CACHED_CLANG_NATIVE_ARGS
514+
if CACHED_CLANG_NATIVE_ARGS is not None: return CACHED_CLANG_NATIVE_ARGS
515+
CACHED_CLANG_NATIVE_ARGS = []
516+
if sys.platform == 'darwin':
517+
sdk_path = osx_find_native_sdk_path()
518+
if sdk_path:
519+
CACHED_CLANG_NATIVE_ARGS = ['-isysroot', osx_find_native_sdk_path()]
520+
return CACHED_CLANG_NATIVE_ARGS
521+
498522
CLANG_CC=os.path.expanduser(build_clang_tool_path('clang'))
499523
CLANG_CPP=os.path.expanduser(build_clang_tool_path('clang++'))
500524
CLANG=CLANG_CPP

0 commit comments

Comments
 (0)