aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc62
1 files changed, 53 insertions, 9 deletions
diff --git a/emcc b/emcc
index fed7e997..2a1a811d 100755
--- a/emcc
+++ b/emcc
@@ -16,7 +16,7 @@ Example uses:
with that command as an argument, for example
emconfigure.py ./configure [options]
-
+
emconfigure.py is a tiny script that just sets some environment vars
as a convenience. The command just shown is equivalent to
@@ -47,7 +47,7 @@ Example uses:
return os.path.join(__rootpath__, *pathelems)
sys.path += [path_from_root('')]
from tools.shared import *
-
+
For using the Emscripten compilers/linkers/etc. you can do:
env = Environment()
...
@@ -441,6 +441,10 @@ Options that are modified or new in %s include:
(also a global property) does not invalidate
everything.
+ Note that you must add -g during the linking
+ stage (bitcode to JS), for jcache to work
+ (otherwise, JS minification can confuse it).
+
--clear-cache Manually clears the cache of compiled
emscripten system libraries (libc++,
libc++abi, libc). This is normally
@@ -557,6 +561,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG:
cmd = [compiler] + list(filter_emscripten_options(sys.argv[1:]))
if not use_js: cmd += shared.EMSDK_OPTS + ['-DEMSCRIPTEN']
+ if use_js: cmd += ['-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] # configure tests should fail when an undefined symbol exists
if DEBUG: print >> sys.stderr, 'emcc, just configuring: ', ' '.join(cmd)
if debug_configure: open(tempout, 'a').write('emcc, just configuring: ' + ' '.join(cmd) + '\n\n')
@@ -720,6 +725,7 @@ try:
jcache = False
save_bc = False
memory_init_file = False
+ use_preload_cache = False
if use_cxx:
default_cxx_std = '-std=c++03' # Enforce a consistent C++ standard when compiling .cpp files, if user does not specify one on the cmdline.
@@ -819,6 +825,9 @@ try:
Compression.on = True
newargs[i] = ''
newargs[i+1] = ''
+ elif newargs[i].startswith('--use-preload-cache'):
+ use_preload_cache = True;
+ newargs[i] = ''
elif newargs[i] == '--ignore-dynamic-linking':
ignore_dynamic_linking = True
newargs[i] = ''
@@ -1010,24 +1019,39 @@ try:
if closure:
print >> sys.stderr, 'emcc: warning: disabling closure because it is not compatible with asm.js code generation'
closure = False
- if shared.Settings.CORRECT_SIGNS != 1:
+ if shared.Settings.CORRECT_SIGNS != 1:
print >> sys.stderr, 'emcc: warning: setting CORRECT_SIGNS to 1 for asm.js code generation'
shared.Settings.CORRECT_SIGNS = 1
- if shared.Settings.CORRECT_OVERFLOWS != 1:
+ if shared.Settings.CORRECT_OVERFLOWS != 1:
print >> sys.stderr, 'emcc: warning: setting CORRECT_OVERFLOWS to 1 for asm.js code generation'
shared.Settings.CORRECT_OVERFLOWS = 1
assert not shared.Settings.PGO, 'cannot run PGO in ASM_JS mode'
if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2:
- keep_llvm_debug = True # must keep debug info to do line-by-line operations
+ keep_llvm_debug = True # must keep debug info to do line-by-line operations
if (keep_llvm_debug or keep_js_debug) and closure:
print >> sys.stderr, 'emcc: warning: disabling closure because debug info was requested'
closure = False
+ if jcache:
+ assert keep_js_debug, 'must run jcache with -g during link stage' # js minification can confuse jcache
+
if minify_whitespace is None:
minify_whitespace = opt_level >= 2 and not keep_js_debug
+ assert shared.LLVM_TARGET in shared.COMPILER_OPTS
+ if shared.LLVM_TARGET == 'i386-pc-linux-gnu':
+ shared.Settings.TARGET_X86 = 1
+ shared.Settings.TARGET_LE32 = 0
+ assert 'le32-unknown-nacl' not in shared.COMPILER_OPTS
+ elif shared.LLVM_TARGET == 'le32-unknown-nacl':
+ shared.Settings.TARGET_LE32 = 1
+ shared.Settings.TARGET_X86 = 0
+ assert 'i386-pc-linux-gnu' not in shared.COMPILER_OPTS
+ else:
+ raise Exception('unknown llvm target: ' + str(shared.LLVM_TARGET))
+
## Compile source code to bitcode
if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode'
@@ -1178,6 +1202,25 @@ try:
def create_libcextra():
if DEBUG: print >> sys.stderr, 'emcc: 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',
+ ]],
['multibyte', [
'btowc.c',
'mblen.c',
@@ -1405,6 +1448,8 @@ try:
file_args += embed_files
if Compression.on:
file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name]
+ if use_preload_cache:
+ file_args.append('--use-preload-cache')
code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
src = open(final).read().replace('// {{PRE_RUN_ADDITIONS}}', '// {{PRE_RUN_ADDITIONS}}\n' + code)
final += '.files.js'
@@ -1510,10 +1555,9 @@ try:
if shared.Settings.USE_TYPED_ARRAYS != 2:
if type(memory_init_file) == int: print >> sys.stderr, 'emcc: warning: memory init file requires typed arrays mode 2'
else:
- memfile = target + '.mem'
- seen_memory_init = False
+ memfile = target + '.mem'
+ shared.try_delete(memfile)
def repl(m):
- seen_memory_init = True
# handle chunking of the memory initializer
s = re.sub('[\[\]\n\(\)\. ]', '', m.groups(0)[0])
s = s.replace('concat', ',')
@@ -1529,7 +1573,7 @@ try:
open(final + '.mem.js', 'w').write(src)
final += '.mem.js'
if DEBUG:
- if seen_memory_init:
+ if os.path.exists(memfile):
save_intermediate('meminit')
print >> sys.stderr, 'emcc: wrote memory initialization to %s' % memfile
else: