diff options
88 files changed, 487 insertions, 322 deletions
@@ -470,7 +470,16 @@ Options that are modified or new in %s include: 1: Emit a separate memory initialization file in binary format. This is more efficient than storing it as text inside JavaScript, but does - mean you have another file to publish. + mean you have another file to publish. The + binary file will also be loaded asynchronously, + which means main() will not be called until + the file is downloaded and applied; you cannot + call any C functions until it arrives. (Call + yourself from main() to know when all async + stuff has happened and it is safe to call + library functions, as main() will only be + called at that time. You can also call + addOnPreMain from a preRun.) -Wno-warn-absolute-paths If not specified, the compiler will warn about any uses of absolute paths in -I and -L command line @@ -1369,6 +1378,7 @@ try: if file_ending.endswith(SOURCE_ENDINGS): temp_file = temp_files[i] logging.debug('optimizing %s', input_file) + #if DEBUG: shutil.copyfile(temp_file, os.path.join(TEMP_DIR, 'to_opt.bc') # useful when LLVM opt aborts shared.Building.llvm_opt(temp_file, llvm_opts) # If we were just asked to generate bitcode, stop there diff --git a/emscripten.py b/emscripten.py index 7f8b5505..c8122cb9 100755 --- a/emscripten.py +++ b/emscripten.py @@ -748,6 +748,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, backend_args += ['-emscripten-reserved-function-pointers=%d' % settings['RESERVED_FUNCTION_POINTERS']] if settings['ASSERTIONS'] > 0: backend_args += ['-emscripten-assertions=%d' % settings['ASSERTIONS']] + backend_args += ['-O' + str(settings['OPT_LEVEL'])] if DEBUG: logging.debug('emscript: llvm backend: ' + ' '.join(backend_args)) t = time.time() @@ -823,6 +824,8 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, ) + map(lambda x: x[1:], metadata['externs']) if metadata['simd']: settings['SIMD'] = 1 + if not metadata['canValidate'] and settings['ASM_JS'] != 2: + logging.warning('disabling asm.js validation due to use of non-supported features') settings['ASM_JS'] = 2 # Save settings to a file to work around v8 issue 1579 diff --git a/scons-tools/emscripten.py b/scons-tools/emscripten.py index af85f106..94153adb 100755 --- a/scons-tools/emscripten.py +++ b/scons-tools/emscripten.py @@ -9,11 +9,6 @@ from SCons.Scanner import Scanner def exists(env):
return True
-def _expand_settings_flags(settings, env):
- return [
- ('-s%s=%s' % (KEY, json.dumps(VALUE).replace('"', '\\"')))
- for KEY, VALUE in settings.items() ]
-
emscripten_version_files = {}
def build_version_file(env):
@@ -86,10 +81,6 @@ def emscripten(env, target_js, source_bc): buildName('raw.js'),
[opt_ll])
- [optimized_js] = env.JSOptimizer(
- buildName('opt.js'),
- raw_emscripten_js)
-
prejs = [
env['EMSCRIPTEN_PREJS'],
'${EMSCRIPTEN_HOME}/src/embind/emval.js',
@@ -98,7 +89,7 @@ def emscripten(env, target_js, source_bc): [concatenated_js] = env.Concatenate(
buildName('concat.js'),
[ prejs,
- optimized_js,
+ raw_emscripten_js,
env['EMSCRIPTEN_POSTJS'] ])
DISABLE_EMSCRIPTEN_WARNINGS = [
@@ -139,11 +130,6 @@ def emscripten(env, target_js, source_bc): concatenated_js,
CLOSURE_FLAGS=['--language_in', 'ECMASCRIPT5']+DISABLE_EMSCRIPTEN_WARNINGS+['--formatting', 'PRETTY_PRINT', '--compilation_level', 'ADVANCED_OPTIMIZATIONS'])
- [global_emscripten_min_js] = env.JSOptimizer(
- buildName('global.min.js'),
- closure_js,
- JS_OPTIMIZER_PASSES=['simplifyExpressionsPost', 'minifyWhitespace', 'last'])
-
[emscripten_iteration_js] = env.WrapInModule(
buildName('iteration.js'),
iter_global_emscripten_js)
@@ -154,12 +140,27 @@ def emscripten(env, target_js, source_bc): [emscripten_min_js] = env.WrapInModule(
buildName('min.js'),
- global_emscripten_min_js)
+ closure_js)
return [emscripten_iteration_js, emscripten_js, emscripten_min_js]
LIBC_SOURCES = [
'system/lib/dlmalloc.c',
+ 'system/lib/libc/musl/src/internal/floatscan.c',
+ 'system/lib/libc/musl/src/internal/shgetc.c',
+ 'system/lib/libc/musl/src/math/scalbn.c',
+ 'system/lib/libc/musl/src/math/scalbnl.c',
+ 'system/lib/libc/musl/src/stdio/__overflow.c',
+ 'system/lib/libc/musl/src/stdio/__toread.c',
+ 'system/lib/libc/musl/src/stdio/__towrite.c',
+ 'system/lib/libc/musl/src/stdio/__uflow.c',
+ 'system/lib/libc/musl/src/stdlib/atof.c',
+ 'system/lib/libc/musl/src/stdlib/strtod.c',
+ 'system/lib/libc/musl/src/string/memcmp.c',
+ 'system/lib/libc/musl/src/string/strcasecmp.c',
+ 'system/lib/libc/musl/src/string/strcmp.c',
+ 'system/lib/libc/musl/src/string/strncasecmp.c',
+ 'system/lib/libc/musl/src/string/strncmp.c',
'system/lib/libc/musl/src/string/wmemset.c',
'system/lib/libc/musl/src/string/wmemcpy.c',
]
@@ -185,13 +186,14 @@ LIBCXX_SOURCES = [os.path.join('system/lib/libcxx', x) for x in [ 'strstream.cpp',
'system_error.cpp',
#'thread.cpp',
- 'typeinfo.cpp',
+ #'typeinfo.cpp',
'utility.cpp',
'valarray.cpp',
]]
LIBCXXABI_SOURCES = [os.path.join('system/lib/libcxxabi/src', x) for x in [
- 'private_typeinfo.cpp'
+ 'private_typeinfo.cpp',
+ 'typeinfo.cpp'
]]
# MAJOR HACK ALERT
@@ -233,6 +235,7 @@ def build_libcxx(env): env = env.Clone()
env['CXXFLAGS'] = filter(lambda e: e not in ('-Werror', '-Wall'), env['CXXFLAGS'])
env['CCFLAGS'] = filter(lambda e: e not in ('-Werror', '-Wall'), env['CCFLAGS'])
+ env['CCFLAGS'] = env['CCFLAGS'] + ['-isystem${EMSCRIPTEN_HOME}/system/lib/libc/musl/src/internal/']
objs = [
env.Object(
@@ -248,16 +251,10 @@ def build_libcxx(env): def generate(env):
env.SetDefault(
PYTHON=sys.executable,
- NODEJS='node',
- JS_ENGINE='$NODEJS',
- EMSCRIPTEN_FLAGS=['-v', '-j', '--suppressUsageWarning'],
+ EMSCRIPTEN_FLAGS=[],
EMSCRIPTEN_TEMP_DIR=env.Dir('#/emscripten.tmp'),
- _expand_settings_flags=_expand_settings_flags,
EMSCRIPTEN_PREJS=[],
EMSCRIPTEN_POSTJS=[],
- EMSCRIPTEN_SETTINGS={},
- _EMSCRIPTEN_SETTINGS_FLAGS='${_expand_settings_flags(EMSCRIPTEN_SETTINGS, __env__)}',
- JS_OPTIMIZER_PASSES=[],
LLVM_OPT_PASSES=['-std-compile-opts', '-std-link-opts'],
EMSCRIPTEN_HOME=env.Dir(os.path.join(os.path.dirname(__file__), '..')),
@@ -274,7 +271,7 @@ def generate(env): RANLIBCOM='',
CCFLAGS=[
'-U__STRICT_ANSI__',
- '-target', 'asmjs-unknown-emscripten',
+ '-target', 'le32-unknown-nacl',
'-nostdinc',
'-Wno-#warnings',
'-Wno-error=unused-variable',
@@ -286,10 +283,9 @@ def generate(env): '-Xclang', '-nostdinc++',
'-Xclang', '-nobuiltininc',
'-Xclang', '-nostdsysteminc',
- '-Xclang', '-isystem$EMSCRIPTEN_HOME/system/include',
+ '-Xclang', '-isystem$EMSCRIPTEN_HOME/system/include/compat',
'-Xclang', '-isystem$EMSCRIPTEN_HOME/system/include/libc',
'-Xclang', '-isystem$EMSCRIPTEN_HOME/system/include/libcxx',
- '-Xclang', '-isystem$EMSCRIPTEN_HOME/system/include/bsd',
'-emit-llvm'],
CXXFLAGS=['-std=c++11', '-fno-exceptions'],
)
@@ -307,11 +303,7 @@ def generate(env): )
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)
-
- env['BUILDERS']['JSOptimizer'] = Builder(
- action='$JS_ENGINE ${EMSCRIPTEN_HOME}/tools/js-optimizer.js $SOURCE $JS_OPTIMIZER_PASSES > $TARGET',
+ action='$PYTHON ${EMSCRIPTEN_HOME}/emcc ${EMSCRIPTEN_FLAGS} $SOURCE -o $TARGET',
target_scanner=EmscriptenScanner)
def depend_on_embedder(target, source, env):
diff --git a/src/library.js b/src/library.js index 62695ae7..2c3d5e03 100644 --- a/src/library.js +++ b/src/library.js @@ -9114,6 +9114,10 @@ LibraryManager.library = { #endif #endif + emscripten_debugger: function() { + debugger; + }, + //============================ // emscripten vector ops //============================ diff --git a/src/library_browser.js b/src/library_browser.js index 03da394e..a280d1b2 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -348,9 +348,9 @@ mergeInto(LibraryManager.library, { if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false; var canvas = Module['canvas']; - var canvasContainer = canvas.parentNode; function fullScreenChange() { Browser.isFullScreen = false; + var canvasContainer = canvas.parentNode; if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] || document['mozFullScreenElement'] || document['mozFullscreenElement'] || document['fullScreenElement'] || document['fullscreenElement'] || @@ -369,7 +369,6 @@ mergeInto(LibraryManager.library, { } else { // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen - var canvasContainer = canvas.parentNode; canvasContainer.parentNode.insertBefore(canvas, canvasContainer); canvasContainer.parentNode.removeChild(canvasContainer); diff --git a/src/library_fs.js b/src/library_fs.js index 1428f041..3d0036ee 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1436,82 +1436,81 @@ mergeInto(LibraryManager.library, { // XHR, which is not possible in browsers except in a web worker! Use preloading, // either --preload-file in emcc or FS.createPreloadedFile createLazyFile: function(parent, name, url, canRead, canWrite) { - if (typeof XMLHttpRequest !== 'undefined') { - if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'; - // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse. - function LazyUint8Array() { - this.lengthKnown = false; - this.chunks = []; // Loaded chunks. Index is the chunk number - } - LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) { - if (idx > this.length-1 || idx < 0) { - return undefined; - } - var chunkOffset = |