Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions eng/pipelines/common/templates/browser-wasm-build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ parameters:
platforms: []
shouldContinueOnError: false
extraBuildArgs: ''
# The wasm-tools workload manifest includes the CoreCLR browser-wasm runtime pack, so
# installing the workload for testing requires that pack in the local feed. Only pipelines
# that build the CoreCLR browser-wasm runtime (e.g. runtime.yml) can stage it here.
includeCoreClrRuntimePack: false

jobs:

Expand Down Expand Up @@ -44,9 +48,13 @@ jobs:
- ${{ if eq(platform, 'browser_wasm') }}:
- build_browser_wasm_linux_Release_MultiThreaded_BuildOnly
- build_browser_wasm_linux_Release_SingleThreaded_BuildOnly
- ${{ if eq(parameters.includeCoreClrRuntimePack, true) }}:
- build_browser_wasm_linux_Release_CoreCLR
- ${{ if eq(platform, 'browser_wasm_win') }}:
- build_browser_wasm_windows_Release_MultiThreaded_BuildOnly
- build_browser_wasm_windows_Release_SingleThreaded_BuildOnly
- ${{ if eq(parameters.includeCoreClrRuntimePack, true) }}:
- build_browser_wasm_windows_Release_CoreCLR
isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }}
testGroup: innerloop
nameSuffix: WasmBuildTests
Expand Down Expand Up @@ -85,6 +93,26 @@ jobs:
TargetFolder: '$(Build.SourcesDirectory)/artifacts'
CleanTargetFolder: false

# Download the CoreCLR runtime pack. The wasm-tools workload manifest now includes
# the CoreCLR browser-wasm runtime pack, so installing the workload for testing
# requires the pack to be present in the local package feed.
- ${{ if eq(parameters.includeCoreClrRuntimePack, true) }}:
- task: DownloadBuildArtifacts@0
displayName: Download built nugets for CoreCLR runtime
inputs:
buildType: current
artifactName: BuildArtifacts_browser_wasm_$(_hostedOs)_Release_CoreCLR
downloadType: single
downloadPath: '$(Build.SourcesDirectory)/artifacts'

- task: CopyFiles@2
displayName: Copy CoreCLR runtime pack
inputs:
SourceFolder: '$(Build.SourcesDirectory)/artifacts/BuildArtifacts_browser_wasm_$(_hostedOs)_Release_CoreCLR'
Contents: packages/$(_BuildConfig)/Shipping/Microsoft.NETCore.App.Runtime.browser-wasm.*
TargetFolder: '$(Build.SourcesDirectory)/artifacts'
CleanTargetFolder: false

# Download WBT
- task: DownloadBuildArtifacts@0
displayName: Download Wasm.Build.Tests
Expand Down
28 changes: 28 additions & 0 deletions eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,41 @@ jobs:
publishArtifactsForWorkload: true
publishWBT: false

# Release build of browser wasm for CoreCLR. Only stages the CoreCLR runtime pack
# (BuildArtifacts_browser_wasm_<os>_Release_CoreCLR) that the wasm-tools workload
# install in the Wasm.Build.Tests job below requires.
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: Release
platforms:
- browser_wasm
- browser_wasm_win
jobParameters:
nameSuffix: CoreCLR
buildArgs: -s clr+libs+packs -c Release -rc $(_BuildConfig) /p:TestAssemblies=false /p:InstallWorkloadForTesting=false
timeoutInMinutes: 120
postBuildSteps:
- template: /eng/pipelines/common/wasm-post-build-steps.yml
parameters:
publishArtifactsForWorkload: true
publishWBT: false
extraVariablesTemplates:
- template: /eng/pipelines/common/templates/runtimes/test-variables.yml
parameters:
testGroup: innerloop
liveLibrariesBuildConfig: Release

# Browser Wasm.Build.Tests
- template: /eng/pipelines/common/templates/browser-wasm-build-tests.yml
parameters:
platforms:
- browser_wasm
- browser_wasm_win
extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
# The CoreCLR build-only job above stages the CoreCLR runtime pack for the
# wasm-tools workload install.
includeCoreClrRuntimePack: true

- template: /eng/pipelines/common/templates/simple-wasm-build-tests.yml
parameters:
Expand Down
3 changes: 3 additions & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@ extends:
- browser_wasm_win
alwaysRun: ${{ variables.isRollingBuild }}
extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
# This pipeline builds the CoreCLR browser-wasm runtime (nameSuffix: CoreCLR),
# so stage its runtime pack for the wasm-tools workload install.
includeCoreClrRuntimePack: true

# Wasm runtime tests
- template: /eng/pipelines/common/templates/wasm-runtime-tests.yml
Expand Down
76 changes: 70 additions & 6 deletions src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@
<WasmEnvironmentVariable Condition="'$(_WasmPerfInstInterval)' != ''" Include="DOTNET_EventPipeThreadSamplingRate" Value="$(_WasmPerfInstInterval)" />
</ItemGroup>

<!-- Import shared native.wasm.targets for Emscripten SDK, ICU, exported functions/methods -->
<Import Project="$(RepositoryEngineeringDir)native.wasm.targets" />

<!-- Derive Emscripten paths from EMSDK_PATH when workload paths are not set -->
<Import Project="$(MSBuildThisFileDirectory)EmSdkRepo.Defaults.props"
Condition="'$(EMSDK_PATH)' != '' and '$(EmscriptenSdkToolsPath)' == ''" />
Expand All @@ -92,6 +89,63 @@
TaskFactory="TaskHostFactory"
Condition="'$(WasmAppBuilderTasksAssemblyPath)' != ''" />

<!-- Fallback exported runtime methods and functions for the emcc link step.
Used when the workload path is active and native.wasm.targets is not available.
TODO-WASM https://github.com/dotnet/runtime/issues/126100#issuecomment-4925516500: Keep this list in sync with eng/native.wasm.targets.
When building in-tree, native.wasm.targets is imported AFTER this target (below)
and its GenerateEmccExports definition wins (MSBuild last-definition-wins). -->
<Target Name="GenerateEmccExports"
Condition="'$(TargetsBrowser)' == 'true'">
Comment thread
pavelsavara marked this conversation as resolved.
<ItemGroup>
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="HEAP8" />
<EmccExportedRuntimeMethod Include="HEAP16" />
<EmccExportedRuntimeMethod Include="HEAPU8" />
<EmccExportedRuntimeMethod Include="HEAPU16" />
<EmccExportedRuntimeMethod Include="HEAP32" />
<EmccExportedRuntimeMethod Include="HEAPU32" />
<EmccExportedRuntimeMethod Include="HEAPF32" />
<EmccExportedRuntimeMethod Include="HEAPF64" />
<EmccExportedRuntimeMethod Include="HEAP64" />
<EmccExportedRuntimeMethod Include="HEAPU64" />
<EmccExportedRuntimeMethod Include="out" />
<EmccExportedRuntimeMethod Include="err" />
<EmccExportedRuntimeMethod Include="ccall" />
<EmccExportedRuntimeMethod Include="cwrap" />
<EmccExportedRuntimeMethod Include="setValue" />
<EmccExportedRuntimeMethod Include="getValue" />
<EmccExportedRuntimeMethod Include="UTF8ToString" />
<EmccExportedRuntimeMethod Include="UTF8ArrayToString" />
<EmccExportedRuntimeMethod Include="lengthBytesUTF8" />
<EmccExportedRuntimeMethod Include="stringToUTF8Array" />
<EmccExportedRuntimeMethod Include="safeSetTimeout" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePush" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePop" />
<EmccExportedRuntimeMethod Include="abort" />

<EmccExportedFunction Include="_free" />
<EmccExportedFunction Include="_htons" />
<EmccExportedFunction Include="_malloc" />
<EmccExportedFunction Include="_sbrk" />
<EmccExportedFunction Include="_memalign" />
<EmccExportedFunction Include="_posix_memalign" />
<EmccExportedFunction Include="_memset" />
<EmccExportedFunction Include="_ntohs" />
<EmccExportedFunction Include="stackAlloc" />
<EmccExportedFunction Include="stackRestore" />
<EmccExportedFunction Include="stackSave" />
<EmccExportedFunction Include="___stack_pointer" />
<EmccExportedFunction Include="___coreclr_wasm_rtlrestorecontext_tag" />
</ItemGroup>
</Target>

<!-- Import shared native.wasm.targets for Emscripten SDK, ICU, exported functions/methods.
Only available in-tree (RepositoryEngineeringDir is set by the build system).
When present its GenerateEmccExports target overrides the fallback above
(MSBuild last-definition-wins), so the in-tree list is always authoritative. -->
<Import Project="$(RepositoryEngineeringDir)native.wasm.targets"
Condition="'$(RepositoryEngineeringDir)' != '' and Exists('$(RepositoryEngineeringDir)native.wasm.targets')" />

<!-- Allow running/debugging from VS -->
<ItemGroup>
<ProjectCapability Include="DotNetCoreWeb"/>
Expand Down Expand Up @@ -177,7 +231,7 @@
served binary would be the original (runtime pack) dotnet.native.wasm. -->
<Target Name="_CoreCLRWasmNativeForBuild"
DependsOnTargets="WasmBuildApp"
BeforeTargets="_ResolveWasmOutputs"
BeforeTargets="_ComputeWasmBuildCandidates;_ResolveWasmOutputs"
Condition="'$(IsBrowserWasmProject)' == 'true' and
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(WasmBuildOnlyAfterPublish)' != 'true' and
Expand Down Expand Up @@ -232,7 +286,7 @@
_GatherWasmFilesToBuild (unlike _ComputeWasmBuildCandidates) does not pull it in on its own.
-->
<Target Name="_CoreCLRResolveRuntimePackVsAppLocalConflicts"
BeforeTargets="_ComputeWasmBuildCandidates;_GatherWasmFilesToBuild"
BeforeTargets="_ComputeWasmBuildCandidates;_GatherWasmFilesToBuild;_CoreCLRGatherWasmFiles"
DependsOnTargets="ResolveReferences"
Condition="'$(IsBrowserWasmProject)' == 'true'">
<PropertyGroup>
Expand Down Expand Up @@ -318,7 +372,7 @@
<_CoreCLRWasmBuildAppCoreDependsOn>
_CoreCLRWasmInitialize;
_CoreCLRSetupEmscripten;
_GatherWasmFilesToBuild;
_CoreCLRGatherWasmFiles;
_CoreCLRPrepareForNativeBuild;
_CoreCLRGenerateManagedToNative;
_CoreCLRWriteCompileRsp;
Expand All @@ -334,6 +388,16 @@
Condition="'$(WasmBuildNative)' == 'true'"
DependsOnTargets="$(_CoreCLRWasmBuildAppCoreDependsOn)" />

<!-- During a nested publish, _GatherWasmFilesToPublish already populated
WasmAssembliesToBundle from ResolvedFileToPublish (which includes app
satellite assemblies). Calling _GatherWasmFilesToBuild would overwrite
that list with build-time items (IntermediateAssembly + ReferenceCopyLocalPaths)
which omit app satellites, causing ComputeWasmPublishAssets to fail.
Only call the SDK's _GatherWasmFilesToBuild for non-publish builds. -->
<Target Name="_CoreCLRGatherWasmFiles"
DependsOnTargets="_GatherWasmFilesToBuild"
Condition="'$(WasmBuildingForNestedPublish)' != 'true'" />

<!-- ======================== Initialize ======================== -->

<Target Name="_CoreCLRWasmInitialize">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<PackageFile Include="$(BrowserProjectRoot)build\BrowserWasmApp.props" TargetPath="Sdk" />
<PackageFile Include="$(BrowserProjectRoot)build\BrowserWasmApp.targets" TargetPath="Sdk" />
<PackageFile Include="$(BrowserProjectRoot)build\BrowserWasmApp.CoreCLR.targets" TargetPath="Sdk" />

<PackageFile Include="$(WasmProjectRoot)build\WasmApp.Common.props" TargetPath="Sdk" />
<PackageFile Include="$(WasmProjectRoot)build\WasmApp.Common.targets" TargetPath="Sdk" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)\BrowserWasmApp.props" />
<Import Project="$(MSBuildThisFileDirectory)\BrowserWasmApp.targets" />
<Import Project="$(MSBuildThisFileDirectory)\BrowserWasmApp.targets" Condition="'$(UseMonoRuntime)' != 'false'" />
<Import Project="$(MSBuildThisFileDirectory)\BrowserWasmApp.CoreCLR.targets" Condition="'$(UseMonoRuntime)' == 'false'" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Microsoft.NET.Runtime.WebAssembly.Sdk.${NetVersion}",
"Microsoft.NET.Sdk.WebAssembly.Pack.${NetVersion}",
"Microsoft.NETCore.App.Runtime.Mono.${NetVersion}.browser-wasm",
"Microsoft.NETCore.App.Runtime.${NetVersion}.browser-wasm",
"Microsoft.NETCore.App.Runtime.AOT.Cross.${NetVersion}.browser-wasm"
],
"extends": [ "microsoft-net-runtime-mono-tooling", "microsoft-net-sdk-emscripten" ],
Expand Down Expand Up @@ -458,6 +459,13 @@
"any": "Microsoft.NETCore.App.Runtime.Mono.browser-wasm"
}
},
"Microsoft.NETCore.App.Runtime.${NetVersion}.browser-wasm" : {
"kind": "framework",
"version": "${PackageVersion}",
"alias-to": {
"any": "Microsoft.NETCore.App.Runtime.browser-wasm"
}
},
"Microsoft.NETCore.App.Runtime.Mono.multithread.${NetVersion}.browser-wasm" : {
"kind": "framework",
"version": "${PackageVersion}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@

<!-- start of TFM specific logic, make sure every node has a TargetsCurrent/TargetsNet* condition -->

<Import Condition="'$(TargetsCurrent)' == 'true' and '$(RunAOTCompilation)' == 'true' and ('$(UsingBrowserRuntimeWorkload)' == 'true' or '$(UsingMobileWorkload)' == 'true' or '$(UsingWasiRuntimeWorkload)' == 'true')" Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task.${NetVersion}" />
<Import Condition="'$(TargetsCurrent)' == 'true' and '$(RunAOTCompilation)' == 'true' and '$(UseMonoRuntime)' != 'false' and ('$(UsingBrowserRuntimeWorkload)' == 'true' or '$(UsingMobileWorkload)' == 'true' or '$(UsingWasiRuntimeWorkload)' == 'true')" Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task.${NetVersion}" />

<ImportGroup Condition="'$(TargetsCurrent)' == 'true' and ('$(TargetPlatformIdentifier)' == 'android' or '$(_IsAndroidLibraryMode)' == 'true')">
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoTargets.Sdk.${NetVersion}" />
Expand Down Expand Up @@ -204,14 +204,22 @@
<Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.${NetVersion}.tvossimulator-x64" />
</ImportGroup>

<ImportGroup Condition="'$(TargetsCurrent)' == 'true' and '$(RuntimeIdentifier)' == 'browser-wasm' and '$(UsingBrowserRuntimeWorkload)' == 'true'">
<ImportGroup Condition="'$(TargetsCurrent)' == 'true' and '$(RuntimeIdentifier)' == 'browser-wasm' and '$(UsingBrowserRuntimeWorkload)' == 'true' and '$(UseMonoRuntime)' != 'false'">
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoTargets.Sdk.${NetVersion}" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.WebAssembly.Sdk.${NetVersion}" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Runtime.WebAssembly.Sdk.${NetVersion}" />
<Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.${NetVersion}.browser-wasm" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Runtime.MonoTargets.Sdk.${NetVersion}" />
</ImportGroup>

<!-- CoreCLR browser-wasm: only needs the WebAssembly.Sdk (build targets + emscripten).
No MonoTargets.Sdk, no MonoAOTCompiler, no AOT.Cross pack — the SDK resolves
the CoreCLR runtime pack and crossgen2 via its own KnownRuntimePack/KnownCrossgen2Pack. -->
<ImportGroup Condition="'$(TargetsCurrent)' == 'true' and '$(RuntimeIdentifier)' == 'browser-wasm' and '$(UsingBrowserRuntimeWorkload)' == 'true' and '$(UseMonoRuntime)' == 'false'">
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.WebAssembly.Sdk.${NetVersion}" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Runtime.WebAssembly.Sdk.${NetVersion}" />
</ImportGroup>

<ImportGroup Condition="'$(TargetsCurrent)' == 'true' and '$(RuntimeIdentifier)' == 'wasi-wasm' and '$(UsingWasiRuntimeWorkload)' == 'true'">
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoTargets.Sdk.${NetVersion}" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk.${NetVersion}" />
Expand Down