Skip to content
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

Adds support for building Wasm on Windows #45545

Merged
merged 28 commits into from
Mar 17, 2021

Conversation

steveisok
Copy link
Member

Emscripten and EMSDK_PATH must be set up externally. This differs from linux and macos where we optionally can do it for you.

Steve Pfister added 2 commits December 2, 2020 12:17
Emscripten and EMSDK_PATH must be set up externally.  This differs from linux and macos
where we optionally can do it for you.
@steveisok steveisok changed the title Adds support for building wasm on Windows Adds support for building Wasm on Windows Dec 3, 2020
@steveisok
Copy link
Member Author

@lewing @akoeplinger Thoughts on where this should build on CI?

@steveisok steveisok requested a review from lewing December 3, 2020 14:22
eng/native/gen-buildsys.cmd Outdated Show resolved Hide resolved
@jkotas
Copy link
Member

jkotas commented Dec 3, 2020

cc @yowl

src/mono/mono.proj Outdated Show resolved Hide resolved
src/mono/wasm/wasm.proj Outdated Show resolved Hide resolved
src/mono/wasm/wasm.proj Show resolved Hide resolved
@lewing lewing added the arch-wasm WebAssembly architecture label Dec 11, 2020
@lewing
Copy link
Member

lewing commented Dec 11, 2020

/cc @radical

@jkotas
Copy link
Member

jkotas commented Dec 13, 2020

Thoughts on where this should build on CI?

We would need to get a Windows machine with Emscripten. The easiest way to do that is to install Emscripten on the fly. https://github.com/dotnet/runtimelab/blob/d0cda961aeda26faae17c474e26d822cd1e45438/eng/pipelines/runtimelab/install-emscripten.cmd is a small script to do that. I am not sure whether it would be appropriate for dotnet/runtime CI though.

@akoeplinger
Copy link
Member

akoeplinger commented Dec 14, 2020

Thoughts on where this should build on CI?

I think we'll mostly want to protect the Windows wasm build for local developer purposes, official builds will likely always use Linux so to me this would make it a good fit for the runtime-live-build pipeline.

I'm not a big fan of introducing the on the fly download of Emscripten like you do in the runtimelab since it's another dependency that can break dotnet/runtime CI.

@steveisok
Copy link
Member Author

Thoughts on where this should build on CI?

I think we'll mostly want to protect the Windows wasm build for local developer purposes, official builds will likely always use Linux so to me this would make it a good fit for the runtime-live-build pipeline.

I'm not a big fan of introducing the on the fly download of Emscripten like you do in the runtimelab since it's another dependency that can break dotnet/runtime CI.

Agreed re: not downloading emscripten every time.

@lewing @radical Do you see the need to run tests? Or will only build validation suffice?

Base automatically changed from master to main March 1, 2021 09:07
@@ -110,4 +108,109 @@
SkipUnchangedFiles="true" />
</Target>

<UsingTask TaskName="GenerateWasmVersionFile"
AssemblyFile="$(WasmBuildTasksAssemblyPath)"/>
<Target Name="BuildWinWasmRuntimes"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this target replace the make invocation in BuildWasmRuntimes? I mean, are they two effectively the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

src/mono/wasm/wasm.proj Outdated Show resolved Hide resolved
src/mono/wasm/wasm.proj Outdated Show resolved Hide resolved
src/mono/mono.proj Outdated Show resolved Hide resolved
Similar to what we do in build.sh
To avoid this error:

    Installing tool 'node-12.18.1-64bit'..
      Installation failed!
      Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/node-v12.18.1-win-x64.zip': <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)>
      Warning: Possibly SSL/TLS issue. Update or install Python SSL root certificates (2048-bit or greater) supplied in Python folder or https://pypi.org/project/certifi/ and try again.
      Warning: The SDK/tool 'node-12.18.1-64bit' cannot be activated since it is not installed! Skipping this tool...

The script comes from runtimelabs repo https://github.com/dotnet/runtimelab/blob/d0cda961aeda26faae17c474e26d822cd1e45438/eng/pipelines/runtimelab/update-machine-certs.ps1
And use it in Makefile and mono.proj
@radical
Copy link
Member

radical commented Mar 16, 2021

@lewing @radical Do you see the need to run tests? Or will only build validation suffice?

IMHO, for this PR, build validation should be enough. That should enable more of us to try this out, and tests can be enabled in a follow up PR.

I think we are missing cmake and failing with:

      configure: cmake -DENABLE_WERROR=1 -DCMAKE_INSTALL_PREFIX=D:\workspace\_work\1\s\artifacts\obj\mono\Browser.wasm.Debug\out -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Debug -DGC_SUSPEND=preemptive -DENABLE_MINIMAL=jit,portability,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,eventpipe,qcalls -DENABLE_INTERP_LIB=1 -DDISABLE_ICALL_TABLES=1 -DDISABLE_CRASH_REPORTING=1 -DENABLE_ICALL_EXPORT=1 -DENABLE_LAZY_GC_THREAD_CREATION=1 -DENABLE_LLVM_RUNTIME=1 -DENABLE_METADATA_UPDATE=1 "-DCMAKE_C_FLAGS= -fexceptions -ID:\workspace\_work\1\s\.packages\microsoft.netcore.runtime.icu.transport\6.0.0-preview.3.21151.1/runtimes/browser-wasm/native/include" "-DCMAKE_CXX_FLAGS= -fexceptions" D:\workspace\_work\1\s\src\mono\ -DCMAKE_TOOLCHAIN_FILE=D:\workspace\_work\1\s\src\mono\wasm\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="D:/workspace/_work/1/s/src/mono/wasm/emsdk/node/12.18.1_64bit/bin/node.exe" -G Ninja
      Traceback (most recent call last):
        File "D:\workspace\_work\1\s\src\mono\wasm\emsdk\upstream\emscripten\\emcmake.py", line 33, in <module>
          sys.exit(run())
        File "D:\workspace\_work\1\s\src\mono\wasm\emsdk\upstream\emscripten\\emcmake.py", line 26, in run
          building.configure(sys.argv[1:])
        File "D:\workspace\_work\1\s\src\mono\wasm\emsdk\upstream\emscripten\tools\building.py", line 339, in configure
          run_process(args, stdout=stdout, stderr=stderr, env=env, **kwargs)
        File "D:\workspace\_work\1\s\src\mono\wasm\emsdk\upstream\emscripten\tools\shared.py", line 94, in run_process
          ret = subprocess.run(cmd, check=check, input=input, *args, **kw)
        File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 472, in run
        File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 775, in __init__
        File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 1178, in _execute_child
      FileNotFoundError: [WinError 2] The system cannot find the file specified
    D:\workspace\_work\1\s\src\mono\mono.proj(410,5): error MSB3073: The command "call D:\workspace\_work\1\s\src\mono\wasm\emsdk\emsdk_env.bat && emcmake cmake -DENABLE_WERROR=1 -DCMAKE_INSTALL_PREFIX=D:\workspace\_work\1\s\artifacts\obj\mono\Browser.wasm.Debug\out -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Debug -DGC_SUSPEND=preemptive -DENABLE_MINIMAL=jit,portability,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,eventpipe,qcalls -DENABLE_INTERP_LIB=1 -DDISABLE_ICALL_TABLES=1 -DDISABLE_CRASH_REPORTING=1 -DENABLE_ICALL_EXPORT=1 -DENABLE_LAZY_GC_THREAD_CREATION=1 -DENABLE_LLVM_RUNTIME=1 -DENABLE_METADATA_UPDATE=1 -DCMAKE_C_FLAGS=" -fexceptions -ID:\workspace\_work\1\s\.packages\microsoft.netcore.runtime.icu.transport\6.0.0-preview.3.21151.1/runtimes/browser-wasm/native/include" -DCMAKE_CXX_FLAGS=" -fexceptions"  D:\workspace\_work\1\s\src\mono\" exited with code 1.
    ##[error]src\mono\mono.proj(410,5): error MSB3073: (NETCORE_ENGINEERING_TELEMETRY=Build) The command "call D:\workspace\_work\1\s\src\mono\wasm\emsdk\emsdk_env.bat && emcmake cmake -DENABLE_WERROR=1 -DCMAKE_INSTALL_PREFIX=D:\workspace\_work\1\s\artifacts\obj\mono\Browser.wasm.Debug\out -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Debug -DGC_SUSPEND=preemptive -DENABLE_MINIMAL=jit,portability,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,shared_perfcounters,interpreter,threads,eventpipe,qcalls -DENABLE_INTERP_LIB=1 -DDISABLE_ICALL_TABLES=1 -DDISABLE_CRASH_REPORTING=1 -DENABLE_ICALL_EXPORT=1 -DENABLE_LAZY_GC_THREAD_CREATION=1 -DENABLE_LLVM_RUNTIME=1 -DENABLE_METADATA_UPDATE=1 -DCMAKE_C_FLAGS=" -fexceptions -ID:\workspace\_work\1\s\.packages\microsoft.netcore.runtime.icu.transport\6.0.0-preview.3.21151.1/runtimes/browser-wasm/native/include" -DCMAKE_CXX_FLAGS=" -fexceptions"  D:\workspace\_work\1\s\src\mono\" exited with code 1.
@ivan-prodanov
Copy link

Can't wait to use this. 👀

Copy link
Member

@radical radical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. There are some issues like it breaks if the runtime checkout is in a path with spaces, but we can fix those in a follow up PR. CI doesn't have the same issue.

@radekdoulik radekdoulik merged commit 4ae9b33 into dotnet:main Mar 17, 2021
@ivan-prodanov
Copy link

ivan-prodanov commented Mar 17, 2021

Great job everyone!
Do we have an example on how to build AOT Wasm apps on windows?

src/mono/mono.proj Show resolved Hide resolved
src/mono/wasm/Makefile Show resolved Hide resolved
jobParameters:
testGroup: innerloop
nameSuffix: Browser_wasm_Windows
buildArgs: -subset mono+libs /p:RuntimeFlavor=Mono
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that it's the runtime-staging pipeline this is probably fine temporarily but for regular runs we need to take another look since right now this clones emsdk and downloads binaries from google storage on each PR which is something we generally want to avoid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, looking forward to use the nuget instead

@lewing
Copy link
Member

lewing commented Mar 17, 2021

@ivan-prodanov we have few more pieces to get into place first but we will be documenting the process soon.

@@ -360,11 +386,12 @@
</ItemGroup>

<PropertyGroup>
<_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) $(MonoProjectRoot)</_MonoCMakeConfigureCommand>
<_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) $(MonoProjectRoot.TrimEnd('\/'))</_MonoCMakeConfigureCommand>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there some msbuild magic function for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any. There are functions that do the opposite - make sure that there is trailing slash. @radical do you know if there's better way to do this?

@akoeplinger akoeplinger deleted the wasm-windows-build branch March 22, 2021 16:24
@ghost ghost locked as resolved and limited conversation to collaborators Apr 21, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Build-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.