From 4b0284df1608b68a8f211a047567af86d5c626a9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 15:24:02 +0100 Subject: [PATCH 1/6] - bump WASI SDK to v25.0 - use `WASI-SDK-VERSION-25.0` as version detection sanity file inside runtime repo - read file $(WASI_SDK_PATH)/VERSION in workload outside of runtime repo --- eng/testing/tests.wasi.targets | 2 +- src/libraries/sendtohelix-wasi.targets | 2 +- src/mono/CMakeLists.txt | 2 +- src/mono/Directory.Build.props | 4 ++-- src/mono/cmake/configure.cmake | 2 +- src/mono/mono.proj | 4 ++-- src/mono/wasi/build/WasiApp.targets | 10 ++++++++-- src/mono/wasi/build/WasiSdk.Defaults.props | 2 +- src/mono/wasi/wasi-sdk-version.txt | 2 +- src/mono/wasi/wasi.proj | 7 ++++--- src/mono/wasm/build/WasmApp.LocalBuild.props | 2 +- src/mono/wasm/data/aot-tests/Directory.Build.props | 2 +- src/native/libs/CMakeLists.txt | 3 ++- src/native/libs/build-native.proj | 2 +- 14 files changed, 27 insertions(+), 19 deletions(-) diff --git a/eng/testing/tests.wasi.targets b/eng/testing/tests.wasi.targets index 7f981dde513c7..c89a257a88a0d 100644 --- a/eng/testing/tests.wasi.targets +++ b/eng/testing/tests.wasi.targets @@ -13,7 +13,7 @@ >true - $([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk')) + $([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk')) $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) <_BundleAOTTestWasmAppForHelixDependsOn>$(_BundleAOTTestWasmAppForHelixDependsOn);PrepareForWasiBuildApp;_PrepareForAOTOnHelix diff --git a/src/libraries/sendtohelix-wasi.targets b/src/libraries/sendtohelix-wasi.targets index 1e9c736e01aa1..0a22d5f70136e 100644 --- a/src/libraries/sendtohelix-wasi.targets +++ b/src/libraries/sendtohelix-wasi.targets @@ -46,7 +46,7 @@ false false - $([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk')) + $([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk')) $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasi', 'build')) $(HelixDependenciesStagingPath)$(WorkItemPrefix)wasi-sdk diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index e18c1b026ef0d..f0160b4974df5 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -245,7 +245,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten") set(HAVE_SYS_RANDOM_H 1) elseif(CLR_CMAKE_HOST_OS STREQUAL "wasi") set(HOST_WASI 1) - add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) + add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_PTHREAD -DHOST_WASI) add_definitions(-D_THREAD_SAFE) add_definitions(-DDISABLE_EGD_SOCKET) add_definitions(-DDISABLE_EVENTPIPE) diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 24e83e50107de..6b6a4f6aa77bf 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -34,9 +34,9 @@ - $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk')) + $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk')) $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) - true + true diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index de690240bfad4..b5cf1c625e4bb 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -27,7 +27,7 @@ if(HOST_HAIKU) endif() if(HOST_WASI) - set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN") + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_PTHREAD") endif() function(ac_check_headers) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index cc4d240fe835f..9b322be7c1dc2 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -341,8 +341,7 @@ JS_ENGINES = [NODE_JS] Condition="'$(HostOS)' == 'windows'" WorkingDirectory="$(ArtifactsObjDir)" IgnoreStandardErrorWarningFormat="true" /> - - + @@ -601,6 +600,7 @@ JS_ENGINES = [NODE_JS] <_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_SIGNAL"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_MMAN"/> + <_MonoCFLAGS Include="-D_WASI_EMULATED_PTHREAD"/> diff --git a/src/mono/wasi/build/WasiApp.targets b/src/mono/wasi/build/WasiApp.targets index f781e6469de22..ca48af019c13c 100644 --- a/src/mono/wasi/build/WasiApp.targets +++ b/src/mono/wasi/build/WasiApp.targets @@ -100,8 +100,14 @@ <_ToolchainMissingPaths Condition="'$(_ToolchainMissingPaths)' == '' and ('$(WasiClang)' == '' or !Exists('$(WasiClang)'))">%24(WasiClang)=$(WasiClang) + + + - <_ToolchainMissingErrorMessage Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION24')">Could not find wasi-sdk. Install wasi-sdk and set %24(WASI_SDK_PATH) . It can be obtained from https://github.com/WebAssembly/wasi-sdk/releases + <_ExpectedWasiSdkVersion>25.0 + <_FoundExpectedWasiSdkVersion Condition="'%(_WasiSdkVersionLines.Identity)' == '$(_ExpectedWasiSdkVersion)'">true + <_ToolchainMissingErrorMessage Condition="'$(_FoundExpectedWasiSdkVersion)' == ''">Please use wasi-sdk version $(_ExpectedWasiSdkVersion) and set %24(WASI_SDK_PATH) . It can be obtained from https://github.com/WebAssembly/wasi-sdk/releases + <_ToolchainMissingErrorMessage Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION')">Could not find wasi-sdk. Install wasi-sdk and set %24(WASI_SDK_PATH) . It can be obtained from https://github.com/WebAssembly/wasi-sdk/releases <_ToolchainMissingErrorMessage Condition="'$(_ToolchainMissingErrorMessage)' == '' and '$(_ToolchainMissingPaths)' != ''">Using WASI_SDK_PATH=$(WASI_SDK_PATH), cannot find $(_ToolchainMissingPaths) . <_IsToolchainMissing Condition="'$(_ToolchainMissingErrorMessage)' != ''">true @@ -356,7 +362,7 @@ <_WasiLinkStepArgs Include="-Wl,--export=malloc,--export=free,--export=__heap_base,--export=__data_end" /> - <_WasiLinkStepArgs Include="-Wl,-z,stack-size=8388608,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> + <_WasiLinkStepArgs Include="-Wl,-z,stack-size=8388608,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman,-lwasi-emulated-pthread"/> - <_WasiLinkFlags Include="-Wl,-z,stack-size=8388608,--initial-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> + <_WasiLinkFlags Include="-Wl,-z,stack-size=8388608,--initial-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman,-lwasi-emulated-pthread"/> diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.props b/src/mono/wasm/build/WasmApp.LocalBuild.props index 0c9d024c25ad9..dc9b562089a3a 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.props +++ b/src/mono/wasm/build/WasmApp.LocalBuild.props @@ -30,7 +30,7 @@ $(RuntimeSrcDir)\artifacts\bin\ $(RuntimeSrcDir)\src\mono\browser\emsdk\ - $([MSBuild]::NormalizeDirectory($(RuntimeSrcDir), 'src', 'mono', 'wasi', 'wasi-sdk')) + $([MSBuild]::NormalizeDirectory($(RuntimeSrcDir), 'src', 'mono', 'wasi', 'wasi-sdk')) $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) $([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.$(RuntimeIdentifier)', $(RuntimeConfig))) diff --git a/src/mono/wasm/data/aot-tests/Directory.Build.props b/src/mono/wasm/data/aot-tests/Directory.Build.props index fa8a2fb8f3d68..3728136a63d1e 100644 --- a/src/mono/wasm/data/aot-tests/Directory.Build.props +++ b/src/mono/wasm/data/aot-tests/Directory.Build.props @@ -10,7 +10,7 @@ <_WasmTargetsDir>$(WasmBuildSupportDir)\wasm\ <_WasmSharedDir>$(WasmBuildSupportDir)\wasm-shared\ $(WasmBuildSupportDir)\emsdk\ - $(WasmBuildSupportDir)/wasi-sdk/ + $(WasmBuildSupportDir)/wasi-sdk/ diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 03c5036fd8b91..7a7d94ee80842 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -58,9 +58,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) add_compile_options(-D_WASI_EMULATED_PROCESS_CLOCKS) add_compile_options(-D_WASI_EMULATED_SIGNAL) add_compile_options(-D_WASI_EMULATED_MMAN) + add_compile_options(-D_WASI_EMULATED_PTHREAD) # keep in sync with src\mono\wasi\build\WasiApp.targets # keep in sync with src\mono\wasi\wasi.proj - add_link_options(-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman) + add_link_options(-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman,-lwasi-emulated-pthread) endif () if (CLR_CMAKE_TARGET_ANDROID) diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 5102566d5cb6e..29b0e7f7efca5 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -27,7 +27,7 @@ - $([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk')) + $([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk')) $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) <_BuildNativeEnvironmentVariables>$(_BuildNativeEnvironmentVariables);WASI_SDK_PATH=$(WASI_SDK_PATH) From 0485a10e0c70fe98af9e5cbca30f80a55a8c471a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 16:33:42 +0100 Subject: [PATCH 2/6] more --- src/mono/mono.proj | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 9b322be7c1dc2..b8124e9ade337 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -358,20 +358,6 @@ JS_ENGINES = [NODE_JS] - - - - - - From 274d4e7fa4a279959757c11e4e0111fa13301569 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 20:01:29 +0100 Subject: [PATCH 3/6] use minor version too --- src/mono/mono.proj | 8 ++++---- src/mono/wasi/provision.ps1 | 6 +++--- src/mono/wasi/wasi-sdk-version.txt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index b8124e9ade337..8723830034838 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -326,13 +326,13 @@ JS_ENGINES = [NODE_JS] $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) %(_VersionLines.Identity) - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-linux.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-macos.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-windows.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-windows.tar.gz - diff --git a/src/mono/wasi/provision.ps1 b/src/mono/wasi/provision.ps1 index 28c7b4438bc95..9f7d8368216dc 100644 --- a/src/mono/wasi/provision.ps1 +++ b/src/mono/wasi/provision.ps1 @@ -14,7 +14,7 @@ $ErrorActionPreference='Stop' $ProgressPreference = 'SilentlyContinue' New-Item -Path $WasiSdkPath -ItemType "directory" -Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz -tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz -C $WasiSdkPath +Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz +tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz -C $WasiSdkPath Copy-Item $WasiLocalPath/wasi-sdk-version.txt $WasiSdkPath/wasi-sdk-version.txt -Remove-Item ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz -fo +Remove-Item ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz -fo diff --git a/src/mono/wasi/wasi-sdk-version.txt b/src/mono/wasi/wasi-sdk-version.txt index 7273c0fa8c522..be8e64f5a38cf 100644 --- a/src/mono/wasi/wasi-sdk-version.txt +++ b/src/mono/wasi/wasi-sdk-version.txt @@ -1 +1 @@ -25 +25.0 From 1f42e2c48184b41bcc81d2b7f1486a5f8b6ea77e Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 20:06:42 +0100 Subject: [PATCH 4/6] more --- src/mono/mono.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 8723830034838..bff2e219a1cf4 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -341,7 +341,7 @@ JS_ENGINES = [NODE_JS] Condition="'$(HostOS)' == 'windows'" WorkingDirectory="$(ArtifactsObjDir)" IgnoreStandardErrorWarningFormat="true" /> - + From aa66e171f2c7936d3a0154c57395ee8498716eed Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 20:16:02 +0100 Subject: [PATCH 5/6] more --- src/mono/mono.proj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index bff2e219a1cf4..b2ffe4ad123e4 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -326,9 +326,10 @@ JS_ENGINES = [NODE_JS] $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) %(_VersionLines.Identity) - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-linux.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-windows.tar.gz + $(WasiSdkVersion.Split('.')[0]) + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkMajorVersion)-x86_64-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-windows.tar.gz From d9348090aba98a04ab0df5e8d73b22f7a0b5be70 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 12 Dec 2024 20:38:14 +0100 Subject: [PATCH 6/6] more --- src/mono/mono.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index b2ffe4ad123e4..947ced98b7402 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -327,7 +327,7 @@ JS_ENGINES = [NODE_JS] $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) %(_VersionLines.Identity) $(WasiSdkVersion.Split('.')[0]) - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkMajorVersion)-x86_64-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-linux.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-windows.tar.gz