-
Notifications
You must be signed in to change notification settings - Fork 109
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
Move to .NET 8 WASI support #587
Conversation
No difference for Wasi.Sdk, but there will be some in upcoming .NET 8.
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.
Small code comments but looks really great!
The only thing I want is some approval from I guess @jdetter or @cloutiertyler that the download strategy is ok from a product perspective.
5800b37
to
55a4ffa
Compare
FWIW this is the same download strategy the previously used Wasi.Sdk package uses. I'm open to better suggestions, just pointing out that functionally it's not something new. |
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.
Tested, working with a few hiccups. Ingvar knows what the issues are and will fix them before merging. Approving so that this isn't blocked. We're trying to get this into the 0.8 release which we're cutting later today.
@RReverser Let me know if there's anything I can do to help test or land this. |
@jdetter wanted to do some more testing after my fixes - we ran into some issues, but they were mostly with unclear error messages e.g. due to .NET 8 not being installed. There was also an issue with I fixed those so in principle nothing prevents this from getting merged now, but I'd prefer to wait for @jdetter to double-check that it's looking good. |
The main problem is actually that I don't have macOS to test that sudo issue is gone now. @kulakowski if you want to test this, you can try to check out, do |
Trying now. |
@kulakowski Any luck? |
Ok I'm merging this as-is to make sure it gets into release. If there are more things to improve, we can do that separately. |
It worked fine, just took a while to download a new xcode etc. |
Thanks. I'm confused though - why would it need Xcode? O_o |
Xcode has a couple levels, the lowest is essentially just a toolchain, and the new dotnet needed a newer version of the toolchain. |
Description of Changes
.NET 8 shipped last week with built-in WASI support. It's still marked as experimental because some things - like better import/export handling that we could use - are still being worked on, but it's already better than using the
Wasi.Sdk
package which is now soft-deprecated and has a number of bugs that nobody's going to fix anymore.This change is pretty big because it tries to move from custom Mono C APIs to native C# marshalling as much as possible, because it's now supported, it's safer, and it's more future-proof. We should be able to eventually remove the
bindings.c
layer altogether onceUnmanagedCallersOnly
andDllImport
are handled automatically and generate Wasm imports/exports by .NET's PInvoke, which is already available in .NET alpha channel. It also provides better foundation for NativeAOT support where Mono APIs don't exist and where otherwise we'd have to maintain two very different paths for AOT and non-AOT bindings.The performance and instruction cost of the resulting bundle is more or less the same as before, because it's still using an interpreter bundled together with .NET bytecode, but thanks to various trimming options the Wasm itself is now ~3 times smaller.
API and ABI breaking changes
I don't think we have the right category for this, but after this change users will need to install .NET 8 to build new SpacetimeDB projects, but we'll automate the rest, e.g. installing the WASI SDK (Clang compiler & C stdlib) as well as Wasi workload for .NET itself.
I'll tentatively mark it as ABI change to draw attention to breakage even though ABI of the generated module is still compatible.
Expected complexity level and risk
3
This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.
If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.