kripken/emscripten — Issue #223: How to turn off remove dead function feature
Author: harykary
Created: 2012-02-08 02:13:33+00:00
State: open

Hi everyone,
I'm working on kripken-emscripten-78a230a version, and it remove all the function that is not called in the chain of calls from main(). I've read and found in the folowing code in emcc file:
......
# Optimize, if asked to
if llvm_opts > 0 and not LEAVE_INPUTS_RAW:
if DEBUG: print >> sys.stderr, 'emcc: LLVM -O%d' % llvm_opts
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), llvm_opts)
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_use_unsafe_opts() and shared.Building.can_build_standalone():
lto_opts = []
if not shared.Building.can_inline(): lto_opts.append('-disable-inlining')
lto_opts.append('-std-link-opts')
if DEBUG: print >> sys.stderr, 'emcc: LLVM LTO:', lto_opts
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), lto_opts)
if DEBUG: save_intermediate('lto', 'bc')
else:
# If possible, remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
if not LEAVE_INPUTS_RAW and shared.Building.can_build_standalone():
if DEBUG: print >> sys.stderr, 'emcc: LLVM dead globals elimination'
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), ['-internalize', '-globaldce'])
if DEBUG: save_intermediate('dce', 'bc')
....
I build with default option (emcc test.cpp), that mean no optimize option, but It still remove my dead function.
I want to keep dead function, please show me how to do.
Thanks