-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fix bug with empty Wasm file when using system binaryen for optimization #179
Conversation
|
||
let mut optimized_wasm_file = File::create(optimized.as_os_str())?; | ||
optimized_wasm_file.write_all(&optimized_wasm)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the bug: the optimized Wasm file was created here and the returned bytes from do_optimization
written into it.
But:
-
This was only necessary for the
do_optimization
function enabled withfeature = "binaryen-as-dependency"
. -
For the
do_optimization
function enabled withnot(feature = "binaryen-as-dependency")
thewasm-opt
cli was already invoked with-o optimized-wasm-file
‒ thus already creating the file.
Consequently the returned bytes from the function were always empty. I first tried to fix this bug by havingwasm-opt
return a raw bytestream, but found a bug inwasm-opt
which currently prevents this: wasm-opt fails when-o
is omitted, instead of writing to stdout as fallback WebAssembly/binaryen#3579.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would also make sense to invoke our tests with --features=binaryen-as-dependency
as well as without.
337bec1
to
ab7468f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. As you suggest we should add a CI test run with binaryen-as-dependency
enabled.
@ascjones The regression which you found is unfortunately a bug which was introduced when making the
binaryen
dependency opt-in.I've added a number of asserts now and fixed it.