Skip to content

Conversation

@benbrandt
Copy link
Member

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 :)

Copy link
Member Author

@benbrandt benbrandt left a 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,
Copy link
Member Author

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.

Copy link
Collaborator

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,
Copy link
Member Author

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

Copy link
Collaborator

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,
Copy link
Member Author

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,
Copy link
Member Author

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())?;
Copy link
Member Author

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

Copy link
Collaborator

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)?;
Copy link
Member Author

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,
Copy link
Member Author

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,
Copy link
Member Author

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"

@benbrandt
Copy link
Member Author

@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

@dicej
Copy link
Collaborator

dicej commented Sep 4, 2024

Thanks, @benbrandt ! BTW, you probably noticed I was using forks of wasmtime etc. with patches to support isyswasfa. We can drop all that and remove the isyswasfa code -- it was a proof-of-concept that has served its purpose; we don't need it anymore.

BTW, I'd be fine with ripping off the band-aid and upgrading to wasmtime 24 and whatever wasm-tools it's using. Might as well jump to the latest of everything while we're doing this.

@benbrandt
Copy link
Member Author

benbrandt commented Sep 4, 2024

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
dicej/component-init#2
dicej/isyswasfa-transform#1

Though the last one isn't necessary if we rip it out.

@benbrandt
Copy link
Member Author

@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

@benbrandt
Copy link
Member Author

@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 🙈

@benbrandt benbrandt marked this pull request as draft September 5, 2024 16:55
.exports(&mut self.store)
.root()
.typed_func::<(), (i32,)>(function)?;
.get_typed_func::<(), (i32,)>(&mut self.store, function)?;
Copy link
Member Author

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>,)>(
Copy link
Member Author

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>;
Copy link
Member Author

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

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}")?,"#
Copy link
Member Author

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))
}}))
Copy link
Member Author

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.

@dicej
Copy link
Collaborator

dicej commented Sep 5, 2024

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

@benbrandt
Copy link
Member Author

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

@dicej
Copy link
Collaborator

dicej commented Sep 6, 2024

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

@dicej dicej marked this pull request as ready for review September 6, 2024 20:42
@dicej
Copy link
Collaborator

dicej commented Sep 6, 2024

@benbrandt Thanks again for doing this; it saved me a lot of time!

@dicej dicej merged commit d477aa0 into bytecodealliance:main Sep 6, 2024
1 check passed
@benbrandt
Copy link
Member Author

@dicej glad I could help!

@benbrandt benbrandt deleted the update-deps branch September 6, 2024 21:25
@dicej
Copy link
Collaborator

dicej commented Sep 6, 2024

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.

@dicej
Copy link
Collaborator

dicej commented Sep 6, 2024

Update: the release is live: https://pypi.org/project/componentize-py/

@benbrandt
Copy link
Member Author

Amazing thank you!

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

Successfully merging this pull request may close these issues.

2 participants