diff options
-rw-r--r-- | src/deps_info.json | 3 | ||||
-rw-r--r-- | tests/test_other.py | 8 | ||||
-rw-r--r-- | tools/js-optimizer.js | 2 | ||||
-rw-r--r-- | tools/shared.py | 24 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-outline1-output.js | 59 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-outline1.js | 27 | ||||
-rw-r--r-- | tools/validate_asmjs.py | 5 |
7 files changed, 121 insertions, 7 deletions
diff --git a/src/deps_info.json b/src/deps_info.json index b38ffd00..029a20e1 100644 --- a/src/deps_info.json +++ b/src/deps_info.json @@ -2,6 +2,7 @@ "uuid_compare": ["memcmp"], "SDL_Init": ["malloc", "free"], "SDL_GL_GetProcAddress": ["emscripten_GetProcAddress"], - "eglGetProcAddress": ["emscripten_GetProcAddress"] + "eglGetProcAddress": ["emscripten_GetProcAddress"], + "emscripten_GetProcAddress": ["strstr"] } diff --git a/tests/test_other.py b/tests/test_other.py index ce95681c..16b5ab92 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2533,10 +2533,8 @@ int main() for opts, expected, compile_expected in [ ([], None, [IMPLICIT_ERROR]), - (['-Wno-error=implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], [IMPLICIT_WARNING]), # turn error into warning - (['-Wno-implicit-function-declaration'], ['abort()', 'it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this'], []), # turn error into nothing at all - (['-Wno-error=implicit-function-declaration', '-s', 'ASSERTIONS=2'], ['abort()', 'This pointer might make sense in another type signature'], []), - (['-Wno-error=implicit-function-declaration', '-O1'], ['hello 0\nhello 0\n'], []), # invalid output - second arg is sent as varargs, but needs to be int. llvm optimizer avoided the crash silently, caused undefined behavior... at least people can debug this by running an -O0 build. + (['-Wno-error=implicit-function-declaration'], ['hello '], [IMPLICIT_WARNING]), # turn error into warning + (['-Wno-implicit-function-declaration'], ['hello '], []), # turn error into nothing at all (runtime output is incorrect) ]: print opts, expected try_delete('a.out.js') @@ -2578,7 +2576,7 @@ int main() assert 'asm.js' in output, 'spidermonkey should mention asm.js compilation: ' + output def test_bad_triple(self): - Popen([CLANG, path_from_root('tests', 'hello_world.c'), '-c', '-emit-llvm', '-o', 'a.bc'], stdout=PIPE, stderr=PIPE).communicate() + Popen([CLANG, path_from_root('tests', 'hello_world.c'), '-c', '-emit-llvm', '-o', 'a.bc'] + get_clang_native_args(), stdout=PIPE, stderr=PIPE).communicate() out, err = Popen([PYTHON, EMCC, 'a.bc'], stdout=PIPE, stderr=PIPE).communicate() assert 'warning' in err, err assert 'incorrect target triple' in err, err diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index e75ff317..c4585b84 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -4491,7 +4491,7 @@ function outline(ast) { for (var returnType in codeInfo.hasReturnType) { reps.push(makeIf( makeComparison(makeAsmCoercion(['name', 'tempValue'], ASM_INT), '==', ['num', controlFromAsmType(returnType)]), - [['stat', ['return', makeAsmCoercion(['name', 'tempInt'], returnType | 0)]]] + [['stat', ['return', makeAsmCoercion(['name', returnType == ASM_INT ? 'tempInt' : 'tempDouble'], returnType | 0)]]] )); } if (codeInfo.hasBreak) { 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 diff --git a/tools/test-js-optimizer-asm-outline1-output.js b/tools/test-js-optimizer-asm-outline1-output.js index 40c028c6..10fc3714 100644 --- a/tools/test-js-optimizer-asm-outline1-output.js +++ b/tools/test-js-optimizer-asm-outline1-output.js @@ -446,6 +446,32 @@ function stackSet(x1, x2, x3, x4, x5) { HEAP32[sp + 62 >> 2] = 0; stackSet$0(sp); } +function linf(d) { + d = +d; + var sp = 0; + sp = STACKTOP; + STACKTOP = STACKTOP + 160 | 0; + while (1) { + HEAP32[sp + 24 >> 2] = 0; + HEAP32[sp + 28 >> 2] = 0; + linf$1(sp); + HEAPF32[sp + 8 >> 2] = d; + HEAP32[sp + 16 >> 2] = 0; + HEAP32[sp + 20 >> 2] = 0; + linf$0(sp); + tempValue = HEAP32[sp + 16 >> 2] | 0; + tempInt = HEAP32[sp + 20 >> 2] | 0; + tempDouble = +HEAPF32[sp + 20 >> 2]; + HEAP32[sp + 16 >> 2] = 0; + HEAP32[sp + 20 >> 2] = 0; + if ((tempValue | 0) == 7) { + STACKTOP = sp; + return +tempDouble; + } + } + STACKTOP = sp; + return +d; +} function lin$0(sp) { sp = sp | 0; c(14); @@ -955,4 +981,37 @@ function stackSet$1(sp) { c(5); c(6); } +function linf$0(sp) { + sp = sp | 0; + var d = +0; + d = +HEAPF32[sp + 8 >> 2]; + OL : do { + c(16); + c(17); + c(18); + c(19); + c(20); + HEAP32[sp + 16 >> 2] = 7; + HEAPF32[sp + 20 >> 2] = +d; + break OL; + } while (0); +} +function linf$1(sp) { + sp = sp | 0; + c(1); + c(2); + c(3); + c(4); + c(5); + c(6); + c(7); + c(8); + c(9); + c(10); + c(11); + c(12); + c(13); + c(14); + c(15); +} diff --git a/tools/test-js-optimizer-asm-outline1.js b/tools/test-js-optimizer-asm-outline1.js index f640d11d..8dfb1afb 100644 --- a/tools/test-js-optimizer-asm-outline1.js +++ b/tools/test-js-optimizer-asm-outline1.js @@ -384,5 +384,32 @@ function stackSet(x1, x2, x3, x4, x5) { c(12); c(13); } +function linf(d) { + d = +d; + while (1) { + c(1); + c(2); + c(3); + c(4); + c(5); + c(6); + c(7); + c(8); + c(9); + c(10); + c(11); + c(12); + c(13); + c(14); + c(15); + c(16); + c(17); + c(18); + c(19); + c(20); + return +d; + } + return +d; +} // EMSCRIPTEN_GENERATED_FUNCTIONS // EXTRA_INFO: { "sizeToOutline": 30, "allowCostlyOutlines": 1 } diff --git a/tools/validate_asmjs.py b/tools/validate_asmjs.py index ea909fbd..4136af93 100644 --- a/tools/validate_asmjs.py +++ b/tools/validate_asmjs.py @@ -59,6 +59,11 @@ def validate_asmjs(filename, muteOutput): if not valid_asmjs: return False if numAsmJsBlocks == 0: + # Test a .js file with the same basename - emcc convention + # is to generate files with same basename but different suffix. + js_file = filename.replace('.html', '.js') + if os.path.isfile(js_file): + return validate_asmjs(js_file, muteOutput) if not muteOutput: print >> sys.stderr, 'Error: the file does not contain any "use asm" modules.' return False |