summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc14
-rwxr-xr-xemscripten.py5
-rwxr-xr-xscons-tools/emscripten.py17
-rwxr-xr-xscons-tools/llvm.py7
-rw-r--r--src/intertyper.js6
-rw-r--r--src/library_egl.js9
-rw-r--r--src/library_glut.js2
-rwxr-xr-xtests/runner.py16
-rw-r--r--tools/shared.py11
9 files changed, 60 insertions, 27 deletions
diff --git a/emcc b/emcc
index a5b30b97..0eb4499b 100755
--- a/emcc
+++ b/emcc
@@ -462,6 +462,12 @@ Options that are modified or new in %s include:
memory initialization data embedded inside
JavaScript as text. (default is off)
+ -Wno-warn-absolute-paths If not specified, the compiler will warn about any
+ uses of absolute paths in -I and -L command line
+ directives. Pass this flag on the command line
+ to hide these warnings and acknowledge that the
+ explicit use of absolute paths is intentional.
+
The target file, if specified (-o <target>), defines what will
be generated:
@@ -735,6 +741,12 @@ try:
absolute_warning_shown = False
+ # Scan for warning suppression message in advance from other cmdline flags, so that it works even if -I or -L directives are present before this.
+ for i in range(len(newargs)):
+ if newargs[i] == '-Wno-warn-absolute-paths':
+ newargs[i] = ''
+ absolute_warning_shown = True
+
settings_changes = []
def validate_arg_level(level_string, max_level, err_msg):
@@ -879,7 +891,7 @@ try:
elif newargs[i].startswith(('-I', '-L')):
path_name = newargs[i][2:]
if not absolute_warning_shown and os.path.isabs(path_name):
- logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
+ logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
absolute_warning_shown = True
newargs = [ arg for arg in newargs if arg is not '' ]
diff --git a/emscripten.py b/emscripten.py
index ab68fcaa..aa47e4f1 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -11,7 +11,6 @@ headers, for the libc implementation in JS).
import os, sys, json, optparse, subprocess, re, time, multiprocessing, string
-from tools import shared
from tools import jsrun, cache as cache_module, tempfiles
from tools.response_file import read_response_file
@@ -26,6 +25,7 @@ def get_configuration():
if hasattr(get_configuration, 'configuration'):
return get_configuration.configuration
+ from tools import shared
configuration = shared.Configuration(environ=os.environ)
get_configuration.configuration = configuration
return configuration
@@ -469,6 +469,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
}
''' % (sig, i, args, arg_coercions, jsret))
+ from tools import shared
asm_setup += '\n' + shared.JS.make_invoke(sig) + '\n'
basic_funcs.append('invoke_%s' % sig)
@@ -807,7 +808,7 @@ WARNING: You should normally never use this! Use emcc instead.
'''
if len(positional) != 1:
- raise RuntimeError('Must provide exactly one positional argument.')
+ raise RuntimeError('Must provide exactly one positional argument. Got ' + str(len(positional)) + ': "' + '", "'.join(positional) + '"')
keywords.infile = os.path.abspath(positional[0])
if isinstance(keywords.outfile, basestring):
keywords.outfile = open(keywords.outfile, 'w')
diff --git a/scons-tools/emscripten.py b/scons-tools/emscripten.py
index 473c51ad..b4912aaa 100755
--- a/scons-tools/emscripten.py
+++ b/scons-tools/emscripten.py
@@ -24,6 +24,7 @@ def build_version_file(env):
EMSCRIPTEN_DEPENDENCIES = [
env.Glob('${EMSCRIPTEN_HOME}/src/*.js'),
+ env.Glob('${EMSCRIPTEN_HOME}/src/embind/*.js'),
env.Glob('${EMSCRIPTEN_HOME}/tools/*.py'),
'${EMSCRIPTEN_HOME}/emscripten.py',
]
@@ -141,7 +142,7 @@ def emscripten(env, target_js, source_bc):
[global_emscripten_min_js] = env.JSOptimizer(
buildName('global.min.js'),
closure_js,
- JS_OPTIMIZER_PASSES=['simplifyExpressionsPost', 'compress', 'last'])
+ JS_OPTIMIZER_PASSES=['simplifyExpressionsPost', 'minifyWhitespace', 'last'])
[emscripten_iteration_js] = env.WrapInModule(
buildName('iteration.js'),
@@ -155,8 +156,6 @@ def emscripten(env, target_js, source_bc):
buildName('min.js'),
global_emscripten_min_js)
- env.InstallAs(buildName('js'), emscripten_js)
-
return [emscripten_iteration_js, emscripten_js, emscripten_min_js]
LIBC_SOURCES = [
@@ -265,9 +264,9 @@ def generate(env):
)
env.Replace(
- CC='${LLVM_ROOT}/${CLANG}',
- CXX='${LLVM_ROOT}/${CLANGXX}',
- AR='${LLVM_ROOT}/${LLVM_LINK}',
+ CC=os.path.join('${LLVM_ROOT}', '${CLANG}'),
+ CXX=os.path.join('${LLVM_ROOT}', '${CLANGXX}'),
+ AR=os.path.join('${LLVM_ROOT}', '${LLVM_LINK}'),
ARCOM='$AR -o $TARGET $SOURCES',
OBJSUFFIX='.bc',
LIBPREFIX='',
@@ -301,6 +300,12 @@ def generate(env):
'__IEEE_LITTLE_ENDIAN',
])
+ env.Append(
+ CPPPATH=[
+ env.Dir('${EMSCRIPTEN_HOME}/system/include'),
+ ]
+ )
+
env['BUILDERS']['Emscripten'] = Builder(
action='$PYTHON ${EMSCRIPTEN_HOME}/emscripten.py $EMSCRIPTEN_FLAGS $_EMSCRIPTEN_SETTINGS_FLAGS --temp-dir=$EMSCRIPTEN_TEMP_DIR --compiler $JS_ENGINE --relooper=third-party/relooper.js $SOURCE > $TARGET',
target_scanner=EmscriptenScanner)
diff --git a/scons-tools/llvm.py b/scons-tools/llvm.py
index f272bd16..2dc65dd3 100755
--- a/scons-tools/llvm.py
+++ b/scons-tools/llvm.py
@@ -1,5 +1,6 @@
from SCons.Scanner.Prog import scan
from SCons.Builder import Builder
+import os
def exists(env):
return True
@@ -23,11 +24,11 @@ def generate(env):
LLVM_LINK='llvm-link')
env['BUILDERS']['LLVMDis'] = Builder(
- action='${LLVM_ROOT}/$LLVM_DIS -o=$TARGET $SOURCE')
+ action=os.path.join('${LLVM_ROOT}', '$LLVM_DIS') + ' -o=$TARGET $SOURCE')
env['BUILDERS']['LLVMOpt'] = Builder(
- action='${LLVM_ROOT}/$LLVM_OPT $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE')
+ action=os.path.join('${LLVM_ROOT}', '$LLVM_OPT') + ' $LLVM_OPT_FLAGS $LLVM_OPT_PASSES -o=$TARGET $SOURCE')
env['BUILDERS']['LLVMLink'] = Builder(
- action='${LLVM_ROOT}/$LLVM_LINK -o=$TARGET $SOURCES',
+ action=os.path.join('${LLVM_ROOT}', '$LLVM_LINK') + ' -o=$TARGET $SOURCES',
emitter=add_libraries)
diff --git a/src/intertyper.js b/src/intertyper.js
index abfbdacb..dd6e5522 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -700,6 +700,12 @@ function intertyper(data, sidePass, baseLineNums) {
item.intertype = 'value';
if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1);
item.ident = tokensLeft[0].text.substr(1, tokensLeft[0].text.length-2) || ';'; // use ; for empty inline assembly
+ var i = 0;
+ splitTokenList(tokensLeft[3].item.tokens).map(function(element) {
+ var ident = toNiceIdent(element[1].text);
+ var type = element[0].text;
+ item.ident = item.ident.replace(new RegExp('\\$' + i++, 'g'), ident);
+ });
return { forward: null, ret: [item], item: item };
}
if (item.ident.substr(-2) == '()') {
diff --git a/src/library_egl.js b/src/library_egl.js
index 0ccb13e6..0e96e92f 100644
--- a/src/library_egl.js
+++ b/src/library_egl.js
@@ -260,8 +260,13 @@ var LibraryEGL = {
}
EGL.windowID = _glutCreateWindow();
- EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
- return 62004; // Magic ID for Emscripten EGLContext
+ if (EGL.windowID != 0) {
+ EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
+ return 62004; // Magic ID for Emscripten EGLContext
+ } else {
+ EGL.setErrorCode(0x3009 /* EGL_BAD_MATCH */); // By the EGL 1.4 spec, an implementation that does not support GLES2 (WebGL in this case), this error code is set.
+ return 0; /* EGL_NO_CONTEXT */
+ }
},
eglDestroyContext__deps: ['glutDestroyWindow', '$GL'],
diff --git a/src/library_glut.js b/src/library_glut.js
index 36d47787..29957e6f 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -385,7 +385,7 @@ var LibraryGLUT = {
glutCreateWindow__deps: ['$Browser'],
glutCreateWindow: function(name) {
Module.ctx = Browser.createContext(Module['canvas'], true, true);
- return 1;
+ return Module.ctx ? 1 /* a new GLUT window ID for the created context */ : 0 /* failure */;
},
glutDestroyWindow__deps: ['$Browser'],
diff --git a/tests/runner.py b/tests/runner.py
index 14de2db0..b662632d 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1989,6 +1989,8 @@ Succeeded!
# This example borrowed from MSDN documentation
def test_fcvt(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+
src = '''
#include <stdlib.h>
#include <stdio.h>
@@ -4083,17 +4085,11 @@ def process(filename):
self.do_run(src, 'Inline JS is very cool\n3.64')
- def zzztest_inlinejs2(self):
+ def test_inlinejs2(self):
if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm')
src = r'''
#include <stdio.h>
- double get() {
- double ret = 0;
- __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable
- return ret;
- }
-
int mix(int x, int y) {
int ret;
asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write
@@ -4106,15 +4102,13 @@ def process(filename):
}
int main(int argc, char **argv) {
- asm("Module.print('Inline JS is very cool')");
- printf("%.2f\n", get());
printf("%d\n", mix(argc, argc/2));
mult();
return 0;
}
'''
- self.do_run(src, 'Inline JS is very cool\n3.64\nwaka\nzakai\n')
+ self.do_run(src, '4\n200\n')
def test_memorygrowth(self):
if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
@@ -11457,6 +11451,8 @@ int main(int argc, char const *argv[])
for args, expected in [(['-I/usr/something'], True),
(['-L/usr/something'], True),
+ (['-I/usr/something', '-Wno-warn-absolute-paths'], False),
+ (['-L/usr/something', '-Wno-warn-absolute-paths'], False),
(['-Isubdir/something'], False),
(['-Lsubdir/something'], False),
([], False)]:
diff --git a/tools/shared.py b/tools/shared.py
index b80d9389..f6d0ff4f 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -360,8 +360,15 @@ def check_sanity(force=False):
# Tools/paths
-LLVM_ADD_VERSION = os.getenv('LLVM_ADD_VERSION')
-CLANG_ADD_VERSION = os.getenv('CLANG_ADD_VERSION')
+try:
+ LLVM_ADD_VERSION
+except NameError:
+ LLVM_ADD_VERSION = os.getenv('LLVM_ADD_VERSION')
+
+try:
+ CLANG_ADD_VERSION
+except NameError:
+ CLANG_ADD_VERSION = os.getenv('CLANG_ADD_VERSION')
# Some distributions ship with multiple llvm versions so they add
# the version to the binaries, cope with that