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-shrink doesn't work as described? #2051

Open
osa1 opened this issue Feb 13, 2025 · 1 comment
Open

wasm-shrink doesn't work as described? #2051

osa1 opened this issue Feb 13, 2025 · 1 comment

Comments

@osa1
Copy link
Contributor

osa1 commented Feb 13, 2025

I'm trying to run wasm-shrink on a 17M .wasm file.

Issues:

  • The interestingness script path works if I pass ./script.sh or absolute path to the script, but script.sh fails with error: Failed to run predicate script 'test.sh'.

  • It seems to ignore -o, it always dumps the shrunk program to stdout, with or without -o.

  • The output is as .wat instead of .wasm, and contains a header like blah.shrunken.wasm :: 17840554 bytes (0.00% smaller).

  • It doesn't seem to shrink: see 0.00% above. I haven't compared the actual output because it's in wat format and my input is .wasm, but it seems like it's generating .wasm as well as .wat, as 0.00% smaller would be the shown amount in .wasm, not in .wat.

    When I enable trace logs I see lines like:

    [2025-02-13T11:23:45Z TRACE] Attempt #423: mutation failed (Error { kind: Parse(BinaryReaderError { inner: BinaryReaderErrorInner { message: "gc proposal not supported", kind: Custom, offset: 15, needed_hint: None } }) })
    

    So that should be the reason why it doesn't shrink.

    But it would be helpful to the user if it failed with this error in a visible way.

I tried with the latest released version of wasm-tools.

@alexcrichton
Copy link
Member

For ./script.sh, did you do chmod +x ./script.sh? For -o looking at the implementation it looks like the directory is mostly used rather than the exact -o so that's something we should fix! Right now the output should include both *.wasm and *.wat so they can be seen side-by-side.

For the actual reduction there's not a lot of gc support just yet. There's some graceful error handling for unsupported proposals as there's varying degrees of support amongst the supported mutations. In that sense it's sort of like how the GC proposal is 1% supported and 99% unsupported and reasonable reduction here probably requires the 99%.

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

No branches or pull requests

2 participants