From 764e81bd041395d4e3bd78c9c53b0676e34ef377 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 30 Jan 2012 10:41:55 -0800 Subject: do not do -Ox or LTO when building a linkable module --- emcc | 7 ++++--- tools/shared.py | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/emcc b/emcc index ae08c516..ef5aae44 100755 --- a/emcc +++ b/emcc @@ -565,9 +565,10 @@ try: shared.Building.llvm_opt(in_temp(target_basename + '.bc'), LLVM_OPT_LEVEL[opt_level]) 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 DEBUG: print >> sys.stderr, 'emcc: LLVM LTO' - shared.Building.llvm_opt(in_temp(target_basename + '.bc'), ['-disable-inlining', '-std-link-opts']) - if DEBUG: save_intermediate('lto', 'bc') + if not shared.Settings.BUILD_AS_SHARED_LIB and not shared.Settings.LINKABLE: + if DEBUG: print >> sys.stderr, 'emcc: LLVM LTO' + shared.Building.llvm_opt(in_temp(target_basename + '.bc'), ['-disable-inlining', '-std-link-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 not shared.Settings.BUILD_AS_SHARED_LIB and not shared.Settings.LINKABLE: diff --git a/tools/shared.py b/tools/shared.py index e43ac8ab..2b87aaf4 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -540,13 +540,17 @@ class Building: llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments ''' assert 0 <= optimization_level <= 3 - safe = Settings.USE_TYPED_ARRAYS != 2 or Settings.BUILD_AS_SHARED_LIB or Settings.LINKABLE + safe = Settings.USE_TYPED_ARRAYS != 2 opts = [] if optimization_level > 0: if not safe: opts.append('-disable-inlining') # we prefer to let closure compiler do our inlining, to avoid overly aggressive inlining - opts.append('-O%d' % optimization_level) - #opts.append('-std-compile-opts') + # -Ox opts do -globaldce, which removes stuff that is needed for libraries and linkables + if not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE: + opts.append('-O%d' % optimization_level) + else: + opts.append('-std-compile-opts') + print '[unsafe: %s]' % ','.join(opts) else: allow_nonportable = not safe optimize_size = True -- cgit v1.2.3-18-g5258