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

Wasm source maps #387

Merged
merged 11 commits into from
Oct 1, 2024
Merged

Wasm source maps #387

merged 11 commits into from
Oct 1, 2024

Conversation

mason-lgtm
Copy link
Contributor

@mason-lgtm mason-lgtm commented Aug 30, 2024

Add support for "inlines" and "compileunits" sources for Wasm using source maps.

Adds a new option "--source-map" which can be specified to map a URL to source map file:

--source-map=http://myurl/output.wasm.map=output.wasm.map

The source map URL is found in the Wasm binary in the sourceMappingURL section.

We also support specifying the source map by file name, which is useful for specifying multiple source maps in diff mode where the sourceMappingURL might be identical between the binaries.

--source-map=path/to/output.wasm=output.wasm.map

uint32_t size = ReadVarUInt32(&section.contents);
string_view source_mapping_url =
ReadPiece(size, &section.contents);
id.resize(size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be simpler and safer to write as id.assign(source_mapping_url).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! done

@gkdn
Copy link
Member

gkdn commented Sep 25, 2024

Hi. Wanted to quickly check if there is additional work needed for PR or if it is ready to go?

@@ -2166,6 +2196,8 @@ bool DoParseOptions(bool skip_unknown, int* argc, char** argv[],
}
} else if (args.TryParseOption("--source-filter", &option)) {
options->set_source_filter(std::string(option));
} else if (args.TryParseOption("--source-map", &option)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation for this flag to the usage string and into the user guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - added usage notes to using.md and added the option to the usage string

@@ -0,0 +1,30 @@
# RUN: %yaml2obj %s -o %t.obj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for adding yaml2obj tests. Could we add one for diff mode, so we can test our design for distinguishing between different versions of the same file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think the simplest way to do this would be to make a copy of the Wasm binary generated by yaml2obj, then create 2 different source maps for each of these. Made the change. PTAL

@haberman haberman merged commit e115514 into google:main Oct 1, 2024
7 of 9 checks passed
@mason-lgtm mason-lgtm deleted the wasmsourcemap branch October 1, 2024 22:54
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