aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc42
1 files changed, 40 insertions, 2 deletions
diff --git a/emcc b/emcc
index ba67f082..3cd049d8 100755
--- a/emcc
+++ b/emcc
@@ -503,6 +503,17 @@ Options that are modified or new in %s include:
--proxy-to-worker Generates both html and js files. The main
program is in js, and the html proxies to/from it.
+ --emrun Enables the generated output to be aware of the
+ emrun command line tool. This allows stdout, stderr
+ and exit(returncode) capture when running the
+ generated application through emrun.
+
+ --em-config Specifies the location of the .emscripten configuration
+ file for the current compiler run. If not specified,
+ the environment variable EM_CONFIG is read for this
+ file, and if that is not set, the default location
+ ~/.emscripten is assumed.
+
The target file, if specified (-o <target>), defines what will
be generated:
@@ -779,6 +790,7 @@ try:
shell_path = shared.path_from_root('src', 'shell.html')
js_libraries = []
bind = False
+ emrun = False
jcache = False
save_bc = False
memory_init_file = False
@@ -973,12 +985,24 @@ try:
if not absolute_warning_shown and os.path.isabs(path_name):
logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
absolute_warning_shown = True
+ elif newargs[i] == '--emrun':
+ emrun = True
+ newargs[i] = ''
+ elif newargs[i] == '--em-config':
+ # This option is parsed in tools/shared.py, here only clean it up from being passed to clang.
+ newargs[i] = ''
+ newargs[i+1] = ''
+
newargs = [ arg for arg in newargs if arg is not '' ]
# If user did not specify a default -std for C++ code, specify the emscripten default.
if default_cxx_std:
newargs = newargs + [default_cxx_std]
+ if emrun:
+ pre_js += open(shared.path_from_root('src', 'emrun_prejs.js')).read() + '\n'
+ post_js += open(shared.path_from_root('src', 'emrun_postjs.js')).read() + '\n'
+
if js_opts is None: js_opts = opt_level >= 2
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None and opt_level >= 3: llvm_lto = 3
@@ -1138,8 +1162,11 @@ try:
logging.warning('disabling asm.js since embind is not ready for it yet')
shared.Settings.ASM_JS = 0
+ if os.environ.get('EMCC_FAST_COMPILER'):
+ shared.Settings.ASM_JS = 1
+
if shared.Settings.ASM_JS:
- assert opt_level >= 1, 'asm.js requires -O1 or above'
+ assert opt_level >= 1 or os.environ.get('EMCC_FAST_COMPILER'), 'asm.js requires -O1 or above'
if bind:
shared.Settings.RESERVED_FUNCTION_POINTERS = max(shared.Settings.RESERVED_FUNCTION_POINTERS, 10)
@@ -1666,7 +1693,12 @@ try:
else:
# At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
link_opts += shared.Building.get_safe_internalize() + ['-globaldce']
- if not save_bc:
+
+ # Simplify LLVM bitcode for fastcomp
+ if os.environ.get('EMCC_FAST_COMPILER') and not AUTODEBUG:
+ link_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
+
+ if (not save_bc and not os.environ.get('EMCC_FAST_COMPILER')) or AUTODEBUG:
# let llvm opt directly emit ll, to skip writing and reading all the bitcode
link_opts += ['-S']
shared.Building.llvm_opt(final, link_opts, final + '.link.ll')
@@ -1693,6 +1725,12 @@ try:
final += '.ad.ll'
if DEBUG: save_intermediate('autodebug', 'll')
+ # Simplify bitcode after autodebug
+ if os.environ.get('EMCC_FAST_COMPILER') and AUTODEBUG:
+ shared.Building.llvm_opt(final, ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'], final + '.adsimp.bc')
+ final += '.adsimp.bc'
+ if DEBUG: save_intermediate('adsimp', 'bc')
+
# Emscripten
logging.debug('LLVM => JS')
extra_args = [] if not js_libraries else ['--libraries', ','.join(map(os.path.abspath, js_libraries))]