Skip to content

Commit 5263848

Browse files
steveisokakoeplingerradekdouliklewing
authored
[wasm] Use source built emsdk packages for the runtime build (#100266)
* Use the emsdk transport packages to build wasm instead of a cloned emsdk Works for the most part out of the box, but fails on the part where we npm install after the libraries build. The reason for the failure is our node transport package is incomplete. If you replace it with a legit node, the build works fully. * Pull in node transport package as opposed to the one packaged in emsdk. Streamline package deps * Make paths friendly for windows * Work in windows transport packages, copy python to its own directory, and adjust a bunch of paths * Bump to latest version of node that contains icu * Add windows deps and add DOTNET_EMSCRIPTEN_NODE_PATH because windows can't see npm without it * Bump emscripten packages to the latest * Fix typos in Version.Details.xml * Switch out to the plain mariner container to ensure no EMSDK already exists * Revert back to the browser-wasm docker image and bump to the latest * Container type-o * Fix condition where the node path isn't set properly * Provision even when building offsets * Fix goofy paths * Update new template to use the latest browser-wasm container * Don't put python.exe on the path for windows, but the folder instead * So that was a bad idea. May have to have emsdk_env.cmd have two entries * Fix offsets generation for browser * Fix emsdk's python path It is not versioned anymore as we use the content of our nugets * Fix EMSDK_PATH on non-windows platforms * Do not add link flags to compile flags To avoid: C:\helix\work\correlation\build\wasm-shared\WasmApp.Common.targets(825,5): error : emcc: warning: linker setting ignored during compilation: 'EXPORT_ES6' [-Wunused-command-line-argument] [C:\helix\work\workitem\e\publish\ProxyProjectForAOTOnHelix.proj] C:\helix\work\correlation\build\wasm-shared\WasmApp.Common.targets(825,5): error : emcc: warning: linker setting ignored during compilation: 'EXPORT_EXCEPTION_HANDLING_HELPERS' [-Wunused-command-line-argument] [C:\helix\work\workitem\e\publish\ProxyProjectForAOTOnHelix.proj] * Set the emsdk paths relative to the script location * Escape few characters and fix the added script * Fix .emscripten script * Use EM_CONFIG intead of __file__ * Fix emsdk_env.cmd script * Revert "Do not add link flags to compile flags" This reverts commit eb19ade. * Revert changes in package-lock.json * Feedback + cleaning * More cleaning * Try not to use the replace in the EMSDK_PATH * Better property names * Use package and emsdk version properties Co-authored-by: Larry Ewing <[email protected]> * Use the updated properties * Fix emsdk version * Use a single version of emsdk and take node version from flow * Update eng/Version.Details.xml Co-authored-by: Larry Ewing <[email protected]> --------- Co-authored-by: Alexander Köplinger <[email protected]> Co-authored-by: Radek Doulik <[email protected]> Co-authored-by: Radek Doulik <[email protected]> Co-authored-by: Larry Ewing <[email protected]>
1 parent 02e348b commit 5263848

File tree

12 files changed

+199
-45
lines changed

12 files changed

+199
-45
lines changed

eng/Version.Details.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,5 +414,37 @@
414414
<Uri>https://github.com/dotnet/installer</Uri>
415415
<Sha>fa261b952d702c6bd604728fcbdb58ac071a22b1</Sha>
416416
</Dependency>
417+
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
418+
<Uri>https://github.com/dotnet/node</Uri>
419+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
420+
</Dependency>
421+
<Dependency Name="runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
422+
<Uri>https://github.com/dotnet/node</Uri>
423+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
424+
</Dependency>
425+
<Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
426+
<Uri>https://github.com/dotnet/node</Uri>
427+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
428+
</Dependency>
429+
<Dependency Name="runtime.linux-musl-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
430+
<Uri>https://github.com/dotnet/node</Uri>
431+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
432+
</Dependency>
433+
<Dependency Name="runtime.osx-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
434+
<Uri>https://github.com/dotnet/node</Uri>
435+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
436+
</Dependency>
437+
<Dependency Name="runtime.osx-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
438+
<Uri>https://github.com/dotnet/node</Uri>
439+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
440+
</Dependency>
441+
<Dependency Name="runtime.win-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
442+
<Uri>https://github.com/dotnet/node</Uri>
443+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
444+
</Dependency>
445+
<Dependency Name="runtime.win-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
446+
<Uri>https://github.com/dotnet/node</Uri>
447+
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
448+
</Dependency>
417449
</ToolsetDependencies>
418450
</Dependencies>

eng/Versions.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,9 @@
256256
<!-- installer version, for testing workloads -->
257257
<MicrosoftDotnetSdkInternalVersion>9.0.100-preview.5.24253.16</MicrosoftDotnetSdkInternalVersion>
258258
<SdkVersionForWorkloadTesting>$(MicrosoftDotnetSdkInternalVersion)</SdkVersionForWorkloadTesting>
259+
<runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion>9.0.0-alpha.1.24175.1</runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion>
260+
<EmsdkPackageVersion>$(MicrosoftNETRuntimeEmscriptenVersion)</EmsdkPackageVersion>
261+
<NodePackageVersion>$(runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion)</NodePackageVersion>
262+
<EmsdkVersion>3.1.34</EmsdkVersion>
259263
</PropertyGroup>
260264
</Project>

eng/native/gen-buildsys.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if /i "%__Arch%" == "wasm" (
5656
set "EMSDK_PATH=!EMSDK_PATH:\=/!"
5757
if not "!EMSDK_PATH:~-1!" == "/" set "EMSDK_PATH=!EMSDK_PATH!/"
5858

59-
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
59+
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/emscripten/cmake/Modules/Platform/Emscripten.cmake"
6060
set __UseEmcmake=1
6161
)
6262
if /i "%__Os%" == "wasi" (
@@ -107,7 +107,7 @@ if not "%__ConfigureOnly%" == "1" (
107107
)
108108

109109
if /i "%__UseEmcmake%" == "1" (
110-
call "!EMSDK_PATH!/emsdk_env.bat" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
110+
call "!EMSDK_PATH!/emsdk_env.cmd" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
111111
) else (
112112
"%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
113113
)

eng/pipelines/common/templates/pipeline-with-resources.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ extends:
100100
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8
101101

102102
browser_wasm:
103-
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-webassembly-20230913040940-1edc1c6
103+
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-webassembly
104104
env:
105105
ROOTFS_DIR: /crossrootfs/x64
106106

src/libraries/sendtohelix-browser.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
<IncludeHelixCorrelationPayload>false</IncludeHelixCorrelationPayload>
5353
<EnableDefaultBuildHelixWorkItems>false</EnableDefaultBuildHelixWorkItems>
5454

55-
<!-- on unix CI has emscripten provisioned in $(EMSDK_PATH) as `/usr/local/emscripten`. -->
56-
<EMSDK_PATH Condition="$([MSBuild]::IsOSPlatform('WINDOWS')) and '$(EMSDK_PATH)' == ''">$(RepoRoot)src\mono\browser\emsdk\</EMSDK_PATH>
55+
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == ''">$([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'browser', 'emsdk'))</EMSDK_PATH>
5756
<EmSdkDirForHelixPayload>$(HelixDependenciesStagingPath)\emsdk</EmSdkDirForHelixPayload>
5857
<DebuggerHost Condition="'$(DebuggerHost)' == ''">chrome</DebuggerHost>
5958

src/mono/browser/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ build-app-host:
167167
$(DOTNET) build $(TOP)/src/mono/wasm/host $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS)
168168

169169
patch-deterministic:
170-
cd emsdk/upstream/emscripten/ && patch -p1 < ../../../runtime/deterministic.diff
170+
cd emsdk/emscripten/ && patch -p1 < ../../../runtime/deterministic.diff

src/mono/browser/browser.proj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<_EmccDefaultsRspPath>$(NativeBinDir)src\emcc-default.rsp</_EmccDefaultsRspPath>
3434
<_EmccCompileRspPath>$(NativeBinDir)src\emcc-compile.rsp</_EmccCompileRspPath>
3535
<_EmccLinkRspPath>$(NativeBinDir)src\emcc-link.rsp</_EmccLinkRspPath>
36-
<EmSdkLLVMAr>$(EMSDK_PATH)\upstream\bin\llvm-ar</EmSdkLLVMAr>
36+
<EmSdkLLVMAr>$(EMSDK_PATH)\bin\llvm-ar</EmSdkLLVMAr>
3737
<EmSdkLLVMAr Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(EmSdkLLVMAr).exe</EmSdkLLVMAr>
3838
</PropertyGroup>
3939

@@ -397,12 +397,12 @@
397397
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableJsInteropByValue)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DENABLE_JS_INTEROP_BY_VALUE=1</CMakeBuildRuntimeConfigureCmd>
398398
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath)</CMakeBuildRuntimeConfigureCmd>
399399

400-
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; $(CMakeBuildRuntimeConfigureCmd)</CMakeBuildRuntimeConfigureCmd>
400+
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.cmd'))&quot; &amp;&amp; $(CMakeBuildRuntimeConfigureCmd)</CMakeBuildRuntimeConfigureCmd>
401401
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' != 'Windows_NT'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&amp;1 &amp;&amp; $(CMakeBuildRuntimeConfigureCmd)'</CMakeBuildRuntimeConfigureCmd>
402402

403403
<CMakeOptions Condition="'$(MonoVerboseBuild)' != ''">-v</CMakeOptions>
404404
<CMakeBuildRuntimeCmd>cmake --build . --config $(Configuration) $(CmakeOptions)</CMakeBuildRuntimeCmd>
405-
<CMakeBuildRuntimeCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; $(CMakeBuildRuntimeCmd)</CMakeBuildRuntimeCmd>
405+
<CMakeBuildRuntimeCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.cmd'))&quot; &amp;&amp; $(CMakeBuildRuntimeCmd)</CMakeBuildRuntimeCmd>
406406
<CMakeBuildRuntimeCmd Condition="'$(OS)' != 'Windows_NT'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&amp;1 &amp;&amp; $(CMakeBuildRuntimeCmd)'</CMakeBuildRuntimeCmd>
407407
</PropertyGroup>
408408
<ItemGroup>

src/mono/browser/build/EmSdkRepo.Defaults.props

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@
44

55
<PropertyGroup>
66
<EmscriptenSdkToolsPath>$([MSBuild]::EnsureTrailingSlash($(EMSDK_PATH)))</EmscriptenSdkToolsPath>
7-
<EmscriptenUpstreamBinPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'bin'))</EmscriptenUpstreamBinPath>
8-
<EmscriptenUpstreamEmscriptenPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'emscripten'))</EmscriptenUpstreamEmscriptenPath>
9-
10-
<_NodeToolsBasePath>$(EmscriptenSdkToolsPath)node</_NodeToolsBasePath>
7+
<EmscriptenUpstreamBinPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'bin'))</EmscriptenUpstreamBinPath>
8+
<EmscriptenUpstreamEmscriptenPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'emscripten'))</EmscriptenUpstreamEmscriptenPath>
119

1210
<!-- gets the path like emsdk/python/3.7.4-2_64bit -->
13-
<_NodeToolsVersionedPath Condition="Exists($(_NodeToolsBasePath))">$([System.IO.Directory]::GetDirectories($(_NodeToolsBasePath)))</_NodeToolsVersionedPath>
14-
<EmscriptenNodeToolsPath Condition="'$(_NodeToolsVersionedPath)' != ''">$(_NodeToolsVersionedPath)</EmscriptenNodeToolsPath>
15-
<EmscriptenNodeToolsPath Condition="'$(EmscriptenNodeToolsPath)' != ''">$([MSBuild]::NormalizeDirectory($(EmscriptenNodeToolsPath)))</EmscriptenNodeToolsPath>
11+
<EmscriptenNodeToolsPath Condition="'$(EmscriptenNodeToolsPath)' == ''">$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'node', 'bin'))</EmscriptenNodeToolsPath>
1612

1713
<_UsingEMSDK_PATH>true</_UsingEMSDK_PATH>
1814
</PropertyGroup>
1915

2016
<!-- Emscripten uses system python on Linux, so we don't need $(EmscriptenPythonToolsPath) -->
2117
<PropertyGroup Condition="!$([MSBuild]::IsOSPlatform('linux'))">
22-
<_PythonToolsBasePath>$(EmscriptenSdkToolsPath)python</_PythonToolsBasePath>
23-
<_PythonToolsVersionedPath Condition="Exists($(_PythonToolsBasePath))">$([System.IO.Directory]::GetDirectories($(_PythonToolsBasePath)))</_PythonToolsVersionedPath>
24-
<EmscriptenPythonToolsPath Condition="'$(_PythonToolsVersionedPath)' != ''">$(_PythonToolsVersionedPath)</EmscriptenPythonToolsPath>
25-
<EmscriptenPythonToolsPath Condition="'$(EmscriptenPythonToolsPath)' != ''">$([MSBuild]::NormalizeDirectory($(EmscriptenPythonToolsPath)))</EmscriptenPythonToolsPath>
18+
<EmscriptenPythonToolsPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath)python))</EmscriptenPythonToolsPath>
2619

2720
<_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenPythonToolsPath)' == '' or !Exists('$(EmscriptenPythonToolsPath)'))">%24(EmscriptenPythonToolsPath)=$(EmscriptenPythonToolsPath) </_EMSDKMissingPaths>
2821
</PropertyGroup>
@@ -31,9 +24,9 @@
3124
<ItemGroup>
3225
<EmscriptenPrependPATH Include="$(EmscriptenSdkToolsPath)" />
3326
<EmscriptenPrependPATH Include="$(EmscriptenUpstreamBinPath)" />
34-
<EmscriptenPrependPATH Include="$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'emscripten'))" />
27+
<EmscriptenPrependPATH Include="$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'emscripten'))" />
3528

36-
<EmscriptenPrependPATH Include="$(EmscriptenNodeToolsPath)bin" />
29+
<EmscriptenPrependPATH Include="$(EmscriptenNodeToolsPath)" />
3730
</ItemGroup>
3831

3932
<ItemGroup Condition="'$(EmscriptenPythonToolsPath)' != ''">

src/mono/browser/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ set(ignoreMeEmsdkPath "${EMSDK_PATH}")
4444

4545
if(CMAKE_BUILD_TYPE STREQUAL "Release")
4646
add_custom_command(TARGET dotnet.native
47-
POST_BUILD COMMAND ${EMSDK_PATH}/upstream/bin/wasm-opt --enable-exception-handling ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm
47+
POST_BUILD COMMAND ${EMSDK_PATH}/bin/wasm-opt --enable-exception-handling ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm
4848
COMMENT "Stripping debug symbols from dotnet.native.wasm using wasm-opt")
4949
endif()
5050

src/mono/browser/sanitize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def rewrite_package_json(path):
3232

3333

3434
emsdk_path = sys.argv[1]
35-
emscripten_path = os.path.join(emsdk_path, "upstream", "emscripten")
35+
emscripten_path = os.path.join(emsdk_path, "emscripten")
3636
node_root = os.path.join(emsdk_path, "node")
3737
node_paths = glob(node_root)
3838
upgrade = True

0 commit comments

Comments
 (0)