Conversation
| let fp16_dir = binaryen_dir.join("third_party/FP16/include"); | ||
| CFG.exported_header_dirs.push(&fp16_dir); |
There was a problem hiding this comment.
This is needed to compile. Not sure if I should move this up a few lines so it's next to where src, tools, and output are added to the exports.
There was a problem hiding this comment.
I made it so all of the cpp files from binaryen are added in the build, but I'm not sure if every single one is needed.
| } | ||
|
|
||
| // FIXME binaryen unicode path handling is broken on windows | ||
| // TODO: How do I fix this? |
There was a problem hiding this comment.
I saw a comment on the issue about issues with Windows paths saying this is fixed in binaryen now, but I'm not sure if any more work is needed here or if this repo gets it "for free".
| @@ -1,3 +1,5 @@ | |||
| #![allow(clippy::new_without_default)] | |||
There was a problem hiding this comment.
I figured this warning would be more annoying than helpful since the new method on the types it was complaining about don't take args.
| /// Outline instructions. | ||
| /// TODO: This is gated behind conditional compilation in the CPP. | ||
| /// Need to figure out how to handle that on the rust end. | ||
| Outlining, |
There was a problem hiding this comment.
As stated in the TODO, this is gated behind conditional compilation in the C++ code and I'm not sure how to handle that on the Rust end. Would that just be adding a new feature and gating this enum variant behind a cfg attribute?
|
|
||
| // TODO: Figure out how to fix, or if this is still even needed | ||
| #[test] | ||
| fn optimization_read_module_error_works() -> anyhow::Result<()> { |
There was a problem hiding this comment.
The result being tested in the assert no longer errors. I don't know if this is because I made a mistake doing the upgrade, or if it's due to a change in the unerlying C++ code in the new version.
Comparing PassRunner::run between version_116 and version_121, there is only one difference: the former does an assert at the start of the function and the latter doesn't.
|
Thanks a lot for this work @SleeplessOne1917 - here's hoping we can get this merged. |
|
I see that a test failed during the CI build, but I ran it locally and it was all green. |
|
Thanks for doing all this legwork @SleeplessOne1917. Pass argumentsThe most difficult failure here looks to be related to binaryen "pass arguments". This causes the failures in Some of the problems here are in the The pass args are kind of an obscure and underdocumented feature of binaryen. We could just break them, but I think this can be fixed. In the broken tests, this problem arises when using the On the command line, this used to look like Now it appears to only work as Internally to binaryen the It looks like to me like the fix is:
I will hack on this myself shortly unless someone else really wants to tackle it, but I don't expect anything more after waiting so long here. I haven't looked at the failure in Almost all the conformance tests are failing. This indicates that the API is not configuring binaryen the same way as wasm-opt is. I have not looked into it yet. These are run with The initial run takes a long time because it is rebuilding the c++ |
|
@brson I made your suggested changes except for fixing the tests. The conformance tests are now failing with a different issue and I'm not sure how to advance. Most of the conformance tests are failing when the API outfile is compared with the Rust out file. All the test output says is that one massive byte vector was produced when it should have been another massive byte vector and I can't see anything that indicates what the actual issue is. |
|
Is this ready to be merged? binaryen 116 does not provide a binary for linux arm64 which was added with 117 :( |
|
Besdies the CI build failing, we'll need to address the points I made in the comments I haven't marked as resolved already before merging. I'm hoping this can be merged sooner rather than later since |
|
Can I lend a hand to get this moving again? |
|
@ggreif I have no issue with that. I haven't had much time to work on anything recently and haven't refreshed myself on what I was doing here in awhile. I'm also not very familiar with C++ and was relying on feedback from the maintainer to help me iron out any issues I come across. If you're familiar with both Rust and C++, as well as the problem domain, you'd handle it better than I can. |
So I made some progress, or at least know where the problems with If you comment out //assert_eq!(api_out_file, rust_out_file);in assert_eq!(binaryen_out_file, rust_out_file);a few lines above it passes. @brson, any hunch? I suspect it is a timestamp or some version marker that differs. |
|
Okay, figured it out the diff is like this (for test $ diff -u 0*wat
--- 0api.wat 2026-01-14 12:52:25.091482776 +0100
+++ 0rust.wat 2026-01-14 12:52:25.008513803 +0100
@@ -1,38 +1,38 @@
(module
- (type (;0;) (func (param i32 i32 i32) (result i32)))
- (type (;1;) (func (param i32 i32) (result i32)))
- (type (;2;) (func (param i32) (result i64)))
- (type (;3;) (func (param i32) (result i32)))
+ (type (;0;) (func (param i32 i32)))
+ (type (;1;) (func (param i32 i32 i32) (result i32)))
+ (type (;2;) (func (param i32 i32) (result i32)))
+ (type (;3;) (func (param i32 i32 i32)))
(type (;4;) (func (param i32)))
- (type (;5;) (func (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32)))
- (type (;6;) (func (param i32 i32 i32 i32)))
- (type (;7;) (func (param i32 i32)))
- (type (;8;) (func (param i32 i32 i32)))
- (type (;9;) (func (param i32 i32 i32 i32 i32)))
- (type (;10;) (func (param i64 i64 i32)))
- (type (;11;) (func (param i32 i32 i32 i32 i32) (result i32)))
- (type (;12;) (func))
+ (type (;5;) (func (param i32 i32 i32 i32)))
+ (type (;6;) (func (param i32 i32 i32 i32 i32)))
+ (type (;7;) (func (param i32) (result i32)))
+ (type (;8;) (func))
+ (type (;9;) (func (param i32 i32 i32 i32 i32) (result i32)))
+ (type (;10;) (func (param i32) (result i64)))
+ (type (;11;) (func (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32)))
+ (type (;12;) (func (param i64 i64 i32)))
(type (;13;) (func (param i32 i64 i64) (result i32)))
(type (;14;) (func (result i32)))
(type (;15;) (func (param i32 i64 i32 i32 i32 i32) (result i32)))
(type (;16;) (func (param i64 i32) (result i32)))
(type (;17;) (func (param i32 i32 i32 i32) (result i32)))
(type (;18;) (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
- (import "seal0" "seal_debug_message" (func (;0;) (type 1)))
- (import "seal0" "seal_contains_storage" (func (;1;) (type 3)))
+ (import "seal0" "seal_debug_message" (func (;0;) (type 2)))
+ (import "seal0" "seal_contains_storage" (func (;1;) (type 7)))
(import "seal0" "seal_clear_storage" (func (;2;) (type 4)))
- (import "seal1" "seal_call" (func (;3;) (type 5)))
- (import "seal0" "seal_deposit_event" (func (;4;) (type 6)))
- (import "seal1" "seal_set_storage" (func (;5;) (type 0)))
- (import "seal0" "seal_get_storage" (func (;6;) (type 0)))
- (import "seal0" "seal_input" (func (;7;) (type 7)))
- (import "seal0" "seal_return" (func (;8;) (type 8)))
- (import "seal0" "seal_hash_blake2_256" (func (;9;) (type 8)))
- (import "seal0" "seal_caller" (func (;10;) (type 7)))
- (import "seal0" "seal_address" (func (;11;) (type 7)))
- (import "seal0" "seal_value_transferred" (func (;12;) (type 7)))
+ (import "seal1" "seal_call" (func (;3;) (type 11)))
+ (import "seal0" "seal_deposit_event" (func (;4;) (type 5)))
+ (import "seal1" "seal_set_storage" (func (;5;) (type 1)))
+ (import "seal0" "seal_get_storage" (func (;6;) (type 1)))
+ (import "seal0" "seal_input" (func (;7;) (type 0)))
+ (import "seal0" "seal_return" (func (;8;) (type 3)))
+ (import "seal0" "seal_hash_blake2_256" (func (;9;) (type 3)))
+ (import "seal0" "seal_caller" (func (;10;) (type 0)))
+ (import "seal0" "seal_address" (func (;11;) (type 0)))
+ (import "seal0" "seal_value_transferred" (func (;12;) (type 0)))
(import "env" "memory" (memory (;0;) 2))
- (func (;13;) (type 0) (param i32 i32 i32) (result i32)
+ (func (;13;) (type 1) (param i32 i32 i32) (result i32)
(local i32)
i32.const 0
local.set 3
@@ -59,7 +59,7 @@
local.set 3
br 0 (;@1;)
end)
- (func (;14;) (type 0) (param i32 i32 i32) (result i32)
+ (func (;14;) (type 1) (param i32 i32 i32) (result i32)
(local i32)
block ;; label = @1and it continues in this manner 'till the end. The type table's indices got permuted. But I'll do a more thorough analysis. |
Closes #166.
Besides updating the project to be compatible with binaryen version_121, I made a few other changes:
struminstead of separate dependency onstrum_macros.Pass::nameand instead useIntoStaticStrto generate static strings for enum variants.PassOptionsgenerateStackIRandoptimizeStackIRfields (these are present in binaryen version_121 but did not exist yet in version_116).containsPass(present in binaryen version_121 but did not exist yet in version_116).cargo clippy.I'm opening this as a draft since I'm not really familiar with binaryen or the WASM spec more generally. I made this PR by referring to previous commits in this repository adding support for newer binaryen versions.
@brson @Aimeedeer pinging you two to make sure you see this since this repo hasn't received any new commits on the master branch for close to a year and you are the primary contributors.