diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd
index b78a073c8c11..23d9861bdb41 100644
--- a/eng/native/gen-buildsys.cmd
+++ b/eng/native/gen-buildsys.cmd
@@ -65,7 +65,7 @@ if /i "%__Arch%" == "wasm" (
set "WASI_SDK_PATH=!WASI_SDK_PATH:\=/!"
if not "!WASI_SDK_PATH:~-1!" == "/" set "WASI_SDK_PATH=!WASI_SDK_PATH!/"
set __CmakeGenerator=Ninja
- set __ExtraCmakeParams=%__ExtraCmakeParams% -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm "-DWASI_SDK_PREFIX=!WASI_SDK_PATH!" "-DCMAKE_TOOLCHAIN_FILE=!WASI_SDK_PATH!/share/cmake/wasi-sdk-p2.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!share/wasi-sysroot" "-DCMAKE_CROSSCOMPILING_EMULATOR=node --experimental-wasm-bigint --experimental-wasi-unstable-preview1"
+ set __ExtraCmakeParams=%__ExtraCmakeParams% -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm "-DWASI_SDK_PREFIX=!WASI_SDK_PATH!" "-DCMAKE_TOOLCHAIN_FILE=!WASI_SDK_PATH!/share/cmake/wasi-sdk-p2.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!share/wasi-sysroot" "-DCMAKE_CROSSCOMPILING_EMULATOR=node --experimental-wasm-bigint --experimental-wasi-unstable-preview1 -D_WASI_EMULATED_PTHREAD"
)
) else (
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"
@@ -102,7 +102,7 @@ if not "%__ConfigureOnly%" == "1" (
if /i "%__UseEmcmake%" == "1" (
call "!EMSDK!/emsdk_env" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
) else (
- "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
+ "%CMakePath%" --trace-source=zlib-ng.cmake %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
)
if "%errorlevel%" == "0" (
diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml
index abe13f65b536..161efb15b2c2 100644
--- a/eng/pipelines/common/global-build-job.yml
+++ b/eng/pipelines/common/global-build-job.yml
@@ -219,7 +219,7 @@ jobs:
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-nodejs.ps1 $(Build.SourcesDirectory)/wasm-tools
displayName: Install NodeJS
- - ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), or(eq(parameters.platform, 'wasi_wasm_win'), eq(parameters.platform, 'wasi_wasm_linux_x64_naot_llvm'))) }}:
+ - ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), in(parameters.platform, 'wasi_wasm_win', 'wasi_wasm_linux_x64_naot_llvm', 'wasi_multithread_wasm_win')) }}:
# Install Wasi Wasm dependencies: wasi-sdk, wasmtime
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasi-sdk.ps1 -CI -InstallDir $(Build.SourcesDirectory)/wasm-tools
displayName: Install wasi-sdk
@@ -228,7 +228,7 @@ jobs:
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-jco.ps1 $(Build.SourcesDirectory)
displayName: Install Jco
- - ${{ if or(eq(parameters.platform, 'browser_wasm_win'), and(eq(parameters.platform, 'wasi_wasm_win'), not(eq(parameters.runtimeFlavor, 'coreclr')))) }}:
+ - ${{ if or(eq(parameters.platform, 'browser_wasm_win'), and(in(parameters.platform, 'wasi_wasm_win', 'wasi_multithread_wasm_win'), not(eq(parameters.runtimeFlavor, 'coreclr')))) }}:
# Update machine certs
- task: PowerShell@2
displayName: Update machine certs
diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml
index 1c34c26eecdb..ef0fe1a1a437 100644
--- a/eng/pipelines/common/platform-matrix.yml
+++ b/eng/pipelines/common/platform-matrix.yml
@@ -500,6 +500,29 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}
+- ${{ if containsValue(parameters.platforms, 'wasi_multithread_wasm_win') }}:
+ - template: xplat-setup.yml
+ parameters:
+ jobTemplate: ${{ parameters.jobTemplate }}
+ helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
+ variables: ${{ parameters.variables }}
+ osGroup: wasi
+ archType: wasm
+ targetRid: wasi-wasm
+ platform: wasi_wasm_win
+ shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
+ jobParameters:
+ hostedOs: windows
+ runtimeFlavor: ${{ parameters.runtimeFlavor }}
+ stagedBuild: ${{ parameters.stagedBuild }}
+ buildConfig: ${{ parameters.buildConfig }}
+ # Turn on threads by adding to the buildArgs
+# ${{ each param in parameters.jobParameters }}:
+# ${{ each pair in param }}:
+# ${{ if ne(pair.key, 'buildArgs') }}:
+# ${{ pair.key }}: ${{ pair.value }}
+ # buildArgs: ${{ buildArgs }} '/p:WasmEnableThreads=true'
+
# Browser WebAssembly Linux X64 for NAOT-LLVM
# Use a different name to differentiate from upstream as we need the -sanitizer image to get build tools that are not present in the stock browser_wasm image.
diff --git a/eng/pipelines/runtimelab.yml b/eng/pipelines/runtimelab.yml
index cf88871b348c..c83bdfa5af99 100644
--- a/eng/pipelines/runtimelab.yml
+++ b/eng/pipelines/runtimelab.yml
@@ -61,6 +61,7 @@ extends:
- windows_x64
- browser_wasm_win
- wasi_wasm_win
+# - wasi_multithread_wasm_win
- Browser_wasm_linux_x64_naot_llvm
- wasi_wasm_linux_x64_naot_llvm
jobParameters:
@@ -103,6 +104,7 @@ extends:
- windows_x64
- Browser_wasm_win
- wasi_wasm_win
+# - wasi_multithread_wasm_win
- wasi_wasm_linux_x64_naot_llvm
- Browser_wasm_linux_x64_naot_llvm
jobParameters:
diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
index 7f09dfcc7608..9358aa219640 100644
--- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
+++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
@@ -35,6 +35,10 @@
true
true
+ true
+ true
+ $(DefineConstants);FEATURE_WASM_MANAGED_THREADS
+ $(DefineConstants);FEATURE_WASM_PERFTRACING
true
diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs
index 4c90bbaa42ad..9c33774f1619 100644
--- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs
+++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Monitor.NativeAot.cs
@@ -143,7 +143,9 @@ public static bool IsEntered(object obj)
#region Public Wait/Pulse methods
+#if !FEATURE_WASM_MANAGED_THREADS
[UnsupportedOSPlatform("browser")]
+#endif
public static bool Wait(object obj, int millisecondsTimeout)
{
return GetCondition(obj).Wait(millisecondsTimeout, obj);
diff --git a/src/installer/pkg/projects/nativeaot-packages.proj b/src/installer/pkg/projects/nativeaot-packages.proj
index 8a640a9c08c0..0a1404df62c1 100644
--- a/src/installer/pkg/projects/nativeaot-packages.proj
+++ b/src/installer/pkg/projects/nativeaot-packages.proj
@@ -4,7 +4,8 @@
-
+
+
diff --git a/src/native/external/zlib-ng.cmake b/src/native/external/zlib-ng.cmake
index b2338d682e14..0049a1041804 100644
--- a/src/native/external/zlib-ng.cmake
+++ b/src/native/external/zlib-ng.cmake
@@ -26,8 +26,10 @@ if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
# zlib-ng uses atomics, so we need to enable threads when requested for browser/wasi, otherwise the wasm target won't have thread support.
if (CMAKE_USE_PTHREADS)
- add_compile_options(-pthread)
- add_linker_flag(-pthread)
+ #add_compile_options(-pthread)
+ #add_linker_flag(-pthread)
+ add_compile_options(-D_WASI_EMULATED_PTHREAD )
+ add_linker_flag(-Wl,-lwasi-emulated-pthread)
endif()
endif()