[wasm] Incremental build improvements (#90194)
authorAnkit Jain <radical@gmail.com>
Mon, 14 Aug 2023 15:48:54 +0000 (11:48 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Aug 2023 15:48:54 +0000 (11:48 -0400)
commit711447a43d607883e511da4627631cda1f9c9d5f
treeb69ae2868a569483470c41f7c1459a71a4461dbc
parent19e84e731b91c30acae5baf747a0c6365e5767b6
[wasm] Incremental build improvements (#90194)

- [wasm] Sanity check emcc versions only when using a custom EMSDK_PATH
- [wasm] Emit a message about compiling native assets only when actually doing so
- [wasm] ConvertDllsToWebcil: avoid doing unncessary conversion, and other work
- [wasm] ManagedToNativeGenerator: add support for incremental runs (time goes from 1.6s to <900ms)

This improves build times ~30% for no-op rebuilds.

*With* native reference | Old | New | Difference | %
-- | -- | -- | -- | --
First build | 8.01s | 8.13s | +0.12s |  
4th rebuild | 1.91s | 1.35s | -0.56s | 29%
rebuild with only cs change | 2.90s | 2.48s | -0.42s | 14%

*Without* native reference | Old | New | Difference | %
-- | -- | -- | -- | --
First build | 5.34s | 5.29 | -0.05s |  
4th rebuild | 1.78s | 1.20s | -0.58s | 32%
rebuild with only cs change | 1.96s | 1.45s | -0.51s | 26%

- These were run for blazor projects
- These were clean builds, with no `dotnet` process running
- And nuget cache cleared of `*webassembly.pack` which is the relevant package here.
- The native reference was a simple `factorial.c` from https://github.com/dotnet/runtime/issues/60245

Fixes https://github.com/dotnet/runtime/issues/60245 .

With feedback from @kg .
src/mono/wasm/Makefile
src/mono/wasm/build/WasmApp.Native.targets
src/mono/wasm/wasm.code-workspace
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs
src/tasks/WasmAppBuilder/EmccCompile.cs
src/tasks/WasmAppBuilder/IcallTableGenerator.cs
src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs
src/tasks/WasmAppBuilder/PInvokeCollector.cs
src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs