aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS3
-rwxr-xr-xemar2
-rwxr-xr-xemcc145
-rwxr-xr-xemscripten.py205
-rw-r--r--src/analyzer.js18
-rw-r--r--src/compiler.js7
-rw-r--r--src/intertyper.js2
-rw-r--r--src/jsifier.js44
-rw-r--r--src/library.js145
-rw-r--r--src/library_browser.js7
-rw-r--r--src/library_gc.js2
-rw-r--r--src/library_gl.js353
-rw-r--r--src/library_sdl.js35
-rw-r--r--src/modules.js22
-rw-r--r--src/parseTools.js88
-rw-r--r--src/preamble.js71
-rw-r--r--src/relooper/Relooper.cpp84
-rw-r--r--src/relooper/test.txt4
-rw-r--r--src/relooper/test2.txt15
-rw-r--r--src/relooper/test3.txt38
-rw-r--r--src/relooper/test4.txt21
-rw-r--r--src/relooper/test6.txt15
-rw-r--r--src/relooper/test_debug.txt15
-rw-r--r--src/relooper/test_fuzz1.txt13
-rw-r--r--src/relooper/test_fuzz5.txt27
-rw-r--r--src/relooper/test_inf.txt651
-rw-r--r--src/runtime.js9
-rw-r--r--src/settings.js30
-rw-r--r--src/shell.html2
-rw-r--r--system/include/emscripten/emscripten.h28
-rw-r--r--system/include/stdbool.h3
-rw-r--r--system/lib/dlmalloc.c9123
-rw-r--r--system/lib/libc.symbols5
-rw-r--r--tests/aniso.c5
-rw-r--r--tests/bullet/output3.txt270
-rw-r--r--tests/cases/atomicrmw.ll1
-rw-r--r--tests/cases/breakinthemiddle2.ll35
-rw-r--r--tests/cases/callalias.ll21
-rw-r--r--tests/cases/callalias2.ll22
-rw-r--r--tests/cases/cmpxchg_volatile.ll548
-rw-r--r--tests/cases/inttoptrfloat.ll20
-rw-r--r--tests/cases/udiv.ll19
-rwxr-xr-xtests/csmith_driver.py50
-rw-r--r--tests/cubegeom.c6
-rw-r--r--tests/cubegeom_pre2_vao.c380
-rw-r--r--tests/cubegeom_pre2_vao2.c381
-rw-r--r--tests/dlmalloc_test.c4
-rw-r--r--tests/fuzz/1.c117
-rw-r--r--tests/fuzz/1.c.txt1
-rw-r--r--tests/fuzz/2.c2006
-rw-r--r--tests/fuzz/2.c.txt1
-rw-r--r--tests/fuzz/3.c1043
-rw-r--r--tests/fuzz/3.c.txt1
-rw-r--r--tests/fuzz/4.c216
-rw-r--r--tests/fuzz/4.c.txt1
-rw-r--r--tests/fuzz/5.c13
-rw-r--r--tests/fuzz/5.c.txt101
-rw-r--r--tests/fuzz/7.c852
-rw-r--r--tests/fuzz/7.c.txt1
-rw-r--r--tests/fuzz/8.c2214
-rw-r--r--tests/fuzz/8.c.txt1
-rwxr-xr-xtests/fuzz/creduce_tester.py53
-rw-r--r--tests/fuzz/csmith.h130
-rwxr-xr-xtests/fuzz/csmith_driver.py122
-rw-r--r--tests/fuzz/platform_generic.h132
-rw-r--r--tests/fuzz/random_inc.h129
-rw-r--r--tests/fuzz/safe_math.h947
-rw-r--r--tests/glbook/CH13_ParticleSystem.pngbin5106 -> 4921 bytes
-rw-r--r--tests/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c48
-rw-r--r--tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle_orig.c2
-rw-r--r--tests/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c2
-rw-r--r--tests/hello_libcxx_mod2.cpp10
-rw-r--r--tests/hello_libcxx_mod2a.cpp11
-rwxr-xr-xtests/runner.py386
-rw-r--r--tests/sdl_text.c40
-rw-r--r--tests/websockets.c7
-rw-r--r--third_party/jni/emjvm.cpp133
-rw-r--r--third_party/jni/emjvm.h8
-rw-r--r--third_party/jni/emjvm.js180
-rw-r--r--third_party/jni/jni.h1154
-rw-r--r--tools/autodebugger_c.py10
-rw-r--r--tools/cache.py194
l---------tools/eliminator/node_modules/.bin/cake1
l---------tools/eliminator/node_modules/.bin/coffee1
-rw-r--r--tools/file_packager.py4
-rw-r--r--tools/js_optimizer.py28
-rw-r--r--tools/jsrun.py27
-rw-r--r--tools/shared.py429
-rw-r--r--tools/tempfiles.py40
90 files changed, 18355 insertions, 5436 deletions
diff --git a/.gitignore b/.gitignore
index 31814a09..843b21b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ src/relooper.js.raw.js
src/relooper/*.o
src/relooper/*.out
+tests/fake/ \ No newline at end of file
diff --git a/AUTHORS b/AUTHORS
index 2e0c06e8..296d4150 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -49,4 +49,7 @@ a license to everyone to use it as detailed in LICENSE.)
* Manuel Schölling <manuel.schoelling@gmx.de>
* Bruce Mitchener, Jr. <bruce.mitchener@gmail.com>
* Michael Bishop <mbtyke@gmail.com>
+* Roger Braun <roger@rogerbraun.net>
+* Vladimir Vukicevic <vladimir@pobox.com> (copyright owned by Mozilla Foundation)
+* Lorant Pinter <lorant.pinter@prezi.com>
diff --git a/emar b/emar
index 60498b8f..5646f444 100755
--- a/emar
+++ b/emar
@@ -11,6 +11,8 @@ import os, subprocess, sys
from tools import shared
DEBUG = os.environ.get('EMCC_DEBUG')
+if DEBUG == "0":
+ DEBUG = None
newargs = [shared.LLVM_AR] + sys.argv[1:]
diff --git a/emcc b/emcc
index d28df40f..f644b924 100755
--- a/emcc
+++ b/emcc
@@ -1,4 +1,5 @@
#!/usr/bin/env python2
+# -*- Mode: python -*-
'''
emcc - compiler helper script
@@ -90,7 +91,10 @@ LLVM_OPT_LEVEL = {
3: 3,
}
-DEBUG = int(os.environ.get('EMCC_DEBUG') or 0)
+DEBUG = os.environ.get('EMCC_DEBUG')
+if DEBUG == "0":
+ DEBUG = None
+
TEMP_DIR = os.environ.get('EMCC_TEMP_DIR')
LEAVE_INPUTS_RAW = os.environ.get('EMCC_LEAVE_INPUTS_RAW') # Do not compile .ll files into .bc, just compile them with emscripten directly
# Not recommended, this is mainly for the test runner, or if you have some other
@@ -118,6 +122,28 @@ if len(sys.argv) == 1:
print 'emcc: no input files'
exit(1)
+# read response files very early on
+response_file = True
+while response_file:
+ response_file = None
+ for index in range(1, len(sys.argv)):
+ if sys.argv[index][0] == '@':
+ # found one, loop again next time
+ print >>sys.stderr, 'emcc: using response file: %s' % response_file
+ response_file = sys.argv[index][1:]
+ if not os.path.exists(response_file):
+ print >>sys.stderr, 'emcc: error: Response file not found: %s' % response_file
+ exit(1)
+
+ response_fd = open(response_file, 'r')
+ extra_args = shlex.split(response_fd.read())
+ response_fd.close()
+
+ # slice in extra_args in place of the response file arg
+ sys.argv[index:index+1] = extra_args
+ #if DEBUG: print >>sys.stderr, "Expanded response file: " + " | ".join(sys.argv)
+ break
+
if sys.argv[1] == '--version':
revision = '(unknown revision)'
here = os.getcwd()
@@ -155,16 +181,18 @@ Options that are modified or new in %s include:
tools/shared.py and also src/settings.js.)
Note: Optimizations are only done when
compiling to JavaScript, not to intermediate
- bitcode.
+ bitcode, *unless* you build with
+ EMCC_OPTIMIZE_NORMALLY=1 (not recommended
+ unless you know what you are doing!)
-O2 As -O1, plus the relooper (loop recreation),
plus LLVM -O2 optimizations
-O3 As -O2, plus dangerous optimizations that may
break the generated code! This adds
- -s INLINING_LIMIT=0
-s DOUBLE_MODE=0
-s PRECISE_I64_MATH=0
--closure 1
+ --llvm-lto 1
This is not recommended at all. A better idea
is to try each of these separately on top of
@@ -207,8 +235,8 @@ Options that are modified or new in %s include:
2: -O2 LLVM optimizations
3: -O3 LLVM optimizations (default in -O2+)
- --llvm-lto <level> 0: No LLVM LTO (default in -O0)
- 1: LLVM LTO (default in -O1+)
+ --llvm-lto <level> 0: No LLVM LTO (default in -O2 and below)
+ 1: LLVM LTO (default in -O3)
Note: If LLVM optimizations are not run
(see --llvm-opts), setting this to 1 has no
effect.
@@ -374,6 +402,41 @@ Options that are modified or new in %s include:
for a later incremental build (where you also
enable it) to be sped up.
+ Caching works separately on 4 parts of compilation:
+ 'pre' which is types and global variables; that
+ information is then fed into 'funcs' which are
+ the functions (which we parallelize), and then
+ 'post' which adds final information based on
+ the functions (e.g., do we need long64 support
+ code). Finally, 'jsfuncs' are JavaScript-level
+ optimizations. Each of the 4 parts can be cached
+ separately, but note that they can affect each
+ other: If you recompile a single C++ file that
+ changes a global variable - e.g., adds, removes
+ or modifies a global variable, say by adding
+ a printf or by adding a compile-time timestamp,
+ then 'pre' cannot be loaded from the cache. And
+ since 'pre's output is sent to 'funcs' and 'post',
+ they will get invalidated as well, and only
+ 'jsfuncs' will be cached. So avoid modifying
+ globals to let caching work fully.
+
+ To work around the problem mentioned in the
+ previous paragraph, you can use
+
+ emscripten_jcache_printf
+
+ when adding debug printfs to your code. That
+ function is specially preprocessed so that it
+ does not create a constant string global for
+ its first argument. See emscripten.h for more
+ details. Note in particular that you need to
+ already have a call to that function in your
+ code *before* you add one and do an incremental
+ build, so that adding an external reference
+ (also a global property) does not invalidate
+ everything.
+
--clear-cache Manually clears the cache of compiled
emscripten system libraries (libc++,
libc++abi, libc). This is normally
@@ -646,7 +709,8 @@ try:
for i in range(len(newargs)):
newargs[i] = newargs[i].strip() # On Windows Vista (and possibly others), excessive spaces in the command line leak into the items in this array, so trim e.g. 'foo.cpp ' -> 'foo.cpp'
if newargs[i].startswith('-O'):
- requested_level = newargs[i][2]
+ # Let -O default to -O2, which is what gcc does.
+ requested_level = newargs[i][2:] or '2'
if requested_level == 's':
print >> sys.stderr, 'emcc: warning: -Os is ignored (use -O0, -O1, -O2)'
else:
@@ -768,7 +832,7 @@ try:
newargs = newargs + [default_cxx_std]
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
- if llvm_lto is None: llvm_lto = llvm_opts > 0
+ if llvm_lto is None: llvm_lto = opt_level >= 3
if opt_level <= 0: keep_llvm_debug = keep_js_debug = True # always keep debug in -O0
if opt_level > 0: keep_llvm_debug = False # JS optimizer wipes out llvm debug info from being visible
if closure is None and opt_level == 3: closure = True
@@ -930,6 +994,7 @@ try:
for input_file in input_files:
if input_file.endswith(SOURCE_SUFFIXES):
if DEBUG: print >> sys.stderr, 'emcc: compiling source file: ', input_file
+ input_file = shared.Building.preprocess(input_file, in_temp(uniquename(input_file)))
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
temp_files.append(output_file)
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
@@ -963,7 +1028,15 @@ try:
# If we were just asked to generate bitcode, stop there
if final_suffix not in JS_CONTAINING_SUFFIXES:
if llvm_opts > 0:
- print >> sys.stderr, 'emcc: warning: -Ox flags ignored, since not generating JavaScript'
+ if not os.environ.get('EMCC_OPTIMIZE_NORMALLY'):
+ print >> sys.stderr, 'emcc: warning: -Ox flags ignored, since not generating JavaScript'
+ else:
+ for input_file in input_files:
+ if input_file.endswith(SOURCE_SUFFIXES):
+ if DEBUG: print >> sys.stderr, 'emcc: optimizing %s with -O%d since EMCC_OPTIMIZE_NORMALLY defined' % (input_file, llvm_opts)
+ shared.Building.llvm_opt(in_temp(unsuffixed(uniquename(input_file)) + '.o'), llvm_opts)
+ else:
+ if DEBUG: print >> sys.stderr, 'emcc: not optimizing %s despite EMCC_OPTIMIZE_NORMALLY since not source code' % (input_file)
if not specified_target:
for input_file in input_files:
shutil.move(in_temp(unsuffixed(uniquename(input_file)) + '.o'), unsuffixed_basename(input_file) + '.' + final_suffix)
@@ -1053,29 +1126,32 @@ try:
libcxxabi_symbols = filter(lambda symbol: symbol not in libc_symbols, libcxxabi_symbols)
libcxxabi_symbols = set(libcxxabi_symbols)
- force = False # If we have libcxx, we must force inclusion of libc, since libcxx uses new internally. Note: this is kind of hacky
-
+ # If we have libcxx, we must force inclusion of libc, since libcxx uses new internally. Note: this is kind of hacky
+ # Settings this in the environment will avoid checking dependencies and make building big projects a little faster
+ force = os.environ.get('EMCC_FORCE_STDLIBS')
+ has = need = None
for name, create, fix, library_symbols in [('libcxx', create_libcxx, fix_libcxx, libcxx_symbols),
('libcxxabi', create_libcxxabi, fix_libcxxabi, libcxxabi_symbols),
('libc', create_libc, fix_libc, libc_symbols)]:
- need = set()
- has = set()
- for temp_file in temp_files:
- symbols = shared.Building.llvm_nm(temp_file)
- for library_symbol in library_symbols:
- if library_symbol in symbols.undefs:
- need.add(library_symbol)
- if library_symbol in symbols.defs:
- has.add(library_symbol)
- for haz in has: # remove symbols that are supplied by another of the inputs
- if haz in need:
- need.remove(haz)
- if DEBUG: print >> sys.stderr, 'emcc: considering including %s: we need %s and have %s' % (name, str(need), str(has))
+ if not force:
+ need = set()
+ has = set()
+ for temp_file in temp_files:
+ symbols = shared.Building.llvm_nm(temp_file)
+ for library_symbol in library_symbols:
+ if library_symbol in symbols.undefs:
+ need.add(library_symbol)
+ if library_symbol in symbols.defs:
+ has.add(library_symbol)
+ for haz in has: # remove symbols that are supplied by another of the inputs
+ if haz in need:
+ need.remove(haz)
+ if DEBUG: print >> sys.stderr, 'emcc: considering including %s: we need %s and have %s' % (name, str(need), str(has)