From d4a4538af95d24da8e11114fc3ed9f8e65913856 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 24 Aug 2020 07:25:02 -0700 Subject: [PATCH] Don't strip debug info in unoptimized builds without -g (#12016) We used to always run wasm-opt's --strip-debug when -g was not specified, which would strip out DWARF as well as the Name section. This changes us to leave it alone. This has no effect on release builds (-O1+) and no effect on proper debug builds (-O0 -g), but does have an effect on unoptimized builds (-O0) without -g, which may now contain DWARF or the Name section now, depending on how clang and wasm-ld were invoked. Part of reducing unnecessary work after link, and aligning us more with what LLVM tools normally do, see WebAssembly/binaryen#3043 --- ChangeLog.md | 4 ++++ emcc.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ca7589f96dcf..1aefaa012635 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -24,6 +24,10 @@ Current Trunk producer's section in debug builds, you can remove it a tool like `wasm-opt --strip-producers` (which is what Emscripten still does in release builds, as always) or use `llvm-objcopy`. +- Only strip debug info in release builds + when `-g` is not present. Previously + even in an `-O0` build without `-g` we would strip it. This was not documented + behavior, and has no effect on program behavior, but may be noticeable + if you inspect a build output with `-O0`. - Do not remove `__original_main` using `--inline-main`. We used to do this so that it didn't show up in stack traces (which could be confusing because it is added by the linker - it's not in the source code). But this has had diff --git a/emcc.py b/emcc.py index 226fcd6c61aa..9ee4062f244d 100755 --- a/emcc.py +++ b/emcc.py @@ -601,9 +601,9 @@ def backend_binaryen_passes(): # hardcoded value in the binaryen pass) if shared.Settings.OPT_LEVEL > 0 and shared.Settings.GLOBAL_BASE >= 1024: passes += ['--low-memory-unused'] - if shared.Settings.DEBUG_LEVEL < 3: - passes += ['--strip-debug'] if shared.Settings.OPT_LEVEL > 0: + if shared.Settings.DEBUG_LEVEL < 3: + passes += ['--strip-debug'] if not shared.Settings.EMIT_PRODUCERS_SECTION: passes += ['--strip-producers'] if shared.Settings.AUTODEBUG: