bytecodealliance / bytecodealliance/wasm-tools

wasm-shrink doesn't work as described?

Open
#2,051 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.8k
Forks
351
Avg merge
16h 57m
Merged PRs (30d)
38

Description

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`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.