-
Notifications
You must be signed in to change notification settings - Fork 16
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
deps: WASI-Virt with upstreamed walrus changes #24
deps: WASI-Virt with upstreamed walrus changes #24
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.
Thanks for doing this, helps a huge amount to ensure we're on the right track with the Walrus updates before the release. Feeling a lot more confident about it seeing this, down to the builder suggestions.
Hey @guybedford a bunch of changes in the last few commits here: Want to pause before I keep going -- there's a bunch more that could be done here (the lists of functions being removed and stuff feel fairly static/certain), but the diff of this PR is growing so going to curtail it to the file moves I've done if you're happy with them (I'm also absolutely happy with moving the virt_deny back into one big file!) [EDIT] To be clear on what I mean by "keep going", there is only replacing uses of I'm definitely open to organizing the modules differently as well -- it feels like we could have something like:
[EDIT2] it seems like there are 3 distinct cases:
Without breaking the downstreams we could refactor into a shape that fits this more, but I'm also open with leaving them as is (including of course undoing the breaking out of [EDIT3] Welp, I didn't pause -- at this point the code should basically be ready for review -- there are some test failures so I'm double checking and debugging those but the overall structure of the PR should not change much from here |
e435d55
to
c78cb79
Compare
e655698
to
cbbc6c2
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.
I'm all for the abstracting of the import and export data here, that was something we needed to already better refactor in this project so thank you @vados-cosmonic for taking this one one.
Really nice to see the code deletions :)
The CI errors seem to me to be that the previous stub_imported_func
had a last argument which when false
would just silently ignore a failure of the get_func_by_name
function. And in particular that was set for a lot of the fs and stream functions.
The fix might be to have this boolean as part of the data, or two have two lists, and then handle the error differences appropriately in the loop.
Once the CI is going would be great to get this merged, we already run on git dependencies, so there's no concern about that either (at least until we publish this project).
Hey @guybedford thanks for taking the time to review, I felt that some of the changes might be gratuitous/a pain to review!
Agreed here, what I opted to do was separate into lists of Also in the case that you're thinking we can go with having it as part of the data, what do you think about having an enum like this: enum StubRequirement {
/// The import/export that is stubbed/stripped must be present *and* must be replaced
Required,
/// The import/export that is stubbed/stripped is allowed to be missing
Optional,
/// It depends on external factors (use-case specific), in this case whether the filesystem is used or not
RequiredDependingOnFsUsage,
} Want to avoid having just a raw One wrinkle to this scheme was that the FS stubbing actually depended on a variable coming in at runtime ( I'll look into this today |
Oh yeah and I'll probably add the module for |
89b5bd0
to
6831403
Compare
Hey @guybedford I tracked down the test failure and it's actually something rather insidious the same function ID is being used in two exports. I don' think the current Here's what I get when I print stuff out:
So the reason the code was breaking was that it looks like this: /// Delete an exported function by name from this module.
pub fn delete_func_by_name(&mut self, name: impl AsRef<str>) -> Result<()> {
let fid = self.get_func_by_name(name.as_ref()).with_context(|| {
format!("failed to find exported func with name [{}]", name.as_ref())
})?;
self.delete(
self.get_exported_func(fid)
.with_context(|| format!("failed to find exported func with ID [{fid:?}]"))?
.id(),
);
Ok(())
} We get the first function by name just fine -- in particular
When we come around the second time (for The culprit in this case seems to be this piece of code: /// Get a reference to a function export given its function id.
pub fn get_exported_func(&self, f: FunctionId) -> Option<&Export> {
self.iter().find(|e| match e.item {
ExportItem::Function(f0) => f0 == f,
_ => false,
})
} This function seems to have been written at a time when it was impossible (?) for the same function ID to be used in two different exports. Obviously, changing that function is going to be a big 'ol breaking change, so there are a few options I can think of to fix this:
I'm going to make a PR to [EDIT] PR is up (approach 1 is clearly the best there so went ahead and did that) |
0c48831
to
dc8695a
Compare
OK, this is the final face of the refactor, code wise.
Upstream |
da14f9a
to
05feebe
Compare
05feebe
to
a59f578
Compare
Just updated to match the changes made to [EDIT] Going to rename the commit to match the title of this PR |
a59f578
to
43690f8
Compare
After the work done upstreaming operations used in `src/walrus_ops.rs` to walrus, the code for WASI-Virt can be updated to use the new APIs and reduce custom code. This commit updates the WASI-Virt codebase to use the upstreamed functions and adds some light refactors to the more mechanical pieces of code for stubbing/denying/stripping. see: bytecodealliance#20 see: rustwasm/walrus#252 Signed-off-by: Victor Adossi <[email protected]>
43690f8
to
77b6248
Compare
Thanks @vados-cosmonic for the persistence in this one! |
Thanks for all the reviews and patience, @guybedford 🙇 ! |
This branch serves an example of what WASI-Virt would look like with the recently upstreamed changes to walrus.
This branch is likely to change greatly/possibly be dropped in favor of a new branch that could be merged.