Skip to content

Conversation

@alexcrichton
Copy link
Contributor

Oh components retconned the 32-bit version marker, which is 1 for core wasm, as the low 16 bits being core wasm version and the upper 16 bits being a possible component version. That means that the binary here isn't a valid component and needs a few bytes shuffled. The smallest component is:

$ wasm-tools parse <<< "(component)" | xxd 00000000: 0061 736d 0d00 0100 .asm.... 

whereas the test case in this PR is:

$ xxd Downloads/component-error.test.wasm 00000000: 0061 736d 0d00 0000 .asm.... 
@kripken
Copy link
Member Author

kripken commented Jul 16, 2024

Thanks @alexcrichton ! Fixed.

@kripken kripken requested a review from tlively July 16, 2024 23:21
Copy link

@mh4ck-Thales mh4ck-Thales left a comment

Choose a reason for hiding this comment

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

Suggestions for the error string, otherwise LGTM. Tested on my machine and it works.

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.


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

;; CHECK: this looks like a wasm component, which Binaryen does not support yet

Choose a reason for hiding this comment

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

If the string in wasm-binary.cpp is change, adapt the test accordingly.

@kripken kripken merged commit ddf919b into WebAssembly:main Jul 17, 2024
@kripken kripken deleted the component.error branch July 17, 2024 17:48
@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

4 participants