diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-01 10:37:40 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-01 10:37:40 -0800 |
commit | fe6518c8daaac34f8c40167b00f3cd7be7df2d62 (patch) | |
tree | 2e9b0b235a914bd1a99a30609f1e70c75f217d1f | |
parent | 1204c42f4f7f5b5658fce74e0e29e0f09ca44029 (diff) |
refactor build checks for standalone and unsafe opts
-rwxr-xr-x | emcc | 4 | ||||
-rw-r--r-- | tools/shared.py | 22 |
2 files changed, 17 insertions, 9 deletions
@@ -568,13 +568,13 @@ try: 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 not shared.Settings.BUILD_AS_SHARED_LIB and not shared.Settings.LINKABLE: + if shared.Building.can_use_unsafe_opts() and shared.Building.can_build_standalone(): 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: + 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') diff --git a/tools/shared.py b/tools/shared.py index 2436c02d..d1fbf878 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -531,6 +531,14 @@ class Building: return filename + '.o.js' @staticmethod + def can_build_standalone(): + return not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE + + @staticmethod + def can_use_unsafe_opts(): + return Settings.USE_TYPED_ARRAYS == 2 + + @staticmethod def pick_llvm_opts(optimization_level): ''' It may be safe to use nonportable optimizations (like -OX) if we remove the platform info from the .ll @@ -543,28 +551,28 @@ 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 + unsafe = Building.can_use_unsafe_opts() opts = [] if optimization_level > 0: - if not safe: + if unsafe: opts.append('-disable-inlining') # we prefer to let closure compiler do our inlining, to avoid overly aggressive inlining # -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: + if Building.can_build_standalone(): opts.append('-O%d' % optimization_level) else: opts.append('-std-compile-opts') #print '[unsafe: %s]' % ','.join(opts) else: - allow_nonportable = not safe + allow_nonportable = False optimize_size = True - use_aa = not safe + use_aa = False # PassManagerBuilder::populateModulePassManager if allow_nonportable and use_aa: # ammo.js results indicate this can be nonportable opts.append('-tbaa') opts.append('-basicaa') # makes fannkuch slow but primes fast - if not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE: + if Building.can_build_standalone(): opts.append('-internalize') opts.append('-globalopt') @@ -624,7 +632,7 @@ class Building: opts.append('-strip-dead-prototypes') - if not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE: + if Building.can_build_standalone(): opts.append('-globaldce') if optimization_level > 1: opts.append('-constmerge') |