aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-10 13:50:43 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-21 10:47:39 -0800
commit7f1fdbef4c074f0a026e5bf3ed01f0339cc8d939 (patch)
treea27478b27955c261d6c48aedc214b6425a2863ae
parent34b153227d5343128cb36931b4dbb27e378372a5 (diff)
be careful with internalize in llvm LTO, and mark needed symbols for relooper
-rwxr-xr-xemcc20
-rw-r--r--tools/shared.py7
2 files changed, 17 insertions, 10 deletions
diff --git a/emcc b/emcc
index 1b86ee9b..8151d7c6 100755
--- a/emcc
+++ b/emcc
@@ -1055,17 +1055,19 @@ try:
if DEBUG: save_intermediate('opt', 'bc')
# Do LTO in a separate pass to work around LLVM bug XXX (see failure e.g. in cubescript)
if shared.Building.can_build_standalone():
- if llvm_lto and shared.Building.can_use_unsafe_opts():
- if not shared.Building.can_inline(): link_opts.append('-disable-inlining')
- link_opts.append('-std-link-opts')
- else:
- # At least remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
- exports = ','.join(map(lambda exp: exp[1:], shared.Settings.EXPORTED_FUNCTIONS))
- link_opts += ['-internalize', '-internalize-public-api-list=' + exports, '-globaldce']
- if link_opts:
+ # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
+ exports = ','.join(map(lambda exp: exp[1:], shared.Settings.EXPORTED_FUNCTIONS))
+ # internalize carefully, llvm 3.2 will remove even main if not told not to
+ link_opts += ['-internalize', '-internalize-public-api-list=' + exports, '-globaldce']
if DEBUG: print >> sys.stderr, 'emcc: LLVM linktime:', link_opts
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts)
- if DEBUG: save_intermediate('linktime', 'bc')
+ if DEBUG: save_intermediate('dce', 'bc')
+ if llvm_lto and shared.Building.can_use_unsafe_opts():
+ if not shared.Building.can_inline(): link_opts.append('-disable-inlining')
+ link_opts = ['-std-link-opts', '-disable-internalize']
+ if DEBUG: print >> sys.stderr, 'emcc: LLVM linktime:', link_opts
+ shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts)
+ if DEBUG: save_intermediate('linktime', 'bc')
# Prepare .ll for Emscripten
if not LEAVE_INPUTS_RAW:
diff --git a/tools/shared.py b/tools/shared.py
index eeffffde..0e219175 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1116,7 +1116,12 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
def make(opt_level):
raw = RELOOPER + '.raw.js'
- Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js', os.path.join('relooper', 'emscripten', 'glue.js'), '-s', 'TOTAL_MEMORY=52428800', '-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=["memcpy", "memset", "malloc", "free", "puts"]', '-O' + str(opt_level), '--closure', '0'], raw)
+ Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js',
+ os.path.join('relooper', 'emscripten', 'glue.js'),
+ '-s', 'TOTAL_MEMORY=52428800',
+ '-s', 'EXPORTED_FUNCTIONS=["_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render"]',
+ '-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=["memcpy", "memset", "malloc", "free", "puts"]',
+ '-O' + str(opt_level), '--closure', '0'], raw)
f = open(RELOOPER, 'w')
f.write("// Relooper, (C) 2012 Alon Zakai, MIT license, https://github.com/kripken/Relooper\n")
f.write("var Relooper = (function() {\n");