aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc61
1 files changed, 42 insertions, 19 deletions
diff --git a/emcc b/emcc
index 895aab87..a5b30b97 100755
--- a/emcc
+++ b/emcc
@@ -53,6 +53,15 @@ from tools import shared, jsrun
from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename
from tools.response_file import read_response_file
+CXX_SUFFIXES = ('.cpp', '.cxx', '.cc')
+SOURCE_SUFFIXES = ('.c', '.cpp', '.cxx', '.cc', '.m', '.mm')
+BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
+DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
+STATICLIB_SUFFIXES = ('.a',)
+ASSEMBLY_SUFFIXES = ('.ll',)
+LIB_PREFIXES = ('', 'lib')
+JS_CONTAINING_SUFFIXES = ('js', 'html')
+
# Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
# levels 2 and 3 (emcc 3 is unsafe opts, so unsuitable for the only level to get
# llvm opt level 3, and speed-wise emcc level 2 is already the slowest/most optimizing
@@ -302,6 +311,9 @@ Options that are modified or new in %s include:
your main compiled code (or run it before in
some other way).
+ For more docs on the options --preload-file
+ accepts, see https://github.com/kripken/emscripten/wiki/Filesystem-Guide
+
--compression <codec> Compress both the compiled code and embedded/
preloaded files. <codec> should be a triple,
@@ -529,7 +541,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG:
if debug_configure: open(tempout, 'a').write('============= ' + arg + '\n' + src + '\n=============\n\n')
except:
pass
- if arg.endswith('.s'):
+ elif arg.endswith('.s'):
if debug_configure: open(tempout, 'a').write('(compiling .s assembly, must use clang\n')
use_js = 0
@@ -612,15 +624,6 @@ if EMMAKEN_CFLAGS: CC_ADDITIONAL_ARGS += shlex.split(EMMAKEN_CFLAGS)
# ---------------- Utilities ---------------
-SOURCE_SUFFIXES = ('.c', '.cpp', '.cxx', '.cc', '.m', '.mm')
-BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
-DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
-STATICLIB_SUFFIXES = ('.a',)
-ASSEMBLY_SUFFIXES = ('.ll',)
-LIB_PREFIXES = ('', 'lib')
-
-JS_CONTAINING_SUFFIXES = ('js', 'html')
-
seen_names = {}
def uniquename(name):
if name not in seen_names:
@@ -784,6 +787,7 @@ try:
newargs[i+1] = ''
elif newargs[i].startswith('--minify'):
check_bad_eq(newargs[i])
+ assert newargs[i+1] == '0', '0 is the only supported option for --minify; 1 has been deprecated'
debug_level = max(1, debug_level)
newargs[i] = ''
newargs[i+1] = ''
@@ -1007,7 +1011,7 @@ try:
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_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + STATICLIB_SUFFIXES + ASSEMBLY_SUFFIXES))
exit(0)
- newargs += CC_ADDITIONAL_ARGS
+ newargs = CC_ADDITIONAL_ARGS + newargs
assert not (Compression.on and final_suffix != 'html'), 'Compression only works when generating HTML'
@@ -1027,6 +1031,10 @@ try:
exec('shared.Settings.' + key + ' = ' + value)
# Apply effects from settings
+ if bind and shared.Settings.ASM_JS:
+ logging.warning('disabling asm.js since embind is not ready for it yet')
+ shared.Settings.ASM_JS = 0
+
if shared.Settings.ASM_JS:
assert opt_level >= 1, 'asm.js requires -O1 or above'
@@ -1046,7 +1054,7 @@ try:
if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2:
debug_level = 4 # must keep debug info to do line-by-line operations
- if debug_level > 0 and closure:
+ if debug_level > 1 and closure:
logging.warning('disabling closure because debug info was requested')
closure = False
@@ -1080,6 +1088,10 @@ try:
if shared.Settings.DLOPEN_SUPPORT:
shared.Settings.LINKABLE = 1
+ if shared.Settings.STB_IMAGE and final_suffix in JS_CONTAINING_SUFFIXES:
+ input_files.append(shared.path_from_root('third_party', 'stb_image.c'))
+ shared.Settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free']
+
## Compile source code to bitcode
logging.debug('compiling to bitcode')
@@ -1094,6 +1106,8 @@ try:
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
temp_files.append(output_file)
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
+ if input_file.endswith(CXX_SUFFIXES):
+ args += shared.EMSDK_CXX_OPTS
logging.debug("running:" + call + ' ' + ' '.join(args))
execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
if not os.path.exists(output_file):
@@ -1271,6 +1285,11 @@ try:
'wctob.c',
'wctomb.c',
]],
+ ['stdlib', [
+ 'ecvt.c',
+ 'fcvt.c',
+ 'gcvt.c',
+ ]],
['string', [
'wcpcpy.c',
'wcpncpy.c',
@@ -1538,14 +1557,17 @@ try:
# It is useful to run several js optimizer passes together, to save on unneeded unparsing/reparsing
js_optimizer_queue = []
+ js_optimizer_extra_info = {}
def flush_js_optimizer_queue():
- global final, js_optimizer_queue
+ global final, js_optimizer_queue, js_optimizer_extra_info
+ if len(js_optimizer_extra_info) == 0:
+ js_optimizer_extra_info = None
if len(js_optimizer_queue) > 0 and not(len(js_optimizer_queue) == 1 and js_optimizer_queue[0] == 'last'):
if DEBUG != '2':
if shared.Settings.ASM_JS:
js_optimizer_queue = ['asm'] + js_optimizer_queue
logging.debug('applying js optimization passes: %s', js_optimizer_queue)
- final = shared.Building.js_optimizer(final, js_optimizer_queue, jcache, debug_level >= 4)
+ final = shared.Building.js_optimizer(final, js_optimizer_queue, jcache, debug_level >= 4, js_optimizer_extra_info)
js_transform_tempfiles.append(final)
if DEBUG: save_intermediate('js_opts')
else:
@@ -1554,10 +1576,11 @@ try:
if shared.Settings.ASM_JS:
passes = ['asm'] + passes
logging.debug('applying js optimization pass: %s', passes)
- final = shared.Building.js_optimizer(final, passes, jcache, debug_level >= 4)
+ final = shared.Building.js_optimizer(final, passes, jcache, debug_level >= 4, js_optimizer_extra_info)
js_transform_tempfiles.append(final)
save_intermediate(name)
js_optimizer_queue = []
+ js_optimizer_extra_info = {}
if opt_level >= 1:
logging.debug('running pre-closure post-opts')
@@ -1574,7 +1597,7 @@ try:
else:
return 'eliminate'
- js_optimizer_queue += [get_eliminate(), 'simplifyExpressionsPre']
+ js_optimizer_queue += [get_eliminate(), 'simplifyExpressions']
if shared.Settings.RELOOP and not shared.Settings.ASM_JS:
js_optimizer_queue += ['optimizeShiftsAggressive', get_eliminate()] # aggressive shifts optimization requires loops, it breaks on switches
@@ -1588,9 +1611,9 @@ try:
final = shared.Building.closure_compiler(final)
if DEBUG: save_intermediate('closure')
- if opt_level >= 1:
- logging.debug('running post-closure post-opts')
- js_optimizer_queue += ['simplifyExpressionsPost']
+ if shared.Settings.OUTLINING_LIMIT > 0:
+ js_optimizer_queue += ['outline']
+ js_optimizer_extra_info['sizeToOutline'] = shared.Settings.OUTLINING_LIMIT
if (not closure or shared.Settings.ASM_JS) and shared.Settings.RELOOP and debug_level < 3:
js_optimizer_queue += ['registerize']