aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rwxr-xr-xemcc498
-rwxr-xr-xemscripten.py26
-rw-r--r--src/deps_info.json7
-rw-r--r--src/jsifier.js56
-rw-r--r--src/library.js100
-rw-r--r--src/library_browser.js12
-rw-r--r--src/library_egl.js2
-rw-r--r--src/library_gl.js198
-rw-r--r--src/library_idbfs.js2
-rw-r--r--src/library_sdl.js31
-rw-r--r--src/preamble.js4
-rw-r--r--src/settings.js14
-rw-r--r--system/include/X11/XKBlib.h1149
-rw-r--r--system/include/X11/Xfuncs.h69
-rw-r--r--system/include/X11/XlibConf.h38
-rw-r--r--system/include/X11/Xlibint.h1387
-rw-r--r--system/include/X11/Xmd.h185
-rw-r--r--system/include/X11/Xproto.h2157
-rw-r--r--system/include/X11/Xprotostr.h77
-rw-r--r--system/include/X11/cursorfont.h111
-rw-r--r--system/include/X11/extensions/XKB.h786
-rw-r--r--system/include/X11/extensions/XKBstr.h613
-rw-r--r--system/include/X11/extensions/XShm.h135
-rw-r--r--system/include/X11/extensions/Xext.h53
-rw-r--r--system/include/X11/extensions/extutil.h190
-rw-r--r--system/include/X11/extensions/shm.h44
-rw-r--r--system/include/emscripten/emscripten.h8
-rw-r--r--system/lib/gl.c1729
-rw-r--r--system/lib/gl.symbols1
-rw-r--r--system/lib/libc.symbols9
-rw-r--r--system/lib/libc/musl/src/locale/strcoll.c15
-rw-r--r--system/lib/libc/musl/src/string/memcmp.c8
-rw-r--r--system/lib/libc/musl/src/string/strcasecmp.c9
-rw-r--r--system/lib/libc/musl/src/string/strcmp.c7
-rw-r--r--system/lib/libc/musl/src/string/strncasecmp.c10
-rw-r--r--system/lib/libc/musl/src/string/strncmp.c9
-rw-r--r--system/lib/sdl.cpp13
-rw-r--r--system/lib/sdl.symbols1
-rw-r--r--tests/cases/bigdouble.ll17
-rw-r--r--tests/cases/bigdouble.txt1
-rw-r--r--tests/codemods.cpp21
-rw-r--r--tests/core/test_memcpy3.c51
-rw-r--r--tests/core/test_memcpy3.out81
-rw-r--r--tests/core/test_memset.c51
-rw-r--r--tests/core/test_memset.out81
-rw-r--r--tests/core/test_sscanf.in1
-rw-r--r--tests/core/test_strcmp_uni.out6
-rw-r--r--tests/cubegeom_proc.c331
-rwxr-xr-xtests/fuzz/csmith_driver.py2
-rw-r--r--tests/hello_world_gles_deriv.c1
-rw-r--r--tests/netinet/in.cpp14
-rw-r--r--tests/netinet/in.out1
-rwxr-xr-xtests/runner.py24
-rw-r--r--tests/sdlglshader.c5
-rw-r--r--tests/test_browser.py56
-rw-r--r--tests/test_core.py72
-rw-r--r--tests/test_egl.c5
-rw-r--r--tests/test_minmax.c89
-rw-r--r--tests/test_other.py24
-rw-r--r--tools/file_packager.py3
-rw-r--r--tools/js-optimizer.js18
-rw-r--r--tools/parse_unaligned.py17
-rw-r--r--tools/shared.py2
-rw-r--r--tools/system_libs.py397
-rw-r--r--tools/test-js-optimizer-asm-last-output.js2
-rw-r--r--tools/test-js-optimizer-asm-pre-f32.js11
-rw-r--r--tools/test-js-optimizer-asm-pre-output-f32.js11
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js19
-rw-r--r--tools/test-js-optimizer-asm-pre.js22
70 files changed, 10482 insertions, 718 deletions
diff --git a/AUTHORS b/AUTHORS
index 2c292dde..fc947687 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -120,3 +120,4 @@ a license to everyone to use it as detailed in LICENSE.)
* Jari Vetoniemi <mailroxas@gmail.com>
* Sindre Sorhus <sindresorhus@gmail.com>
* James S Urquhart <jamesu@gmail.com>
+* Boris Gjenero <boris.gjenero@gmail.com>
diff --git a/emcc b/emcc
index d30966cd..7686e818 100755
--- a/emcc
+++ b/emcc
@@ -47,16 +47,18 @@ emcc can be influenced by a few environment variables:
EMMAKEN_COMPILER - The compiler to be used, if you don't want the default clang.
'''
-import os, sys, shutil, tempfile, subprocess, shlex, time, re, logging
+import os, sys, shutil, tempfile, subprocess, shlex, time, re, logging, json
from subprocess import PIPE, STDOUT
-from tools import shared, jsrun
+from tools import shared, jsrun, system_libs
from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename, WINDOWS
from tools.response_file import read_response_file
# endings = dot + a suffix, safe to test by filename.endswith(endings)
C_ENDINGS = ('.c', '.C')
CXX_ENDINGS = ('.cpp', '.cxx', '.cc', '.CPP', '.CXX', '.CC')
-SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + ('.m', '.mm')
+OBJC_ENDINGS = ('.m',)
+OBJCXX_ENDINGS = ('.mm',)
+SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + OBJC_ENDINGS + OBJCXX_ENDINGS
BITCODE_ENDINGS = ('.bc', '.o', '.obj')
DYNAMICLIB_ENDINGS = ('.dylib', '.so', '.dll')
STATICLIB_ENDINGS = ('.a',)
@@ -311,6 +313,13 @@ Options that are modified or new in %s include:
If a directory is passed here, its entire
contents will be embedded.
+ Note: Embedding files is much less
+ efficient than preloading them. You
+ should only use it for small amounts
+ of small files. Instead, use
+ --preload-file which emits efficient
+ binary data.
+
--preload-file <name> A file to preload before running the
compiled code asynchronously. Otherwise
similar to --embed-file, except that this
@@ -384,6 +393,9 @@ Options that are modified or new in %s include:
The main file resides in the base directory and
has the suffix ".js".
+ Note: this option is deprecated (modern JS debuggers
+ should work ok even on large files)
+
--bind Compiles the source code using the "embind"
bindings approach, which connects C/C++ and JS.
@@ -704,7 +716,7 @@ use_cxx = True
for i in range(1, len(sys.argv)):
arg = sys.argv[i]
if not arg.startswith('-'):
- if arg.endswith(('.c','.m')):
+ if arg.endswith(C_ENDINGS + OBJC_ENDINGS):
use_cxx = False
if '-M' in sys.argv or '-MM' in sys.argv:
@@ -1186,7 +1198,7 @@ try:
fastcomp = os.environ.get('EMCC_FAST_COMPILER') == '1'
if fastcomp:
- shared.Settings.ASM_JS = 1
+ shared.Settings.ASM_JS = 1 if opt_level > 0 else 2
assert shared.Settings.ALLOW_MEMORY_GROWTH == 0, 'memory growth not supported in fastcomp yet'
assert shared.Settings.UNALIGNED_MEMORY == 0, 'forced unaligned memory not supported in fastcomp'
assert shared.Settings.CHECK_HEAP_ALIGN == 0, 'check heap align not supported in fastcomp yet'
@@ -1194,20 +1206,22 @@ try:
assert shared.Settings.RESERVED_FUNCTION_POINTERS == 0, 'reserved function pointers not supported in fastcomp'
assert shared.Settings.ASM_HEAP_LOG == 0, 'asm heap log not supported in fastcomp'
assert shared.Settings.LABEL_DEBUG == 0, 'label debug not supported in fastcomp'
- assert shared.Settings.LEGACY_GL_EMULATION == 0, 'legacy gl emulation not supported in fastcomp'
assert shared.Settings.EXECUTION_TIMEOUT == -1, 'execution timeout not supported in fastcomp'
assert shared.Settings.NAMED_GLOBALS == 0, 'named globals not supported in fastcomp'
assert shared.Settings.PGO == 0, 'pgo not supported in fastcomp'
assert shared.Settings.TARGET_LE32 == 1, 'fastcomp requires le32'
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 not bind, 'embind not supported in fastcomp yet'
if jcache:
logging.warning('jcache is not supported in fastcomp (you should not need it anyhow), disabling')
jcache = False
fastcomp_opts = ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
- if not shared.Settings.DISABLE_EXCEPTION_CATCHING:
+ 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.ASM_JS:
assert opt_level >= 1 or fastcomp, 'asm.js requires -O1 or above'
@@ -1399,374 +1413,12 @@ try:
logging.debug('will generate JavaScript')
- extra_files_to_link = []
-
if not LEAVE_INPUTS_RAW and \
- not shared.Settings.BUILD_AS_SHARED_LIB == 2 and \
+ not shared.Settings.BUILD_AS_SHARED_LIB and \
not shared.Settings.SIDE_MODULE: # shared libraries/side modules link no C libraries, need them in parent
-
- # Check if we need to include some libraries that we compile. (We implement libc ourselves in js, but
- # compile a malloc implementation and stdlibc++.)
-
- def read_symbols(path, exclude=None):
- symbols = map(lambda line: line.strip().split(' ')[1], open(path).readlines())
- if exclude:
- symbols = filter(lambda symbol: symbol not in exclude, symbols)
- return set(symbols)
-
- lib_opts = ['-O2']
-
- # XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
- # a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
- libc_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libc.symbols'))
- sdl_symbols = read_symbols(shared.path_from_root('system', 'lib', 'sdl.symbols'))
- libcextra_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libcextra.symbols'))
- libcxx_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libcxx', 'symbols'), exclude=libc_symbols)
- libcxxabi_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libcxxabi', 'symbols'), exclude=libc_symbols)
-
- # XXX we should disable EMCC_DEBUG when building libs, just like in the relooper
-
- def build_libc(lib_filename, files):
- o_s = []
- prev_cxx = os.environ.get('EMMAKEN_CXX')
- if prev_cxx: os.environ['EMMAKEN_CXX'] = ''
- musl_internal_includes = shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal')
- for src in files:
- o = in_temp(os.path.basename(src) + '.o')
- execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes] + lib_opts, stdout=stdout, stderr=stderr)
- o_s.append(o)
- if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
- shared.Building.link(o_s, in_temp(lib_filename))
- return in_temp(lib_filename)
-
- def build_libcxx(src_dirname, lib_filename, files):
- o_s = []
- for src in files:
- o = in_temp(src + '.o')
- srcfile = shared.path_from_root(src_dirname, src)
- execute([shared.PYTHON, shared.EMXX, srcfile, '-o', o, '-std=c++11'] + lib_opts, stdout=stdout, stderr=stderr)
- o_s.append(o)
- shared.Building.link(o_s, in_temp(lib_filename))
- return in_temp(lib_filename)
-
- # libc
- def create_libc():
- logging.debug(' building libc for cache')
- libc_files = [
- 'dlmalloc.c',
- os.path.join('libcxx', 'new.cpp'),
- ]
- musl_files = [
- ['internal', [
- 'floatscan.c',
- 'shgetc.c',
- ]],
- ['math', [
- 'scalbn.c',
- 'scalbnl.c',
- ]],
- ['stdio', [
- '__overflow.c',
- '__toread.c',
- '__towrite.c',
- '__uflow.c',
- ]],
- ['stdlib', [
- 'atof.c',
- 'strtod.c',
- ]]
- ]
- for directory, sources in musl_files:
- libc_files += [os.path.join('libc', 'musl', 'src', directory, source) for source in sources]
- return build_libc('libc.bc', libc_files)
-
- def apply_libc(need):
- # libc needs some sign correction. # If we are in mode 0, switch to 2. We will add our lines
- try:
- if shared.Settings.CORRECT_SIGNS == 0: raise Exception('we need to change to 2')
- except: # we fail if equal to 0 - so we need to switch to 2 - or if CORRECT_SIGNS is not even in Settings
- shared.Settings.CORRECT_SIGNS = 2
- if shared.Settings.CORRECT_SIGNS == 2:
- shared.Settings.CORRECT_SIGNS_LINES = [shared.path_from_root('src', 'dlmalloc.c') + ':' + str(i+4) for i in [4816, 4191, 4246, 4199, 4205, 4235, 4227]]
- # If we are in mode 1, we are correcting everything anyhow. If we are in mode 3, we will be corrected
- # so all is well anyhow too.
- return True
-
- # libcextra
- def create_libcextra():
- logging.debug('building libcextra for cache')
- musl_files = [
- ['ctype', [
- 'iswalnum.c',
- 'iswalpha.c',
- 'iswblank.c',
- 'iswcntrl.c',
- 'iswctype.c',
- 'iswdigit.c',
- 'iswgraph.c',
- 'iswlower.c',
- 'iswprint.c',
- 'iswpunct.c',
- 'iswspace.c',
- 'iswupper.c',
- 'iswxdigit.c',
- 'towctrans.c',
- 'wcswidth.c',
- 'wctrans.c',
- 'wcwidth.c',
- ]],
- ['internal', [
- 'intscan.c',
- ]],
- ['legacy', [
- 'err.c',
- ]],
- ['locale', [
- 'iconv.c',
- 'iswalnum_l.c',
- 'iswalpha_l.c',
- 'iswblank_l.c',
- 'iswcntrl_l.c',
- 'iswctype_l.c',
- 'iswdigit_l.c',
- 'iswgraph_l.c',
- 'iswlower_l.c',
- 'iswprint_l.c',
- 'iswpunct_l.c',
- 'iswspace_l.c',
- 'iswupper_l.c',
- 'iswxdigit_l.c',
- 'strcasecmp_l.c',
- 'strfmon.c',
- 'strncasecmp_l.c',
- 'strxfrm.c',
- 'towctrans_l.c',
- 'towlower_l.c',
- 'towupper_l.c',
- 'wcscoll.c',
- 'wcscoll_l.c',
- 'wcsxfrm.c',
- 'wcsxfrm_l.c',
- 'wctrans_l.c',
- 'wctype_l.c',
- ]],
- ['math', [
- '__cos.c',
- '__cosdf.c',
- '__sin.c',
- '__sindf.c',
- 'ilogb.c',
- 'ilogbf.c',
- 'ilogbl.c',
- 'ldexp.c',
- 'ldexpf.c',
- 'ldexpl.c',
- 'logb.c',
- 'logbf.c',
- 'logbl.c',
- 'lgamma.c',
- 'lgamma_r.c',
- 'lgammaf.c',
- 'lgammaf_r.c',
- 'lgammal.c',
- 'scalbnf.c',
- 'signgam.c',
- 'tgamma.c',
- 'tgammaf.c',
- 'tgammal.c'
- ]],
- ['misc', [
- 'getopt.c',
- 'getopt_long.c',
- ]],
- ['multibyte', [
- 'btowc.c',
- 'mblen.c',
- 'mbrlen.c',
- 'mbrtowc.c',
- 'mbsinit.c',
- 'mbsnrtowcs.c',
- 'mbsrtowcs.c',
- 'mbstowcs.c',
- 'mbtowc.c',
- 'wcrtomb.c',
- 'wcsnrtombs.c',
- 'wcsrtombs.c',
- 'wcstombs.c',
- 'wctob.c',
- 'wctomb.c',
- ]],
- ['regex', [
- 'fnmatch.c',
- 'regcomp.c',
- 'regerror.c',
- 'regexec.c',
- 'tre-mem.c',
- ]],
- ['stdio', [
- 'fwprintf.c',
- 'swprintf.c',
- 'vfwprintf.c',
- 'vswprintf.c',
- 'vwprintf.c',
- 'wprintf.c',
- 'fputwc.c',
- 'fputws.c',
- ]],
- ['stdlib', [
- 'ecvt.c',
- 'fcvt.c',
- 'gcvt.c',
- 'wcstod.c',
- 'wcstol.c',
- ]],
- ['string', [
- 'memccpy.c',
- 'memmem.c',
- 'mempcpy.c',
- 'memrchr.c',
- 'strcasestr.c',
- 'strchrnul.c',
- 'strlcat.c',
- 'strlcpy.c',
- 'strsep.c',
- 'strverscmp.c',
- 'wcpcpy.c',
- 'wcpncpy.c',
- 'wcscasecmp.c',
- 'wcscasecmp_l.c',
- 'wcscat.c',
- 'wcschr.c',
- 'wcscmp.c',
- 'wcscpy.c',
- 'wcscspn.c',
- 'wcsdup.c',
- 'wcslen.c',
- 'wcsncasecmp.c',
- 'wcsncasecmp_l.c',
- 'wcsncat.c',
- 'wcsncmp.c',
- 'wcsncpy.c',
- 'wcsnlen.c',
- 'wcspbrk.c',
- 'wcsrchr.c',
- 'wcsspn.c',
- 'wcsstr.c',
- 'wcstok.c',
- 'wcswcs.c',
- 'wmemchr.c',
- 'wmemcmp.c',
- 'wmemcpy.c',
- 'wmemmove.c',
- 'wmemset.c',
- ]]
- ]
- libcextra_files = []
- for directory, sources in musl_files:
- libcextra_files += [os.path.join('libc', 'musl', 'src', directory, source) for source in sources]
- return build_libc('libcextra.bc', libcextra_files)
-
- # libcxx
- def create_libcxx():
- logging.debug('building libcxx for cache')
- libcxx_files = [
- 'algorithm.cpp',
- 'condition_variable.cpp',
- 'future.cpp',
- 'iostream.cpp',
- 'memory.cpp',
- 'random.cpp',
- 'stdexcept.cpp',
- 'system_error.cpp',
- 'utility.cpp',
- 'bind.cpp',
- 'debug.cpp',
- 'hash.cpp',
- 'mutex.cpp',
- 'string.cpp',
- 'thread.cpp',
- 'valarray.cpp',
- 'chrono.cpp',
- 'exception.cpp',
- 'ios.cpp',
- 'locale.cpp',
- 'regex.cpp',
- 'strstream.cpp'
- ]
- return build_libcxx(os.path.join('system', 'lib', 'libcxx'), 'libcxx.bc', libcxx_files)
-
- def apply_libcxx(need):
- assert shared.Settings.QUANTUM_SIZE == 4, 'We do not support libc++ with QUANTUM_SIZE == 1'
- # libcxx might need corrections, so turn them all on. TODO: check which are actually needed
- shared.Settings.CORRECT_SIGNS = shared.Settings.CORRECT_OVERFLOWS = shared.Settings.CORRECT_ROUNDINGS = 1
- #logging.info('using libcxx turns on CORRECT_* options')
- return True
-
- # libcxxabi - just for dynamic_cast for now
- def create_libcxxabi():
- logging.debug('building libcxxabi for cache')
- libcxxabi_files = [
- 'typeinfo.cpp',
- 'private_typeinfo.cpp'
- ]
- return build_libcxx(os.path.join('system', 'lib', 'libcxxabi', 'src'), 'libcxxabi.bc', libcxxabi_files)
-
- def apply_libcxxabi(need):
- assert shared.Settings.QUANTUM_SIZE == 4, 'We do not support libc++abi with QUANTUM_SIZE == 1'
- #logging.info('using libcxxabi, this may need CORRECT_* options')
- #shared.Settings.CORRECT_SIGNS = shared.Settings.CORRECT_OVERFLOWS = shared.Settings.CORRECT_ROUNDINGS = 1
- return True
-
- # SDL. We include code that demands malloc/free if not already required, so we have proper malloc/free from JS SDL code.
- # Note that the Force instance here can be optimized out, but we still export malloc/free, so they will be kept alive.
- def create_sdl():
- return build_libcxx(os.path.join('system', 'lib'), 'sdl.bc', ['sdl.cpp'])
-
- def apply_sdl(need):
- return 'SDL_Init' in all_needed and ('malloc' not in all_needed or 'free' not in all_needed)
-
- # Settings this in the environment will avoid checking dependencies and make building big projects a little faster
- # 1 means include everything; otherwise it can be the name of a lib (libcxx, etc.)
- force = os.environ.get('EMCC_FORCE_STDLIBS')
- force_all = force == '1'
-
- # Scan symbols
- all_needed = set()
- symbolses = map(lambda temp_file: shared.Building.llvm_nm(temp_file), temp_files)
- for symbols in symbolses:
- all_needed.update(symbols.undefs)
- for symbols in symbolses:
- all_needed.difference_update(symbols.defs)