Skip to content

Commit f85d370

Browse files
authored
[release/7.0][wasm-mt] Fix pack/build issues in threaded builds (#75171)
* [wasm-mt] Build the threaded CoreLib if MonoWasmBuildVariant is 'multithread' Also define the perf-tracing feature flag for the threaded and perf-tracing build variants. * Also fixup the BCL assemblies * [wasm-mt] look for WasmEnableThreads in user projects not WasmEnabelThreading. Conversely, use `WasmEnablePerfTracing`, not `WasmEnablePerfTrace`. * include dotnet.worker.js in runtime pack * use set "preferDirectoryName" to true in WASM templates * fix whitespace * when updating RuntimePackNamePatterns don't include net7 component The workload resolver already did its job by the time this property is updated, so we need to use patterns that correspond to actual nupkg names (unversioned), not runtime pack alias names from the manifest (versioned with 'net7') * WBT: unset MonoWasmBuildVariant for the non-threaded runtime For local testing if the built runtime is a multithreaded one, make and we need to make the normal variant nuget, unset MonoWasmBuildVariant property * [WorkloadBuildTasks] remove the workload manifest net6/net7 hack Starting with 7.0.100-rc.2.22457.6 we already have the versioned net6/net7 toolchains, so the hack isn't needed anymore (and in fact, breaks workload installation during testing) * also build the JS interop library with threading if variant is used
1 parent a20c82f commit f85d370

File tree

11 files changed

+21
-14
lines changed

11 files changed

+21
-14
lines changed

eng/liveBuilds.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@
187187
$(LibrariesNativeArtifactsPath)dotnet.timezones.blat;
188188
$(LibrariesNativeArtifactsPath)*.dat;"
189189
IsNative="true" />
190+
<!-- for threaded wasm -->
191+
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser' and Exists('$(LibrariesNativeArtifactsPath)dotnet.worker.js')"
192+
Include="
193+
$(LibrariesNativeArtifactsPath)dotnet.worker.js"
194+
IsNative="true" />
190195
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
191196
Include="
192197
$(LibrariesNativeArtifactsPath)src\*.c;

eng/testing/workloads-testing.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<!-- add for non-threaded runtime also -->
172172
<_NuGetsToBuild Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.browser-wasm.$(_PackageVersion).nupkg"
173173
Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj"
174-
Properties="@(_DefaultPropsForNuGetBuild, ';')"
174+
Properties="@(_DefaultPropsForNuGetBuild, ';');MonoWasmBuildVariant="
175175
Dependencies="$(_DefaultRuntimePackNuGetPath)"
176176
Descriptor="single threaded runtime pack"
177177
Condition="'$(_DefaultBuildVariant)' != '.'" />

src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<ItemGroup>
77
<ProjectReference Include="$(CoreLibProject)" />
88
</ItemGroup>
9-
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true'">
9+
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">
1010
<!-- when wasm threading is enabled the implementation in CoreLib won't have the UnsupportedOSAttribute for browser,
1111
but this contract still does since we only expose the wasm threading through System.Diagnostics.Tracing.WebAssembly.PerfTracing
1212
so we need to baseline the ApiCompat errors related to that -->
1313
<ApiCompatBaselineFile Include="ApiCompatBaseline.Tracing.txt" />
1414
</ItemGroup>
15-
</Project>
15+
</Project>

src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<NoWarn>$(NoWarn);0809;0618;CS8614;CS3015</NoWarn>
1111
<StrongNameKeyId>SilverlightPlatform</StrongNameKeyId>
1212
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
13-
<FeatureWasmPerfTracing Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true'">true</FeatureWasmPerfTracing>
14-
<FeatureWasmThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmThreads>
13+
<FeatureWasmPerfTracing Condition="'$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">true</FeatureWasmPerfTracing>
14+
<FeatureWasmThreads Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">true</FeatureWasmThreads>
1515
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
1616
<DefineConstants Condition="'$(FeatureWasmThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_THREADS</DefineConstants>
1717
<DefineConstants>$(DefineConstants);BUILDING_CORELIB_REFERENCE</DefineConstants>
@@ -51,4 +51,4 @@
5151
<!-- types not exposed in contracts but forwarded from the mscorlib shim, this is manually maintained -->
5252
<Compile Include="System.Private.CoreLib.ManualShimTypeForwards.cs" />
5353
</ItemGroup>
54-
</Project>
54+
</Project>

src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<PropertyGroup>
9-
<FeatureWasmThreads Condition="'$(TargetOS)' == 'browser' and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmThreads>
9+
<FeatureWasmThreads Condition="'$(TargetOS)' == 'browser' and ('$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread')">true</FeatureWasmThreads>
1010
</PropertyGroup>
1111

1212
<PropertyGroup>

src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<ProjectReference Include="$(CoreLibProject)" />
99
</ItemGroup>
10-
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true'">
10+
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">
1111
<!-- when wasm threading is enabled the implementation in CoreLib won't have the UnsupportedOSAttribute for browser,
1212
but this contract still does since we only expose the wasm threading through System.Diagnostics.Threading.Thread.WebAssembly.Threading
1313
so we need to baseline the ApiCompat errors related to that -->

src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<ItemGroup>
77
<ProjectReference Include="$(CoreLibProject)" />
88
</ItemGroup>
9-
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true'">
9+
<ItemGroup Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">
1010
<!-- when wasm threading is enabled the implementation in CoreLib won't have the UnsupportedOSAttribute for browser,
1111
but this contract still does since we only expose the wasm threading through System.Diagnostics.Threading.ThreadPool.WebAssembly.Threading
1212
so we need to baseline the ApiCompat errors related to that -->
1313
<ApiCompatBaselineFile Include="ApiCompatBaseline.Threading.txt" />
1414
</ItemGroup>
15-
</Project>
15+
</Project>

src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@
125125
<DefineConstants>$(DefineConstants);MONO_FEATURE_SRE</DefineConstants>
126126

127127
<FeatureMono>true</FeatureMono>
128-
<FeatureWasmThreads Condition="'$(TargetsBrowser)' == 'true' and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmThreads>
129-
<FeatureWasmPerfTracing Condition="'$(TargetsBrowser)' == 'true' and ('$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true')">true</FeatureWasmPerfTracing>
128+
<FeatureWasmThreads Condition="'$(TargetsBrowser)' == 'true' and ('$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread')">true</FeatureWasmThreads>
129+
<FeatureWasmPerfTracing Condition="'$(TargetsBrowser)' == 'true' and ('$(WasmEnableThreads)' == 'true' or '$(WasmEnablePerfTracing)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace')">true</FeatureWasmPerfTracing>
130130
<FeatureManagedEtwChannels>true</FeatureManagedEtwChannels>
131131
<FeatureManagedEtw>true</FeatureManagedEtw>
132132
<FeaturePortableTimer Condition="'$(TargetsBrowser)' != 'true'">true</FeaturePortableTimer>

src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.net7.Manifest/WorkloadManifest.targets.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
<KnownRuntimePack Update="@(KnownRuntimePack)">
104104
<LatestRuntimeFrameworkVersion Condition="'%(KnownRuntimePack.TargetFramework)' == 'net7.0' and '%(KnownRuntimePack.RuntimePackLabels)' == 'Mono'">$(_MonoWorkloadRuntimePackPackageVersion)</LatestRuntimeFrameworkVersion>
105105
<!-- Overrides for wasm threading support -->
106-
<RuntimePackNamePatterns Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(WasmEnableThreading)' == 'true'">Microsoft.NETCore.App.Runtime.Mono.multithread.net7.**RID**</RuntimePackNamePatterns>
107-
<RuntimePackNamePatterns Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(WasmEnablePerfTrace)' == 'true'">Microsoft.NETCore.App.Runtime.Mono.perftrace.net7.**RID**</RuntimePackNamePatterns>
106+
<RuntimePackNamePatterns Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(WasmEnableThreads)' == 'true'">Microsoft.NETCore.App.Runtime.Mono.multithread.**RID**</RuntimePackNamePatterns>
107+
<RuntimePackNamePatterns Condition="'$(RuntimeIdentifier)' == 'browser-wasm' and '$(WasmEnablePerfTracing)' == 'true'">Microsoft.NETCore.App.Runtime.Mono.perftrace.**RID**</RuntimePackNamePatterns>
108108
</KnownRuntimePack>
109109
</ItemGroup>
110110

src/mono/wasm/templates/templates/browser/.template.config/template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"name": "WebAssembly Browser App",
77
"shortName": "wasmbrowser",
88
"sourceName": "browser.0",
9+
"preferNameDirectory": true,
910
"tags": {
1011
"language": "C#",
1112
"type": "project"

0 commit comments

Comments
 (0)