aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS4
-rwxr-xr-xemcc116
-rw-r--r--emscripten-version.txt2
-rwxr-xr-xemscripten.py1053
-rw-r--r--src/embind/embind.js301
-rw-r--r--src/embind/emval.js21
-rw-r--r--src/emscripten-source-map.min.js3
-rw-r--r--src/library.js199
-rw-r--r--src/library_browser.js42
-rw-r--r--src/library_html5.js6
-rw-r--r--src/library_sdl.js392
-rw-r--r--src/preamble.js195
-rw-r--r--src/relooper/Relooper.cpp9
-rw-r--r--src/relooper/fuzzer.py6
-rw-r--r--src/relooper/test.cpp31
-rw-r--r--src/relooper/test.txt153
-rw-r--r--src/shell.html11
-rw-r--r--src/shell_minimal.html11
-rw-r--r--src/struct_info.json18
-rw-r--r--system/include/emscripten/bind.h158
-rw-r--r--system/include/emscripten/html5.h6
-rw-r--r--system/include/emscripten/val.h20
-rw-r--r--system/lib/libc.symbols11
-rw-r--r--system/lib/libc/musl/src/compat/readme.txt2
-rw-r--r--system/lib/libc/musl/src/compat/strlwr.c12
-rw-r--r--system/lib/libc/musl/src/compat/strtol_l.c22
-rw-r--r--system/lib/libc/musl/src/compat/strupr.c12
-rw-r--r--system/lib/libc/musl/src/ctype/isalnum.c6
-rw-r--r--system/lib/libc/musl/src/ctype/isalpha.c7
-rw-r--r--system/lib/libc/musl/src/ctype/isascii.c6
-rw-r--r--system/lib/libc/musl/src/ctype/isblank.c6
-rw-r--r--system/lib/libc/musl/src/ctype/iscntrl.c6
-rw-r--r--system/lib/libc/musl/src/ctype/isdigit.c7
-rw-r--r--system/lib/libc/musl/src/ctype/isgraph.c4
-rw-r--r--system/lib/libc/musl/src/ctype/islower.c7
-rw-r--r--system/lib/libc/musl/src/ctype/isprint.c4
-rw-r--r--system/lib/libc/musl/src/ctype/ispunct.c6
-rw-r--r--system/lib/libc/musl/src/ctype/isspace.c6
-rw-r--r--system/lib/libc/musl/src/ctype/isupper.c7
-rw-r--r--system/lib/libc/musl/src/ctype/isxdigit.c6
-rw-r--r--system/lib/libc/musl/src/ctype/toascii.c7
-rw-r--r--system/lib/libc/musl/src/ctype/tolower.c7
-rw-r--r--system/lib/libc/musl/src/ctype/toupper.c7
-rw-r--r--system/lib/libc/musl/src/locale/isalnum_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isalpha_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isblank_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iscntrl_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isdigit_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isgraph_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/islower_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isprint_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/ispunct_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isspace_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isupper_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/isxdigit_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/tolower_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/toupper_l.c6
-rw-r--r--system/lib/libc/musl/src/stdlib/strtol.c64
-rw-r--r--system/lib/libcextra.symbols32
-rw-r--r--tests/cases/floatundefinvoke_fastcomp.ll30
-rw-r--r--tests/cases/floatundefinvoke_fastcomp.txt3
-rw-r--r--tests/cases/i1tof_ta2.ll71
-rw-r--r--tests/cases/i1tof_ta2.txt3
-rw-r--r--tests/core/test_double_varargs.c34
-rw-r--r--tests/core/test_double_varargs.out2
-rw-r--r--tests/core/test_exceptions_white_list_empty.out0
-rw-r--r--tests/embind/embind.test.js424
-rw-r--r--tests/embind/embind_test.cpp285
-rw-r--r--tests/emscripten_fs_api_browser.cpp5
-rw-r--r--tests/life.c2
-rw-r--r--tests/sdl_audio_mix.c2
-rw-r--r--tests/test_benchmark.py37
-rw-r--r--tests/test_core.py98
-rw-r--r--tests/test_other.py102
-rw-r--r--tests/test_sanity.py2
-rw-r--r--tests/webidl/output.txt2
-rw-r--r--tests/webidl/post.js3
-rw-r--r--tests/webidl/test.h3
-rw-r--r--tests/webidl/test.idl3
-rw-r--r--third_party/WebIDL.py13
-rw-r--r--tools/bisect_pair_lines.py63
-rw-r--r--tools/eliminator/asm-eliminator-test-output.js79
-rw-r--r--tools/eliminator/asm-eliminator-test.js73
-rw-r--r--tools/js-optimizer.js224
-rw-r--r--tools/js_optimizer.py28
-rw-r--r--tools/shared.py174
-rw-r--r--tools/system_libs.py42
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js78
-rw-r--r--tools/test-js-optimizer-asm-pre.js79
-rw-r--r--tools/test-js-optimizer-asm-regs-harder-output.js5
-rw-r--r--tools/test-js-optimizer-asm-regs-harder.js8
-rw-r--r--tools/webidl_binder.py3
92 files changed, 3833 insertions, 1242 deletions
diff --git a/AUTHORS b/AUTHORS
index 65354d07..2ff3bd94 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -138,4 +138,8 @@ a license to everyone to use it as detailed in LICENSE.)
* Guillaume Blanc <guillaumeblanc.sc@gmail.com>
* Usagi Ito <usagi@WonderRabbitProject.net>
* Camilo Polymeris <cpolymeris@gmail.com>
+* Markus Henschel <markus.henschel@yager.de>
+* Ophir Lojkine <ophir.lojkine@eleves.ec-nantes.fr>
+* Ryan Sturgell <ryan.sturgell@gmail.com> (copyright owned by Google, Inc.)
* Jason Green <jason@transgaming.com> (copyright owned by TransGaming, Inc.)
+
diff --git a/emcc b/emcc
index 1629f5c7..e55990df 100755
--- a/emcc
+++ b/emcc
@@ -64,6 +64,7 @@ DYNAMICLIB_ENDINGS = ('.dylib', '.so', '.dll')
STATICLIB_ENDINGS = ('.a',)
ASSEMBLY_ENDINGS = ('.ll',)
HEADER_ENDINGS = ('.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
+SUPPORTED_LINKER_FLAGS = ('--start-group', '-(', '--end-group', '-)')
LIB_PREFIXES = ('', 'lib')
@@ -1098,12 +1099,24 @@ try:
# Find input files
+ # These three arrays are used to store arguments of different types for
+ # type-specific processing. In order to shuffle the arguments back together
+ # after processing, all of these arrays hold tuples (original_index, value).
+ # Note that the index part of the tuple can have a fractional part for input
+ # arguments that expand into multiple processed arguments, as in -Wl,-f1,-f2.
input_files = []
+ libs = []
+ link_flags = []
+
+ # All of the above arg lists entries contain indexes into the full argument
+ # list. In order to add extra implicit args (embind.cc, etc) below, we keep a
+ # counter for the next index that should be used.
+ next_arg_index = len(newargs)
+
has_source_inputs = False
has_header_inputs = False
lib_dirs = [shared.path_from_root('system', 'local', 'lib'),
shared.path_from_root('system', 'lib')]
- libs = []
for i in range(len(newargs)): # find input files XXX this a simple heuristic. we should really analyze based on a full understanding of gcc params,
# right now we just assume that what is left contains no more |-x OPT| things
arg = newargs[i]
@@ -1124,13 +1137,13 @@ try:
if arg_ending.endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
newargs[i] = ''
if arg_ending.endswith(SOURCE_ENDINGS):
- input_files.append(arg)
+ input_files.append((i, arg))
has_source_inputs = True
elif arg_ending.endswith(HEADER_ENDINGS):
- input_files.append(arg)
+ input_files.append((i, arg))
has_header_inputs = True
elif arg_ending.endswith(ASSEMBLY_ENDINGS) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
- input_files.append(arg)
+ input_files.append((i, arg))
elif arg_ending.endswith(STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS):
# if it's not, and it's a library, just add it to libs to find later
l = unsuffixed_basename(arg)
@@ -1139,7 +1152,7 @@ try:
if l.startswith(prefix):
l = l[len(prefix):]
break
- libs.append(l)
+ libs.append((i, l))
newargs[i] = ''
else:
logging.warning(arg + ' is not valid LLVM bitcode')
@@ -1157,7 +1170,20 @@ try:
lib_dirs.append(arg[2:])
newargs[i] = ''
elif arg.startswith('-l'):
- libs.append(arg[2:])
+ libs.append((i, arg[2:]))
+ newargs[i] = ''
+ elif arg.startswith('-Wl,'):
+ # Multiple comma separated link flags can be specified. Create fake
+ # fractional indices for these: -Wl,a,b,c,d at index 4 becomes:
+ # (4, a), (4.25, b), (4.5, c), (4.75, d)
+ link_flags_to_add = arg.split(',')[1:]
+ for flag_index, flag in enumerate(link_flags_to_add):
+ # Only keep flags that shared.Building.link knows how to deal with.
+ # We currently can't handle flags with options (like
+ # -Wl,-rpath,/bin:/lib, where /bin:/lib is an option for the -rpath
+ # flag).
+ if flag in SUPPORTED_LINKER_FLAGS:
+ link_flags.append((i + float(flag_index) / len(link_flags_to_add), flag))
newargs[i] = ''
original_input_files = input_files[:]
@@ -1173,7 +1199,7 @@ try:
final_ending = ('.' + final_suffix) if len(final_suffix) > 0 else ''
# Find library files
- for lib in libs:
+ for i, lib in libs:
logging.debug('looking for library "%s"', lib)
found = False
for prefix in LIB_PREFIXES:
@@ -1183,7 +1209,7 @@ try:
path = os.path.join(lib_dir, name)
if os.path.exists(path):
logging.debug('found library "%s" at %s', lib, path)
- input_files.append(path)
+ input_files.append((i, path))
found = True
break
if found: break
@@ -1199,7 +1225,7 @@ try:
return False
else:
return True
- input_files = [input_file for input_file in input_files if check(input_file)]
+ input_files = [(i, input_file) for (i, input_file) in input_files if check(input_file)]
if len(input_files) == 0:
logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + STATICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS))
@@ -1211,7 +1237,8 @@ try:
# If we are using embind and generating JS, now is the time to link in bind.cpp
if bind and final_suffix in JS_CONTAINING_SUFFIXES:
- input_files.append(shared.path_from_root('system', 'lib', 'embind', 'bind.cpp'))
+ input_files.append((next_arg_index, shared.path_from_root('system', 'lib', 'embind', 'bind.cpp')))
+ next_arg_index += 1
# Apply optimization level settings
shared.Settings.apply_opt_level(opt_level, noisy=True)
@@ -1223,6 +1250,8 @@ try:
value = '"@' + os.path.abspath(value[1:]) + '"'
value = value.replace('\\\\', '/').replace('\\', '/') # Convert backslash paths to forward slashes on Windows as well, since the JS compiler otherwise needs the backslashes escaped (alternative is to escape all input paths passing to JS, which feels clumsier to read)
exec('shared.Settings.' + key + ' = ' + value)
+ if key == 'EXPORTED_FUNCTIONS':
+ shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS = shared.Settings.EXPORTED_FUNCTIONS[:] # used for warnings in emscripten.py
fastcomp = os.environ.get('EMCC_FAST_COMPILER') != '0'
@@ -1240,10 +1269,10 @@ try:
assert shared.Settings.TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1, 'fastcomp requires asmjs-unknown-emscripten'
assert shared.Settings.USE_TYPED_ARRAYS == 2, 'fastcomp assumes ta2'
assert not split_js_file, '--split-js is deprecated and not supported in fastcomp'
- assert shared.Settings.MAX_SETJMPS == 20, 'changing MAX_SETJMPS is not supported in fastcomp yet'
assert shared.Settings.INIT_HEAP == 0, 'HEAP_INIT is not supported in fastcomp (and should never be needed except for debugging)'
assert not shared.Settings.RUNTIME_TYPE_INFO, 'RUNTIME_TYPE_INFO is not supported in fastcomp'
assert not shared.Settings.CORRUPTION_CHECK, 'CORRUPTION_CHECK is not supported in asm.js mode, which is what fastcomp can emit (you can use non-asm.js mode in non-fastcomp)'
+ assert not shared.Settings.MAIN_MODULE and not shared.Settings.SIDE_MODULE, 'Linking modules is not supported in fastcomp'
except Exception, e:
logging.error('Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see https://github.com/kripken/emscripten/wiki/LLVM-Backend')
raise e
@@ -1260,8 +1289,8 @@ try:
fastcomp_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
fastcomp_opts += ['-enable-emscripten-cxx-exceptions']
- if len(shared.Settings.EXCEPTION_CATCHING_WHITELIST) > 0:
- fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST)]
+ if shared.Settings.DISABLE_EXCEPTION_CATCHING == 2:
+ fastcomp_opts += ['-emscripten-cxx-exceptions-whitelist=' + ','.join(shared.Settings.EXCEPTION_CATCHING_WHITELIST or ['fake'])]
if shared.Settings.ASM_JS:
assert opt_level >= 1 or fastcomp, 'asm.js requires -O1 or above'
@@ -1329,7 +1358,8 @@ try:
logging.warning('ALIASING_FUNCTION_POINTERS is on, function pointer comparisons may be invalid across types')
if shared.Settings.STB_IMAGE and final_suffix in JS_CONTAINING_SUFFIXES:
- input_files.append(shared.path_from_root('third_party', 'stb_image.c'))
+ input_files.append((next_arg_index, shared.path_from_root('third_party', 'stb_image.c')))
+ next_arg_index += 1
shared.Settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free']
if type(shared.Settings.EXPORTED_FUNCTIONS) in (list, tuple):
@@ -1363,9 +1393,10 @@ try:
# Precompiled headers support
if has_header_inputs:
- for header in input_files:
- assert header.endswith(HEADER_ENDINGS), 'if you have one header input, we assume you want to precompile headers, and cannot have source files or other inputs as well: ' + str(input_files) + ' : ' + header
- args = newargs + shared.EMSDK_CXX_OPTS + input_files
+ headers = [header for _, header in input_files]
+ for header in headers:
+ assert header.endswith(HEADER_ENDINGS), 'if you have one header input, we assume you want to precompile headers, and cannot have source files or other inputs as well: ' + str(headers) + ' : ' + header
+ args = newargs + shared.EMSDK_CXX_OPTS + headers
if specified_target:
args += ['-o', specified_target]
logging.debug("running (for precompiled headers): " + call + ' ' + ' '.join(args))
@@ -1386,12 +1417,12 @@ try:
return in_temp(unsuffixed(uniquename(input_file)) + default_object_extension)
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
- for input_file in input_files:
+ for i, input_file in input_files:
file_ending = filename_type_ending(inp