Skip to content

Commit 9b15472

Browse files
authored
Warn on DWARF limiting opts only when DWARF is in use. Fixes #16722 (#16727)
We warned in too many cases. If DWARF is not used, do not warn.
1 parent 9cd026c commit 9b15472

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

emcc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,8 +3332,10 @@ def phase_binaryen(target, options, wasm_target):
33323332
# the only reason we need intermediate debug info, we can stop keeping it
33333333
if settings.ASYNCIFY:
33343334
intermediate_debug_info -= 1
3335-
if intermediate_debug_info and should_run_binaryen_optimizer():
3336-
# See https://github.com/emscripten-core/emscripten/issues/15269
3335+
# currently binaryen's DWARF support will limit some optimizations; warn on
3336+
# that. see https://github.com/emscripten-core/emscripten/issues/15269
3337+
dwarf_info = settings.DEBUG_LEVEL >= 3
3338+
if dwarf_info:
33373339
diagnostics.warning('limited-postlink-optimizations', 'running limited binaryen optimizations because DWARF info requested (or indirectly required)')
33383340
building.run_wasm_opt(wasm_target,
33393341
wasm_target,

tests/test_other.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11904,14 +11904,26 @@ def test_shared_memory_preprocessor_flags(self):
1190411904
def test_wasm_worker_preprocessor_flags(self):
1190511905
self.run_process([EMCC, '-c', test_file('wasm_worker/wasm_worker_preprocessor_flags.c'), '-sWASM_WORKERS'])
1190611906

11907+
@parameterized({
11908+
# we will warn here since -O2 runs the optimizer and -g enables DWARF
11909+
'O2_g': (True, ['-O2', '-g'],),
11910+
# asyncify will force wasm-opt to run as well, so we warn here too
11911+
'asyncify_g': (True, ['-sASYNCIFY', '-g'],),
11912+
# with --profiling-funcs however we do not use DWARF (we just emit the
11913+
# names section) and will not warn.
11914+
'O2_pfuncs': (False, ['-O2', '--profiling-funcs'],),
11915+
})
11916+
def test_debug_opt_warning(self, should_fail, args):
11917+
if should_fail:
11918+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror'] + args)
11919+
self.assertContained('error: running limited binaryen optimizations because DWARF info requested (or indirectly required) [-Wlimited-postlink-optimizations]', err)
11920+
else:
11921+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror'] + args)
11922+
1190711923
@also_with_minimal_runtime
1190811924
def test_wasm_worker_closure(self):
1190911925
self.run_process([EMCC, test_file('wasm_worker/lock_async_acquire.c'), '-O2', '-sWASM_WORKERS', '--closure=1'])
1191011926

11911-
def test_debug_opt_warning(self):
11912-
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-O2', '-g', '-Werror'])
11913-
self.assertContained('error: running limited binaryen optimizations because DWARF info requested (or indirectly required) [-Wlimited-postlink-optimizations]', err)
11914-
1191511927
def test_clock_nanosleep(self):
1191611928
self.do_runf(test_file('other/test_clock_nanosleep.c'))
1191711929

0 commit comments

Comments
 (0)