aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc2
-rwxr-xr-xtests/runner.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/emcc b/emcc
index 63ce1d88..1a4dc470 100755
--- a/emcc
+++ b/emcc
@@ -1104,7 +1104,7 @@ try:
# Optimize, if asked to
if not LEAVE_INPUTS_RAW:
- link_opts = [] if keep_debug else ['-strip-debug']
+ link_opts = [] if keep_debug and opt_level == 0 else ['-strip-debug'] # remove LLVM debug info in -O1+, since the optimizer removes it anyhow
if llvm_opts > 0:
shared.Building.llvm_opt(in_temp(target_basename + '.bc'), llvm_opts)
if DEBUG: save_intermediate('opt', 'bc')
diff --git a/tests/runner.py b/tests/runner.py
index 92f31aa8..9fe944dd 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -9289,6 +9289,26 @@ f.close()
finally:
del os.environ['EMCC_DEBUG']
+ def test_debuginfo(self):
+ if os.environ.get('EMCC_DEBUG'): return self.skip('cannot run in debug mode')
+ try:
+ os.environ['EMCC_DEBUG'] = '1'
+ # llvm debug info is kept only when we can see it, which is without the js optimize, -O0. js debug info is lost by registerize in -O2, so - g disables it
+ for args, expect_llvm, expect_js in [
+ (['-O0'], True, True),
+ (['-O0', '-g'], True, True),
+ (['-O1'], False, True),
+ (['-O1', '-g'], False, True),
+ (['-O2'], False, False),
+ (['-O2', '-g'], False, True),
+ ]:
+ print args, expect_llvm, expect_js
+ output, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp')] + args, stdout=PIPE, stderr=PIPE).communicate()
+ assert expect_llvm == ('strip-debug' not in err)
+ assert expect_js == ('registerize' not in err)
+ finally:
+ del os.environ['EMCC_DEBUG']
+
def test_scons(self): # also incidentally tests c++11 integration in llvm 3.1
try_delete(os.path.join(self.get_dir(), 'test'))
shutil.copytree(path_from_root('tests', 'scons'), os.path.join(self.get_dir(), 'test'))