-
Notifications
You must be signed in to change notification settings - Fork 30
Update wasm related dependencies #102
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
Conversation
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.
I didn't touch pyo3 because that might be a bigger change that I didn't get to.
I also was having issues in the runtime crate updating wit-bindgen, but I'm not sure if that needs to be updated or not
| EntityType::Global(GlobalType { | ||
| val_type: ValType::I32, | ||
| mutable: false, | ||
| shared: false, |
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.
The docs all had this as false, but I don't know what the correct value should be.
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.
false is correct in this context. true would mean the global can be accessed from more than one thread, but WASIp2 and the component model are strictly single threaded for the time being.
| maximum: None, | ||
| memory64: false, | ||
| shared: false, | ||
| page_size_log2: None, |
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.
Same here. I assumed the default
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.
Yeah, we have no use for non-default page sizes at this point. That's primarily meant for embedded systems.
| nullable: true, | ||
| heap_type: HeapType::Func, | ||
| }, | ||
| element_type: RefType::FUNCREF, |
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.
It seemed that this constant was a convenience wrapper around the same thing, but I could be wrong
| .try_into() | ||
| .unwrap(), | ||
| maximum: None, | ||
| table64: false, |
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.
Followed the doc example here as well
| "bundled", | ||
| ); | ||
| .preopened_dir(stdlib.path(), "python", DirPerms::all(), FilePerms::all())? | ||
| .preopened_dir(bundled.path(), "bundled", DirPerms::all(), FilePerms::all())?; |
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.
It seemed that this now just wanted paths. I think I got the arguments in the right order...
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.
Pretty much none of the tests would pass if you used the wrong order, so we're good :)
| linker: &mut Linker<Ctx>, | ||
| ) -> Result<()> { | ||
| wasi_command::add_to_linker(linker)?; | ||
| wasmtime_wasi::add_to_linker_async(linker)?; |
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.
I was having trouble finding if the old command was just replaced by the top-level linker. it is possible this is linking too much, I couldn't tell.
| world: "echoes-test", | ||
| async: true | ||
| async: true, | ||
| trappable_imports: true, |
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.
I added this to all of them, since the previous implementations allowed for Result in the return values.
| "componentize-py:test/resource-alias1/thing": ThingString, | ||
| "componentize-py:test/resource-floats/float": MyFloat, | ||
| "resource-floats-imports/float": MyFloat, | ||
| "resource-floats-exports/float": MyFloat, |
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.
These came up as "unused"
|
@dicej I added some comments where I was unsure on things to help focus the review. I don't claim to be an expert, and the changelogs are hard to follow/nonexistent for these crates |
|
Thanks, @benbrandt ! BTW, you probably noticed I was using forks of BTW, I'd be fine with ripping off the band-aid and upgrading to |
|
Ok I can take a look at it tomorrow. I created a few more PRs for downstream deps so that wasmtime and wasm-tools can be updated. https://github.com/dicej/wasm-convert/pull/1/files Though the last one isn't necessary if we rip it out. |
|
@dicej I removed the isyswasfa, but I am really struggling with some of the wasmtime changes, especially in the test generators. I'll see if I can manage to get this in an ok state |
|
@dicej ok I pushed up what I did. It compiles, but tests fail horribly. Maybe you might have some ideas of what I did wrong here 🙈 |
| .exports(&mut self.store) | ||
| .root() | ||
| .typed_func::<(), (i32,)>(function)?; | ||
| .get_typed_func::<(), (i32,)>(&mut self.store, function)?; |
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.
These all seem to fail, which I suspect is because somehow I am not retrieving the function from the correct level.
src/lib.rs
Outdated
| Init::instantiate_async(&mut store, component, &linker).await?; | ||
| let instance = linker.instantiate_async(&mut store, component).await?; | ||
| let init = instance | ||
| .get_typed_func::<(&str, &Symbols, bool), (Result<(), String>,)>( |
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.
I had to replicate some of what was happening in the bindgen because the bindgen code no longer returns the instance
| store: &mut Store<Ctx>, | ||
| pre: &InstancePre<Ctx>, | ||
| ) -> Result<(Self::World, Instance)>; | ||
| async fn instantiate_pre(store: &mut Store<Ctx>, pre: InstancePre<Ctx>) -> Result<Self::World>; |
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.
Since the instance doesn't get returned anymore, I removed it from this return as well.
Also, the only methods I could find that did roughly the same thing needed to consume the InstancePre. Since this is holding Arcs, I am hoping it is ok to clone and consume...
test-generator/src/lib.rs
Outdated
| writeln!( | ||
| &mut typed_function_inits, | ||
| r#"echo{test_index}: instance.typed_func::<({params}), ({result_type},)>("echo{test_index}")?,"# | ||
| r#"echo{test_index}: instance.get_typed_func::<({params}), ({result_type},)>(&mut *store, "componentize-py:test/echoes-generated/echo{test_index}")?,"# |
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.
I'm almost positive this isn't correct....
| Ok((Self::World {{ | ||
| {typed_function_inits} | ||
| }}, guest_instance)) | ||
| }})) |
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 too. All of this has changed a lot, and I don't think I am accessing the functions correctly here.
|
@benbrandt Thanks for putting so much effort into this. I'm having a busy week, so apologies for not helping much so far. Hopefully I'll have some time tomorrow to take a look. |
|
No worries. If you want you can also just go commit by commit and if I went wrong somewhere I can maybe cherry pick or revert if the others are ok |
Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
|
@benbrandt I just pushed an update to fix the tests. I'll merge your PRs on the other repos, then update the Cargo.toml here to match, and then we should be ready to merge this. |
Signed-off-by: Joel Dice <[email protected]>
|
@benbrandt Thanks again for doing this; it saved me a lot of time! |
|
@dicej glad I could help! |
|
FYI, I'm planning to publish a new release to pypi.org, but having CI issues I may need an administrator to help with, and that may need to wait until Monday. |
|
Update: the release is live: https://pypi.org/project/componentize-py/ |
|
Amazing thank you! |
This updates all of the WASM related dependencies I could.
I think there is one failing test still, which I don't understand, so it is possible I messed something up in addressing the changes. Would appreciate a lookover.
Also, I couldn't go to the latest for everything because some of the sub git deps are pinned at wasm-tools 0.209.1, so I had to keep them there as well as a wasmtime version that also used those versions.
Hopefully this is a helpful start though, and if not, no worries :)