diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-07 10:32:54 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-07 10:32:54 -0800 |
commit | 466af17eb971e780f83d663f0d424bf71064b3d3 (patch) | |
tree | 50b4e9bc6d7555a2feff88d775a39996b079b004 | |
parent | 4a6e77e0486e06479d9700a7e2f768e3fd7162e6 (diff) |
strip debug info in -O1 and above by default, unless -g is specified when converting to JS, since (1) js optimizations strip it anyhow, and (2) it slows down compilation
-rwxr-xr-x | emcc | 32 | ||||
-rwxr-xr-x | tests/runner.py | 3 |
2 files changed, 24 insertions, 11 deletions
@@ -173,6 +173,11 @@ Options that are modified or new in %s include: (without the external "s in either of those, you would get an error) + -g Use debug info. Note that you need this during + the last compilation phase from bitcode to + JavaScript, or else we will remove it by + default in -O1 and above. + --typed-arrays <mode> 0: No typed arrays 1: Parallel typed arrays 2: Shared (C-like) typed arrays (default) @@ -461,7 +466,7 @@ CC = shared.to_cc(CXX) if os.environ.get('EMMAKEN_CXX'): CC = CXX -CC_ADDITIONAL_ARGS = shared.COMPILER_OPTS # + ['-g']? +CC_ADDITIONAL_ARGS = shared.COMPILER_OPTS EMMAKEN_CFLAGS = os.environ.get('EMMAKEN_CFLAGS') if EMMAKEN_CFLAGS: CC_ADDITIONAL_ARGS += shlex.split(EMMAKEN_CFLAGS) @@ -564,6 +569,7 @@ try: shell_path = shared.path_from_root('src', 'shell.html') js_libraries = [] remove_duplicates = False + keep_debug = False bind = False def check_bad_eq(arg): @@ -622,7 +628,9 @@ try: check_bad_eq(newargs[i]) split_js_file = int(newargs[i+1]) newargs[i] = '' - newargs[i+1] = '' + newargs[i+1] = '' + elif newargs[i] == '-g': + keep_debug = True elif newargs[i] == '--bind': bind = True newargs[i] = '-std=c++11' # Force C++11 for embind code @@ -683,6 +691,7 @@ try: if closure is None: closure = 1 if opt_level >= 2 else 0 if minify_whitespace is None: minify_whitespace = closure # if closure is run, minify whitespace + if opt_level <= 0: keep_debug = True # always keep debug in -O0 if closure: assert os.path.exists(shared.CLOSURE_COMPILER), 'emcc: fatal: Closure compiler (%s) does not exist' % shared.CLOSURE_COMPILER @@ -810,6 +819,10 @@ try: key, value = change.split('=') exec('shared.Settings.' + key + ' = ' + value) + # Apply effects from settings + if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2: + keep_debug = True # must keep debug info to do line-by-line operations + ## Compile source code to bitcode if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode' @@ -994,23 +1007,24 @@ try: if not LEAVE_INPUTS_RAW: save_intermediate('basebc', 'bc') # Optimize, if asked to + link_opts = [] if keep_debug else ['-strip-debug'] 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 llvm_lto and 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 not shared.Building.can_inline(): link_opts.append('-disable-inlining') + link_opts.append('-std-link-opts') + if DEBUG: print >> sys.stderr, 'emcc: LLVM LTO:', link_opts + shared.Building.llvm_opt(in_temp(target_basename + '.bc'), 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 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']) + link_opts += ['-internalize', '-globaldce'] + if DEBUG: print >> sys.stderr, 'emcc: LLVM dead code elimination:', link_opts + shared.Building.llvm_opt(in_temp(target_basename + '.bc'), link_opts) if DEBUG: save_intermediate('dce', 'bc') # Prepare .ll for Emscripten diff --git a/tests/runner.py b/tests/runner.py index a5d5045a..456b5bf5 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5755,8 +5755,7 @@ void*:16 def get_freetype(self): Settings.INIT_STACK = 1 # TODO: Investigate why this is necessary return self.get_library('freetype', - os.path.join('objs', '.libs', 'libfreetype.a'), - cache_name_extra='' if self.emcc_args is None or '-O2' not in self.emcc_args else '_opt') + os.path.join('objs', '.libs', 'libfreetype.a')) def test_freetype(self): if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix') |