diff options
Diffstat (limited to 'tools/shared.py')
-rw-r--r-- | tools/shared.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/shared.py b/tools/shared.py index 3e989844..1f184de7 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -412,10 +412,10 @@ class Building: for k, v in env_init.iteritems(): env[k] = v if configure: # Useful in debugging sometimes to comment this out (and the lines below up to and including the |link| call) - Building.configure(configure + configure_args, stdout=open(os.path.join(output_dir, 'configure_'), 'w'), - stderr=open(os.path.join(output_dir, 'configure_err'), 'w'), env=env) - Building.make(make + make_args, stdout=open(os.path.join(output_dir, 'make_'), 'w'), - stderr=open(os.path.join(output_dir, 'make_err'), 'w'), env=env) + Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'), + stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env) + Building.make(make + make_args, stdout=open(os.path.join(project_dir, 'make_'), 'w'), + stderr=open(os.path.join(project_dir, 'make_err'), 'w'), env=env) bc_file = os.path.join(project_dir, 'bc.bc') Building.link(generated_libs, bc_file) if cache is not None: @@ -443,9 +443,9 @@ class Building: # @param opt Either an integer, in which case it is the optimization level (-O1, -O2, etc.), or a list of raw # optimization passes passed to llvm opt @staticmethod - def llvm_opt(filename, opts, safe=True): + def llvm_opt(filename, opts): if type(opts) is int: - opts = Building.pick_llvm_opts(opts, safe) + opts = Building.pick_llvm_opts(opts) output = Popen([LLVM_OPT, filename] + opts + ['-o=' + filename + '.opt.bc'], stdout=PIPE).communicate()[0] assert os.path.exists(filename + '.opt.bc'), 'Failed to run llvm optimizations: ' + output shutil.move(filename + '.opt.bc', filename) @@ -531,7 +531,7 @@ class Building: return filename + '.o.js' @staticmethod - def pick_llvm_opts(optimization_level, safe=True): + 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 (which we do in do_ll_opts) - but even there we have issues (even in TA2) with instruction combining @@ -542,14 +542,18 @@ 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 opts = [] if optimization_level > 0: - #opts.append('-disable-inlining') # we prefer to let closure compiler do our inlining if not safe: - #opts.append('-O%d' % optimization_level) - opts.append('-std-compile-opts') - opts.append('-std-link-opts') - print 'Unsafe:', opts, + 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: + 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 |