If you haven't already done so, please read this document to understand the build requirements for your operating system.
At this time no other build dependencies are necessary to start building for WebAssembly. Emscripten will be downloaded and installed automatically in the build process. To read how to build on specific platforms, see Building.
This document explains how to work on the runtime or libraries. If you haven't already done so, please read this document to understand configurations.
When rebuilding with build.sh after a code change, you need to ensure that the mono.wasmruntime and libs.pretest subsets are included even for a Mono-only change or this directory will not be updated (details below).
At this time, it is not possible to specify different configurations for the runtime and libraries. That is mixing a Release -runtimeConfiguration with a Debug -libraryConfiguration (or -configuration), or vice versa will not work. The same applies to single and multithreaded configurations.
Please only use the -configuration option with Debug or Release, and do not specify a -runtimeConfiguration and -libraryConfiguration.
This is tracked in #42553
If you are working on core parts of Mono you will probably need to build the Mono runtime and System.Private.CoreLib which can be built with the following:
./build.sh mono -os browser -c Debug|ReleaseTo build just System.Private.CoreLib without the Mono runtime you can use the Mono.CoreLib subset:
./build.sh mono.corelib -os browser -c Debug|ReleaseTo build just the Mono runtime without System.Private.CoreLib use the Mono.Runtime subset:
./build.sh mono.runtime -os browser -c Debug|ReleaseBuilding both Mono/System.Private.CoreLib and the managed libraries:
./build.sh mono+libs -os browser -c Debug|ReleaseThe WebAssembly implementation files are built after the libraries source build and made available in the artifacts folder. If you are working on the code base and need to compile just these modules then building the Mono.WasmRuntime subset will allow one to do that:
./build.sh mono.wasmruntime -os browser -c Debug|ReleaseIf you don't run the full Libs subset then you can use the Libs.PreTest subset to copy updated runtime/corelib binaries to the runtime pack which is used for running tests:
./build.sh libs.pretest -os browser -c Debug|ReleaseThe libraries build contains some native code. This includes shims over libc, openssl, gssapi, and zlib. The build system uses CMake to generate Makefiles using clang. The build also uses git for generating some version information.
./build.sh libs.native -os browser -c Debug|ReleaseIndividual projects and libraries can be build by specifying the build configuration.
Examples
- Build all projects for a given library (e.g.: System.Net.Http) including the tests
./build.sh -os browser -c Release --projects <full-repository-path>/src/libraries/System.Net.Http/System.Net.Http.slnx- Build only the source project of a given library (e.g.: System.Net.Http)
./build.sh -os browser -c Release --projects <full-repository-path>/src/libraries/System.Net.Http/src/System.Net.Http.csprojMore information and examples can be found in the libraries document.
A Debug build sets the following environment variables by default:
- debugging and logging which will log garbage collection information to the console.
MONO_LOG_LEVEL=debug
MONO_LOG_MASK=gc
L: GC_MAJOR_SWEEP: major size: 752K in use: 39K
L: GC_MAJOR: (user request) time 3.00ms, stw 3.00ms los size: 0K in use: 0K
- Redirects the
System.Diagnostics.Debugoutput tostderrwhich will show up on the console.
// Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this
// output will be sent to the console. Right now this is the only way to emit debug logging from
// corlib assemblies.
monoeg_g_setenv ("DOTNET_DebugWriteToStdErr", "1", 0);
First update the Emscripten version in the current WebAssembly image definition in dotnet-buildtools-prereqs-docker. The active WebAssembly images are tracked in the Azure Linux manifest.
Submit a PR with the Dockerfile change and wait for the image publishing flow to complete.
Once the image is published, find the new tag in the corresponding
image-info file
in dotnet/versions.
Then update the WebAssembly image references in this repo:
Open a PR with the updated image references.
You can read about running library tests in Libraries tests.