Skip to content
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

Save build ID in a source map #6799

Merged
merged 1 commit into from
Aug 15, 2024
Merged

Conversation

loganek
Copy link
Contributor

@loganek loganek commented Aug 1, 2024

@kripken
Copy link
Member

kripken commented Aug 1, 2024

@dschuff I think you have been involved in the build ID discussions?

@loganek
Copy link
Contributor Author

loganek commented Aug 5, 2024

@kripken / @dschuff do you have any thoughts on that?

Copy link
Member

@kripken kripken left a 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?

*sourceMap << "\"debugId\":\"";
for (size_t i = pos; i < section.data.size(); i++) {
*sourceMap << std::setfill('0') << std::setw(2) << std::hex
<< +section.data[i];
Copy link
Member

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?

Copy link
Contributor Author

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.

@dschuff
Copy link
Member

dschuff commented Aug 8, 2024

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."
I assume that limitation is only in place because it also needs to specify the behavior of the proposed JS APIs (which would in turn require some spec to understand how to get a build ID from a wasm file analogous to how it's speced for JS. I assume it would be harmless to just include the build ID here anyway; but maybe we can do even better. Do you know if there have been any discussions in TC39 here about how this might apply to wasm?

@loganek
Copy link
Contributor Author

loganek commented Aug 8, 2024

For a test, perhaps we can do something like

main/test/lit/debug/source-map-smearing.wast

which has an example of printing out the emitted source map?

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.

Copy link
Member

@kripken kripken left a 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.

@loganek
Copy link
Contributor Author

loganek commented Aug 13, 2024

says that debug IDs are only specified for source maps with embedded source files

That's one condition, and the other one is where sources are categorically not available which I think applies here because (at least for now) WASM doesn't specify how the source code can be included in WASM file itself.

Do you know if there have been any discussions in TC39 here about how this might apply to wasm?

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.

@dschuff
Copy link
Member

dschuff commented Aug 14, 2024

says that debug IDs are only specified for source maps with embedded source files

That's one condition, and the other one is where sources are categorically not available which I think applies here because (at least for now) WASM doesn't specify how the source code can be included in WASM file itself.

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.

Do you know if there have been any discussions in TC39 here about how this might apply to wasm?

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.

Yeah, definitely keeping it separate from this change is fine.

@kripken kripken merged commit ad08022 into WebAssembly:main Aug 15, 2024
13 checks passed
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants