-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Debuginfo] Add a JS_DEBUG_LEVEL setting to control the JS debug level #24936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
I'm curious how much usage remains of the (internal) DEBUG_LEVEL setting? Perhaps it can be removed as a followup?
Hmm, good question, but unfortunately I don't think we can remove |
Would it make sense to just support The existing behavior would not need to change. The patch could (it seems) be limited to |
Atm (before this PR) |
@kripken I am currently getting valid source maps combined with fully stripped wasm binaries in Emscripten 4.0.12 using These include source file and line info. This behavior ( |
I tested this change locally with Incidentally, this is an identical size to what I can get with |
Ah, yes, if you separate the compile and link stages then you sort of have some control over different debug levels for LLVM vs JS, as LLVM is already done by the link stage. And some changes to But, if you do LTO then I don't think that approach would work (the debug level would affect compilation, as it happens during link). However, if I'm missing something and you can get LTO and other cases working your way, I'm certainly open to a PR that replaces this one. |
@kripken You are right, I hadn't considered the LTO case. I guess that forces the necessity of a new setting. In that case, I'd like to propose something like I am not personally at liberty to contribute to open source projects due to my employment. |
What do you see the advantage of |
This would enable Binaryen to run its most aggressive minification on the .wasm binary, which to me is half of the problem. |
But |
This is true, but adding This not only disables stripping of debug symbols from the .wasm binary, but also prevents Binaryen from running with its most aggressive optimizations. Some of these, like |
Hmm, I don't think that is an issue. First, metadce depends on the opt level, not debug: Lines 156 to 161 in cab75bc
I added a test now that verifies this. Your worry is reasonable, though, and I looked if any other optimization is disabled by DEBUG_LEVEL, but I can't find any (as the new test confirms). |
You mentioned earlier:
I suspect that is the combination of the sourcemap URL section + the names section. The former is necessary, and the latter is currently emitted with source maps - there is a TODO in the code to consider changing it, but we should do that separately from this PR, and for now it is simple to remove manually using |
You are right on both counts:
I guess this would leave I'll leave it to you then - I'd like to have the convenience, but I understand it may add complexity. |
Does the |
Normally
-g
affects the debug level in LLVM, Binaryen, and JS, but foroptimized builds with source maps we don't want all those to match.
One way to fix that might be a breaking change, to make
-gsource-map
not set
-g
for JS, or to make it only set it for LLVM. However, that wouldbreak many debug workflows in confusing ways, and it seems less
consistent (that a
-gX
flag doesn't see the debug level).This PR proposes that we add a new setting to explicitly control the JS
debug level. It defaults to the
-gX
level, but now e.g.will emit an optimized build, with a source map, and with optimized JS
(since we set the JS debug level to 0, overriding the default
-g3
from-gsource-map
).Fixes #20462
Fixes #24626