-
Notifications
You must be signed in to change notification settings - Fork 508
Can't build Web Assembly on Windows #8311
Comments
cc @yowl |
@guptay1 I dont know that you can create the wasm from a
The csproj for this looks like:
|
I've got net 5 preview installed but |
@yowl I'm also using .NET 5 Preview. The LLVM bitcode file is getting created. I wasn't able to create it before. Now when I run the command:
I get the following error in the browser console:
Also tried the following emcc command from the documentation:
where actually libPortableRuntime.bc -> libPortableRuntime.a and libbootstrappercpp.bc->libbootstrappercpp.a after build.cmd. This emcc command gives many errors with a general format like:
Am I missing something here? |
Hmm, the |
@yowl No, it didn't |
The 3 archive, |
@yowl Yes. I was pointing out that the documentation says that they are bitcode files |
Ah ok, right its out of date. So under your project folder you dont have |
I do, but it's empty. There is no content in it when ideally it should've had the html, js and wasm file, Right? |
can you run |
Yes it should |
That doesn't look right, you should have 3:
|
Lemme Check |
Without EMSDK env var, this condition will not be true and linking will not occur: |
Added the EMSDK variable using emsdk_env.bat. I can generate the files in the bin now but on Running it on live server, it throws the following errors: |
Yeah, unfortunately However looking now I can't see the browser_wasm artifact. |
So, adding this archive file to the command |
mm, actually it's a bit more complicated you need basically all the dlls from the browser-wasm build which I can't find now. The easiest thing to do is to replace
If Then
|
This is what I'm doing for the test projects. |
@yowl Can you point out one such test project that you might've made available on open source? I saw your snakewasm project but it didn't have any documentation to exactly understand what you actually did. Also, the hack above, I understand what you did there in the code but didn't understand the imports and CODEGEN_WASM. Can you elaborate more on that? |
I'm referring to the CoreRT test projects that are enabled for Wasm, e.g. https://github.com/dotnet/corert/tree/master/tests/src/Simple/HelloWasm.
in a
|
@yowl Did the above thing. The Console error is resolved but now I am getting a call stack size exceeded exception. Also, as you can see that the discussion is going too long and apparently there are too many details and too many hacks which aren't present in the documentation. Can you please write a sample app which won't take long ( a Hello World is also fine) based on the above discussion? Most of the things are discussed here so it will become pretty easy for me and the future readers who want to understand c# and wasm together. Or maybe point to some documentation which outlines this for new devs? |
@yowl Any intuitions for how to clear the above call stack size exceeded error? What can be the possible cause of this and how to resolve? |
You can start with https://github.com/yowl/WasmHelloWorld |
@yowl This works. Couldn't figure out why my code wasn't working because I was doing exactly the same. Probably something I might be missing. I just need some more info to move a step further. If I want to use System.ServiceModel.Http package in my solution, then how can I go about it? I don't think directly adding the package to the project will do it. Since we are using corert, there must be some additions which have to be made to it? Also, I have a WCF service which I want to add as a Connected service in my ConsoleApp. Is this supported in Wasm considering the calling to service and the fetching happens over http requests?? |
I don't think WCF would even work when targeting Windows/Linux. Trying it with WASM might be a stretch. WCF has a custom implementation for .NET Native that we haven't hooked up into CoreRT yet. Besides some NuGet configuration kung-fu so that we pick up the UWP version of WCF (if that even works), we also lack support for the compile-time version of |
@MichalStrehovsky I'm targeting only wasm for now. Do you think that the support will be there when .NET 5 will be released? |
This repo has an experimental project in it with no official shipping schedule. The WASM support in it is even more experimental. I would look into the thing that is officially supported, which is Mono's WASM. Try it with the latest .NET 5 SDK and if it doesn't work, file an issue in the dotnet/runtime repo. |
@MichalStrehovsky The plan was to use mono-wasm. But it lacks documentation. The documentation which is present dates back to almost 3 years in which the mentioned things don't work or might've moved to some other location or made private. This repo had a much better documentation to get new devs get started with wasm easily and it seems straightforward with a bunch of hacks which make perfect sense. If you know about similar documentation for mono and where can I find it, can you share? |
I suggest opening an issue about the lack of documentation in the dotnet/runtime repo. But yeah, the team's priority is Blazor so they mostly just care that Blazor-integrated bits work. They have some non-Blazor samples here: https://github.com/dotnet/runtime/tree/master/src/mono/netcore/sample/wasm. AFAIK the WASM targeting runtime/SDK is only buildable on Linux because they're all Linux/mac people. (Once you build the WASM runtime, you can use Windows.) |
Yes, all I could find was Blazor whenever c# and wasm comes together. There is no direct c# to wasm translation being talked about except in corert. Guess I should open up an issue with dotnet/runtime repo requesting documentation. Also, you are right. The targeting runtime/SDK needs macOS. I couldn't find the artifacts for other environment except macOS. The article and the github repo which mentions about it is also 3 years old which seems like a dead project as no new commits are made. |
After following the instructions on https://github.com/morganbr/corert/blob/master/Documentation/how-to-build-WebAssembly.md and https://github.com/dotnet/corert/blob/master/Documentation/how-to-build-WebAssembly.md, I tried building a simple hello world app instead of using the sample. Added the nuget packages and set up of Emscripten. Not able to generate the .bc file and hence no wasm file can be generated using emcc. All pre-requisites and setups are working. Can someone point out how to do it from scratch for a hello world app without using the samples?
The text was updated successfully, but these errors were encountered: