Skip to content

Commit

Permalink
Error more clearly on wasm components (#6751)
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken authored Jul 17, 2024
1 parent 9cee7d0 commit ddf919b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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 "
"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.

0 comments on commit ddf919b

Please sign in to comment.