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

Error more clearly on wasm components #6751

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,15 @@ void WasmBinaryReader::verifyInt64(int64_t x) {
void WasmBinaryReader::readHeader() {
BYN_TRACE("== readHeader\n");
verifyInt32(BinaryConsts::Magic);
verifyInt32(BinaryConsts::Version);
auto version = getInt32();
if (version != BinaryConsts::Version) {
if (version == 0x1000d) {
throwError("this looks like a wasm component, which Binaryen does not "

Choose a reason for hiding this comment

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

We can change wasm to Wasm in the error string, and it could be nice to give a link to #6728. It allows people to follow the progress and maybe help if they're interested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, I added a link now.

We use lowercase wasm which is more informal in our other error strings, so for consistency I didn't change that. Though I agree in proper English it should be capitalized.

"support yet (see "
"https://github.com/WebAssembly/binaryen/issues/6728)");
}
throwError("invalid version");
}
}

void WasmBinaryReader::readStart() {
Expand Down
6 changes: 6 additions & 0 deletions test/lit/binary/component-error.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Verify that we show an error when given a component.

;; RUN: not wasm-opt %s.wasm 2>&1 | filecheck %s

;; CHECK: this looks like a wasm component, which Binaryen does not support yet (see https://github.com/WebAssembly/binaryen/issues/6728)

Binary file added test/lit/binary/component-error.test.wasm
Binary file not shown.
Loading