Closed RReverser closed 1 year ago
I haven't archived this repo yet or updated the README, but from here on all the development work and focus is on the WASI workload in the real .NET SDK, from .NET 8 Preview 4 onwards. There's a video about it at https://twitter.com/stevensanderson/status/1658845798212202496 and a blog post with early docs coming soon.
So, if you could try this out with the new runtime that would be great. If it still seems to have a bug, please consider filing an issue on https://github.com/dotnet/runtime
I'm definitely keeping an eye on .NET Preview 8 and tried it, but it's too early to replace this repo for non-WASI tasks, particularly due to missing custom import/export functionality which you showed me how to use in the other issue couple months ago.
I'll be happy to switch over when that's implemented but for now we're stuck with Wasi.Sdk and would love some help with this bug.
I think it's still possible to do the same import/export techniques with new runtime implementation. The import/export facilities that are still to be implemented are new, better ones. I'm afraid I won't have capacity to investigate issues on this repo any time soon - sorry!
I think when I tried I was running into this issue (at least I think it's the same one) you mentioned here:
https://github.com/dotnet/runtime/issues/65895#issuecomment-1546766222
It ignores pinvokes unless they correspond to an entry on _WasmNativeFileForLinking (even though when you want to generate an import, you won't be linking with any module for it)
But maybe it was for the new binding system and not old one? I'll give it another try but if it still doesn't work, I guess I'm stuck.
Do you have a working example with custom C bindings that works with .Net Preview 8 that you could point me to?
Right, just double-checked and the problem with .NET 8 is that no matter what I do, I can't get my own imports/exports to show up in generated Wasm.
And also WasiAfterRuntimeLoaded doesn't work:
/home/rreverser/.dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/8.0.0-preview.5.23280.8/Sdk/WasiApp.Native.targets(465,26): error MSB4012: The expression "-D WASI_AFTER_RUNTIME_LOADED_DECLARATIONS="@(WasiAfterRuntimeLoadedDeclarations, ' ')"" cannot be used in this context. Item lists cannot be concatenated with other strings where an item list is expected. Use a semicolon to separate multiple item lists. [/home/rreverser/spacetime-web/api/module_templates/cs/StdbModule.csproj]
And then there are missing symbols for all those utils like mono_wasm_invoke_method.
It just seems a lot less mature than Wasi.Sdk for now which at least does work today.
@RReverser were you eventually successful with .NET 8, now that it's released? I asked this question on SO before (https://stackoverflow.com/q/77848793/5831785), but it seems nobody was able to do it yet.
@rs22 Yes, we are using it successfully now. I'm going to write a blog post soon-ish.
Ok I spent pretty much entire day today trying to figure out what's going on here because this bug reproduces in pretty weird ways, but now I'm giving up and going to need some help please. @SteveSandersonMS.
Here's reasonably minimal sample that at least prints a useful error message: https://gist.github.com/RReverser/db10fc4dfe039630eb24821e1d619bf7 (in other instances I ran into, it just crashes)
Error:
What's weird is, if I uncomment printing
DateTimeOffset.UnixEpoch
(I chose it just because it's a constant, to reduce repro and not depend on WASI time) inMain
, then both that one and the one inHelloWorld
work fine, but if it's commented out (or, as in my original project, doesn't exit), then logging instances ofDateTimeOffset
crashes everywhere else as well.Judging by this message and the observed behaviour, I suspect there is some lazy initialisation happening that only loads DLLs if they are needed by
Main
function but not other exports? Not sure what to make of it or how to fix it.