Skip to content
Closed
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
1 change: 1 addition & 0 deletions eng/liveILLink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<ItemGroup Condition="'$(_RequiresLiveILLink)' == 'true'">
<!-- The assembly shouldn't be referenced, nor promoted to a package dependency, nor copied to the output directory. -->
<ProjectReference Include="$(_ILLinkTasksSourceDir)ILLink.Tasks.csproj"
Condition="'$(WasmBuildingForNestedPublish)' != 'true'"
ReferenceOutputAssembly="false"
PrivateAssets="all"
Private="false"
Expand Down
10 changes: 8 additions & 2 deletions eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@

So, set those parameters explicitly here.
-->
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'false'">$(_ExtraTrimmerArgs) --substitutions "$(BrowserProjectRoot)build\ILLink.Substitutions.WasmIntrinsics.xml"</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'false'">$(_ExtraTrimmerArgs) --substitutions "$(BrowserProjectRoot)build\ILLink.Substitutions.NoWasmIntrinsics.xml"</_ExtraTrimmerArgs>
<_WasmIntrinsicsSubstitutions Condition="'$(WasmEnableSIMD)' != 'false'">WasmIntrinsics</_WasmIntrinsicsSubstitutions>
<_WasmIntrinsicsSubstitutions Condition="'$(WasmEnableSIMD)' == 'false'">NoWasmIntrinsics</_WasmIntrinsicsSubstitutions>
<!-- WasmEnableSIMD is about native codegen, and CoreCLR browser-wasm forces it on, but the CoreCLR
interpreter maps every System.Runtime.Intrinsics arch intrinsic except get_IsSupported to
PlatformNotSupportedException. Only crossgen'd code can execute them, so without ReadyToRun stubbing
IsSupported to true leaves a guarded SIMD path unconditionally reachable and it throws at startup. -->
<_WasmIntrinsicsSubstitutions Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(PublishReadyToRun)' != 'true'">NoWasmIntrinsics</_WasmIntrinsicsSubstitutions>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --substitutions "$(BrowserProjectRoot)build\ILLink.Substitutions.$(_WasmIntrinsicsSubstitutions).xml"</_ExtraTrimmerArgs>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<TargetFramework>$(NetCoreAppCurrent)-browser</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestRuntime>true</TestRuntime>
<TestTrimming>true</TestTrimming>
<WasmXHarnessArgs>$(WasmXHarnessArgs) --engine-arg=--expose-gc --web-server-use-cop</WasmXHarnessArgs>
<WasmXHarnessMonoArgs>$(WasmXHarnessMonoArgs) --setenv=TZ=Europe/Berlin</WasmXHarnessMonoArgs>
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
Expand All @@ -20,6 +21,15 @@
Suppress the NU1511 warning in the whole project as putting it on a P2P doesn't work: https://github.com/NuGet/Home/issues/14121 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
<WasmEnableStreamingResponse>false</WasmEnableStreamingResponse>

<!-- Remove when PublishReadyToRun becomes default https://github.com/dotnet/runtime/issues/132466 -->
<PublishReadyToRun Condition="'$(PublishReadyToRun)' == '' and '$(RuntimeFlavor)' == 'CoreCLR'">true</PublishReadyToRun>
<!--
<WasmBuildNative>true</WasmBuildNative>
<WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
<WasmNativeStrip>false</WasmNativeStrip>
-->

</PropertyGroup>

<!-- Make debugging easier -->
Expand Down
12 changes: 12 additions & 0 deletions src/libraries/sendtohelix-browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@
<HelixCorrelationPayload Include="$(MonoTargetsTasksDir)" Destination="build/MonoTargetsTasks" />
</ItemGroup>

<!-- CoreCLR ReadyToRun: ship the in-build crossgen2 tool + the wasm-aware Crossgen2Tasks shim so the
Wasm.Build.Tests ReadyToRun opt-in (ReadyToRunTests.GetR2RBuildArgs) resolves them under BASE_DIR
(= HELIX_CORRELATION_PAYLOAD). Until the wasm crossgen2 support flows through the base SDK
(dotnet/sdk#55785), this is how per-app publish R2R gets a wasm crossgen2 on the Helix worker.
Inert when crossgen2 isn't built. -->
<ItemGroup Condition="'$(NeedsEMSDK)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR' and Exists('$(Crossgen2InBuildDir)')">
<HelixCorrelationPayload Include="$(Crossgen2InBuildDir)" Destination="coreclr/browser.wasm.$(Configuration)/$(BuildArchitecture)/crossgen2" />
<HelixCorrelationPayload Include="$(ArtifactsBinDir)Crossgen2Tasks\$(TasksConfiguration)\"
Condition="Exists('$(ArtifactsBinDir)Crossgen2Tasks\$(TasksConfiguration)\')"
Destination="Crossgen2Tasks/$(Configuration)" />
</ItemGroup>

<!-- copy node separately only if EMSDK is not being included -->
<ItemGroup Condition="'$(IncludeNodePayload)' == 'true'">
<HelixCorrelationPayload Include="$(EmSdkDirForHelixPayload)node" Destination="build/emsdk-node" />
Expand Down
15 changes: 11 additions & 4 deletions src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,18 @@
</PropertyGroup>
</Target>

<!-- The relink triggers below must not depend solely on the bare-RID IsBrowserWasmProject: a Blazor app
leaves it unset because it resolves the wasm RID late (dotnet/runtime#133185), so WasmBuildNative=true
becomes a silent no-op there. This file is imported only for CoreCLR browser-wasm apps (Sdk.targets,
UseMonoRuntime==false), so an explicit WasmBuildNative=true is a reliable relink signal regardless of
RID timing. Kept as an OR so IsBrowserWasmProject (which also steers ICU/tzdata skipping and R2R
staging) is never forced on. -->

<!-- Build entry point: runs after Build. The inner _CoreCLRWasmBuildAppCore is
gated on WasmBuildNative='true', so when no relink is needed this is a no-op. -->
<Target Name="WasmBuildApp"
AfterTargets="$(WasmBuildAppAfterThisTarget)"
Condition="'$(IsBrowserWasmProject)' == 'true' and
Condition="('$(IsBrowserWasmProject)' == 'true' or '$(WasmBuildNative)' == 'true') and
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(WasmBuildOnlyAfterPublish)' != 'true' and
'$(IsCrossTargetingBuild)' != 'true'"
Expand All @@ -234,7 +241,7 @@
<!-- Publish entry point: triggers nested publish for browser-wasm projects -->
<Target Name="WasmTriggerPublishApp"
AfterTargets="$(WasmTriggerPublishAppAfterThisTarget)"
Condition="'$(IsBrowserWasmProject)' == 'true' and
Condition="('$(IsBrowserWasmProject)' == 'true' or '$(WasmBuildNative)' == 'true') and
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(IsCrossTargetingBuild)' != 'true'">
<!-- Use a unique property, so the already run wasm targets can also run -->
Expand Down Expand Up @@ -277,7 +284,7 @@
<Target Name="_CoreCLRWasmNativeForBuild"
DependsOnTargets="WasmBuildApp"
BeforeTargets="_ComputeWasmBuildCandidates;_ResolveWasmOutputs"
Condition="'$(IsBrowserWasmProject)' == 'true' and
Condition="('$(IsBrowserWasmProject)' == 'true' or '$(WasmBuildNative)' == 'true') and
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(WasmBuildOnlyAfterPublish)' != 'true' and
'$(IsCrossTargetingBuild)' != 'true' and
Expand All @@ -291,7 +298,7 @@
<Target Name="_CoreCLRWasmNative"
DependsOnTargets="WasmTriggerPublishApp"
BeforeTargets="ProcessPublishFilesForWasm"
Condition="'$(IsBrowserWasmProject)' == 'true' and
Condition="('$(IsBrowserWasmProject)' == 'true' or '$(WasmBuildNative)' == 'true') and
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(UsingBrowserRuntimeWorkload)' != 'true'" />

Expand Down
8 changes: 0 additions & 8 deletions src/mono/browser/build/WasmApp.InTree.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
<UseMonoRuntime>true</UseMonoRuntime>
</PropertyGroup>

<!-- In-tree R2R uses the in-build crossgen2. These two hooks must be props-time (property defaults live
in the CoreCLR .targets); both are inert unless PublishReadyToRun. See dotnet/runtime#121257. -->
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(TargetOS)' == 'browser'">
<AfterMicrosoftNETSdkTargets Condition="'$(Crossgen2SdkOverrideTargetsPath)' != '' and Exists('$(Crossgen2SdkOverrideTargetsPath)')">$(AfterMicrosoftNETSdkTargets);$(Crossgen2SdkOverrideTargetsPath)</AfterMicrosoftNETSdkTargets>
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)WasmApp.ReadyToRun.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
<Import Project="$(Crossgen2SdkOverridePropsPath)"
Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(TargetOS)' == 'browser' and '$(Crossgen2SdkOverridePropsPath)' != '' and Exists('$(Crossgen2SdkOverridePropsPath)')" />

<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsOutputTypeLibrary)' == 'true'">
<OutputType>library</OutputType>
Expand Down
18 changes: 0 additions & 18 deletions src/mono/browser/build/WasmApp.ReadyToRun.targets

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
***********************************************************************************************
Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.ReadyToRun.targets

ReadyToRun compiler override for CoreCLR browser-wasm. See dotnet/runtime#121257.

Appended to AfterMicrosoftNETSdkTargets by Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.props (only when
Crossgen2InBuildDir is set), so it imports after Microsoft.NET.Publish.targets and its ResolveReadyToRunCompilers
wins (MSBuild last-definition-wins). Mirrors AppleBuild.ReadyToRun.targets.

The raw in-build crossgen2 directory ($(Crossgen2InBuildDir)) has crossgen2 at its root; the shipped
Microsoft.NETCore.App.Crossgen2.<hostRid> pack has it under tools/ (both carry clrjit_universal_wasm next to
crossgen2, which crossgen2 auto-loads when targeting wasm). This override probes both and sets the Crossgen2Tool
item directly, because the base SDK / Crossgen2Tasks pack resolver keys on ResolvedCrossgen2Pack, which a
standalone SDK app doesn't populate for a local build. Once the crossgen2 pack flows as a real restorable package
(so ResolvedCrossgen2Pack is set), this override can be retired in favour of it. Inert for normal consumers (no
Crossgen2InBuildDir).

Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project>
<Target Name="ResolveReadyToRunCompilers"
Condition="'$(PublishReadyToRun)' == 'true' and '$(Crossgen2InBuildDir)' != '' and Exists('$(Crossgen2InBuildDir)')"
DependsOnTargets="$(ResolveReadyToRunCompilersDependsOn)">
<PropertyGroup>
<_WasmCrossgen2ExeSuffix Condition="'$(ExeSuffix)' != ''">$(ExeSuffix)</_WasmCrossgen2ExeSuffix>
<_WasmCrossgen2ExeSuffix Condition="'$(_WasmCrossgen2ExeSuffix)' == '' and $([MSBuild]::IsOSPlatform('windows'))">.exe</_WasmCrossgen2ExeSuffix>
<!-- Accept both layouts: the raw in-build dir has crossgen2 at its root; the shipped
Microsoft.NETCore.App.Crossgen2.<hostRid> pack (dotnet/runtime#132466 G2) has it under tools/.
Probing both lets Crossgen2InBuildDir point at either the in-build dir or the pack root. -->
<_WasmCrossgen2RootExe>$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(_WasmCrossgen2ExeSuffix)'))</_WasmCrossgen2RootExe>
<_WasmCrossgen2ToolsExe>$([MSBuild]::NormalizePath('$([MSBuild]::NormalizeDirectory('$(Crossgen2InBuildDir)', 'tools'))', 'crossgen2$(_WasmCrossgen2ExeSuffix)'))</_WasmCrossgen2ToolsExe>
<Crossgen2Path Condition="Exists('$(_WasmCrossgen2RootExe)')">$(_WasmCrossgen2RootExe)</Crossgen2Path>
<Crossgen2Path Condition="'$(Crossgen2Path)' == '' and Exists('$(_WasmCrossgen2ToolsExe)')">$(_WasmCrossgen2ToolsExe)</Crossgen2Path>
<Crossgen2Path Condition="'$(Crossgen2Path)' == ''">$(_WasmCrossgen2RootExe)</Crossgen2Path>
<!-- Directory of the resolved crossgen2, so _WasmCoreClrConservativeR2RInputs (G9) can add the wasm JIT
crossgen2 auto-loads to the R2R inputs. -->
<_WasmResolvedCrossgen2Dir>$([MSBuild]::EnsureTrailingSlash($([System.IO.Path]::GetDirectoryName('$(Crossgen2Path)'))))</_WasmResolvedCrossgen2Dir>
<!-- RunReadyToRunCompiler (NETSDK1158) requires non-empty TargetOS/TargetArch on the Crossgen2Tool item
when JitPath is unset (crossgen2 then auto-loads its own clrjit_universal_wasm). In-tree builds set
$(TargetOS)/$(TargetArchitecture); a standalone SDK app does not. -->
<_WasmR2RTargetOS Condition="'$(TargetOS)' != ''">$(TargetOS)</_WasmR2RTargetOS>
<_WasmR2RTargetOS Condition="'$(_WasmR2RTargetOS)' == ''">browser</_WasmR2RTargetOS>
<_WasmR2RTargetArch Condition="'$(TargetArchitecture)' != ''">$(TargetArchitecture)</_WasmR2RTargetArch>
<_WasmR2RTargetArch Condition="'$(_WasmR2RTargetArch)' == ''">wasm</_WasmR2RTargetArch>
</PropertyGroup>

<ItemGroup>
<Crossgen2Tool Include="$(Crossgen2Path)"
TargetArch="$(_WasmR2RTargetArch)"
TargetOS="$(_WasmR2RTargetOS)"
PerfmapFormatVersion="$(PublishReadyToRunPerfmapFormatVersion)" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
***********************************************************************************************
Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.props

CoreCLR browser-wasm ReadyToRun wiring, isolated from Mono. Imported (props-time) from
Microsoft.NET.Sdk.WebAssembly.Browser.props only when an in-build crossgen2 is provided:
in-tree via eng/liveBuilds.targets; Wasm.Build.Tests / samples via -p:Crossgen2InBuildDir.

The base SDK's ReadyToRun pipeline predates wasm support (dotnet/sdk#55785) and its
PrepareForReadyToRunCompilation emits composite images for wasm (composite strips the assembly manifest
=> the runtime fails coreclr_initialize with 0x80131018). So activate the runtime's wasm-aware
Crossgen2Tasks shim (non-composite per-assembly R2R) and the ResolveReadyToRunCompilers override, both
appended to AfterMicrosoftNETSdkTargets (evaluated after Microsoft.NET.Publish.targets), shim first so the
override wins. Mirrors src/mono/msbuild/apple/build/AppleBuild.props. See dotnet/runtime#121257.

Inert for Mono (no crossgen2) and for normal consumers (no Crossgen2InBuildDir), which resolve crossgen2
through the base SDK once a wasm crossgen2 pack ships.

Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project>
<Import Project="$(Crossgen2SdkOverridePropsPath)"
Condition="'$(Crossgen2SdkOverridePropsPath)' != '' and Exists('$(Crossgen2SdkOverridePropsPath)')" />

<PropertyGroup>
<AfterMicrosoftNETSdkTargets Condition="'$(Crossgen2SdkOverrideTargetsPath)' != '' and Exists('$(Crossgen2SdkOverrideTargetsPath)')">$(AfterMicrosoftNETSdkTargets);$(Crossgen2SdkOverrideTargetsPath)</AfterMicrosoftNETSdkTargets>
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.ReadyToRun.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project>
Loading
Loading