-
Notifications
You must be signed in to change notification settings - Fork 776
Save build ID in a source map #6799
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
Conversation
@dschuff I think you have been involved in the build ID discussions? |
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.
For a test, perhaps we can do something like
https://github.com/WebAssembly/binaryen/blob/main/test/lit/debug/source-map-smearing.wast
which has an example of printing out the emitted source map?
src/wasm/wasm-binary.cpp
Outdated
*sourceMap << "\"debugId\":\""; | ||
for (size_t i = pos; i < section.data.size(); i++) { | ||
*sourceMap << std::setfill('0') << std::setw(2) << std::hex | ||
<< +section.data[i]; |
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.
What is the +
achieving here?
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.
that's just a conversion to integer (otherwise it'll print an ASCII representation of this character). However, I've updated it to use an explicit cast to not confuse anybody.
This makes perfect sense to me. The specific behavior of adding the build ID to the source map whenever it exists in the binary also makes sense, but I did notice that https://github.com/tc39/source-map/blob/main/proposals/debug-id.md#scope says that debug IDs are only specified for source maps with embedded source files, which emscripten doesn't support (although I think it would make sense to add that support, see also emscripten-core/emscripten#22189), and the spec "applies only to non-indexed source maps and currently specifies references only for JavaScript." |
15a6d4e
to
36bf9cb
Compare
This is based on the two proposals: * https://github.com/WebAssembly/tool-conventions/blob/main/BuildId.md * https://github.com/tc39/source-map/blob/main/proposals/debug-id.md
36bf9cb
to
9b13dc5
Compare
Great, I was looking for an example but couldn't find, so thanks for sharing. However, I've pushed a precompiled wasm file because WAT parser doesn't seem to support custom sections right now (and it feels a bit out of scope for this change) - I hope that's ok. |
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.
Code and test lgtm. Remaining to discuss is the point @dschuff brought up.
That's one condition, and the other one is
Hi, really sorry for the late reply. I'm not part of TC39 and I'm not aware of any discussions related to WebAssembly other than here WebAssembly/tool-conventions#133. I agree there's opportunity to do better here although I'd keep it separate from this change if possible. |
Ah I was thinking about the case where the sources are "available" but somehow stored separately, in which case you might want to use the build id as an identifier to link them all together separately. Or more generally it just seemed confusing why you would ever want to explicitly say that the build id should be unspecified.
Yeah, definitely keeping it separate from this change is fine. |
This is based on the two proposals: