Skip to content

Commit c969265

Browse files
authored
[WASI] bump WASI SDK to v25.0 (#110654)
1 parent c130ec4 commit c969265

15 files changed

+35
-40
lines changed

eng/testing/tests.wasi.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
>true</InstallWasmtimeForTests>
1414

1515
<!--<InstallWorkloadUsingArtifactsDependsOn>_GetWorkloadsToInstall;$(InstallWorkloadUsingArtifactsDependsOn)</InstallWorkloadUsingArtifactsDependsOn>-->
16-
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION24')">$([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
16+
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/WASI-SDK-VERSION-25.0')">$([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
1717
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
1818

1919
<_BundleAOTTestWasmAppForHelixDependsOn>$(_BundleAOTTestWasmAppForHelixDependsOn);PrepareForWasiBuildApp;_PrepareForAOTOnHelix</_BundleAOTTestWasmAppForHelixDependsOn>

src/libraries/sendtohelix-wasi.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<IncludeHelixCorrelationPayload>false</IncludeHelixCorrelationPayload>
4747
<EnableDefaultBuildHelixWorkItems>false</EnableDefaultBuildHelixWorkItems>
4848

49-
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION24')">$([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
49+
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/WASI-SDK-VERSION-25.0')">$([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
5050
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
5151
<WasiBuildTargetsDir>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasi', 'build'))</WasiBuildTargetsDir>
5252
<WasiSdkDirForHelixPayload>$(HelixDependenciesStagingPath)$(WorkItemPrefix)wasi-sdk</WasiSdkDirForHelixPayload>

src/mono/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "emscripten")
245245
set(HAVE_SYS_RANDOM_H 1)
246246
elseif(CLR_CMAKE_HOST_OS STREQUAL "wasi")
247247
set(HOST_WASI 1)
248-
add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI)
248+
add_definitions(-D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_PTHREAD -DHOST_WASI)
249249
add_definitions(-D_THREAD_SAFE)
250250
add_definitions(-DDISABLE_EGD_SOCKET)
251251
add_definitions(-DDISABLE_EVENTPIPE)

src/mono/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
<!-- Directory to provision and use WASI sdk if WASI_SDK_PATH env variable is not set -->
3636
<PropertyGroup Condition="'$(TargetsWasi)' == 'true'">
37-
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION24')">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
37+
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/WASI-SDK-VERSION-25.0')">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
3838
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
39-
<ShouldProvisionWasiSdk Condition="!Exists('$(WASI_SDK_PATH)/VERSION24')">true</ShouldProvisionWasiSdk>
39+
<ShouldProvisionWasiSdk Condition="!Exists('$(WASI_SDK_PATH)/WASI-SDK-VERSION-25.0')">true</ShouldProvisionWasiSdk>
4040
</PropertyGroup>
4141

4242
<PropertyGroup>

src/mono/cmake/configure.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if(HOST_HAIKU)
2727
endif()
2828

2929
if(HOST_WASI)
30-
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN")
30+
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_PTHREAD")
3131
endif()
3232

3333
function(ac_check_headers)

src/mono/mono.proj

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,14 @@ JS_ENGINES = [NODE_JS]
326326
<PropertyGroup>
327327
<WasiLocalPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi'))</WasiLocalPath>
328328
<WasiSdkVersion>%(_VersionLines.Identity)</WasiSdkVersion>
329-
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-linux.tar.gz</WasiSdkUrl>
330-
<WasiSdkUrl Condition="'$(HostOS)' == 'osx'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-macos.tar.gz</WasiSdkUrl>
331-
<WasiSdkUrl Condition="'$(HostOS)' == 'windows'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-x86_64-windows.tar.gz</WasiSdkUrl>
329+
<WasiSdkMajorVersion>$(WasiSdkVersion.Split('.')[0])</WasiSdkMajorVersion>
330+
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-linux.tar.gz</WasiSdkUrl>
331+
<WasiSdkUrl Condition="'$(HostOS)' == 'osx'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz</WasiSdkUrl>
332+
<WasiSdkUrl Condition="'$(HostOS)' == 'windows'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkMajorVersion)/wasi-sdk-$(WasiSdkVersion)-x86_64-windows.tar.gz</WasiSdkUrl>
332333
</PropertyGroup>
333334

334335
<RemoveDir Directories="$(WASI_SDK_PATH)" />
335-
<Exec Command="curl -L -o wasi-sdk-$(WasiSdkVersion).0.tar.gz $(WasiSdkUrl) &amp;&amp; mkdir -p $(WASI_SDK_PATH) &amp;&amp; tar --strip-components=1 -xzf wasi-sdk-$(WasiSdkVersion).0.tar.gz -C $(WASI_SDK_PATH) &amp;&amp; cp $(WasiLocalPath)/wasi-sdk-version.txt $(WASI_SDK_PATH)wasi-sdk-version.txt"
336+
<Exec Command="curl -L -o wasi-sdk-$(WasiSdkVersion).tar.gz $(WasiSdkUrl) &amp;&amp; mkdir -p $(WASI_SDK_PATH) &amp;&amp; tar --strip-components=1 -xzf wasi-sdk-$(WasiSdkVersion).tar.gz -C $(WASI_SDK_PATH) &amp;&amp; cp $(WasiLocalPath)/wasi-sdk-version.txt $(WASI_SDK_PATH)wasi-sdk-version.txt"
336337
Condition="'$(HostOS)' != 'windows'"
337338
WorkingDirectory="$(ArtifactsObjDir)"
338339
IgnoreStandardErrorWarningFormat="true" />
@@ -341,8 +342,7 @@ JS_ENGINES = [NODE_JS]
341342
Condition="'$(HostOS)' == 'windows'"
342343
WorkingDirectory="$(ArtifactsObjDir)"
343344
IgnoreStandardErrorWarningFormat="true" />
344-
345-
<Touch Files="$(WASI_SDK_PATH)/VERSION24" AlwaysCreate="true" />
345+
<Touch Files="$(WASI_SDK_PATH)/WASI-SDK-VERSION-$(WasiSdkVersion)" AlwaysCreate="true" />
346346

347347
</Target>
348348

@@ -359,20 +359,6 @@ JS_ENGINES = [NODE_JS]
359359
</PropertyGroup>
360360
<Error Text="Expected version: %(_ExpectedVersionLines.Identity) and actual version: %(_ActualVersionLines.Identity) of WASI SDK does not match. Please delete $(WASI_SDK_PATH) folder to provision a new version."
361361
Condition="'$(ActualWasiSdkVersion)' != '$(ExpectedWasiSdkVersion)'" />
362-
363-
<!-- LLVM in WASI SDK 24 will call wasm-opt when found on the PATH. But it will fail because wasm-opt can't read the WASM components.
364-
After we upgrade to WASI SDK with LLVM 19, we could use no-wasm-opt LLVM option to avoid this issue.
365-
See https://github.com/llvm/llvm-project/pull/98373
366-
See https://github.com/dotnet/runtime/issues/104773
367-
-->
368-
<Exec Command="wasm-opt --version" IgnoreExitCode="true"
369-
IgnoreStandardErrorWarningFormat="true"
370-
StandardErrorImportance="low"
371-
StandardOutputImportance="Low" >
372-
<Output TaskParameter="ExitCode" PropertyName="_WasmOptExitCode"/>
373-
</Exec>
374-
<Error Text="Found wasm-opt tool on the PATH. Please remove it to avoid failures during compilation into wasm32-wasip2 target as WASM components, which is not supported by wasm-opt tool. See https://github.com/llvm/llvm-project/pull/95208#issuecomment-2220400454"
375-
Condition="'$(_WasmOptExitCode)' == '0'" />
376362
</Target>
377363

378364
<!-- Copy Mono runtime bits to $(Destination) -->
@@ -601,6 +587,7 @@ JS_ENGINES = [NODE_JS]
601587
<_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/>
602588
<_MonoCFLAGS Include="-D_WASI_EMULATED_SIGNAL"/>
603589
<_MonoCFLAGS Include="-D_WASI_EMULATED_MMAN"/>
590+
<_MonoCFLAGS Include="-D_WASI_EMULATED_PTHREAD"/>
604591
</ItemGroup>
605592

606593
<!-- iOS/tvOS specific options -->

src/mono/wasi/build/WasiApp.targets

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@
100100
<_ToolchainMissingPaths Condition="'$(_ToolchainMissingPaths)' == '' and ('$(WasiClang)' == '' or !Exists('$(WasiClang)'))">%24(WasiClang)=$(WasiClang) </_ToolchainMissingPaths>
101101
</PropertyGroup>
102102

103+
<ReadLinesFromFile Condition="'$(WASI_SDK_PATH)' != '' and Exists('$(WASI_SDK_PATH)/VERSION')" File="$(WASI_SDK_PATH)/VERSION">
104+
<Output TaskParameter="Lines" ItemName="_WasiSdkVersionLines" />
105+
</ReadLinesFromFile>
103106
<PropertyGroup>
104-
<_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</_ToolchainMissingErrorMessage>
107+
<_ExpectedWasiSdkVersion>25.0</_ExpectedWasiSdkVersion>
108+
<_FoundExpectedWasiSdkVersion Condition="'%(_WasiSdkVersionLines.Identity)' == '$(_ExpectedWasiSdkVersion)'">true</_FoundExpectedWasiSdkVersion>
109+
<_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>
110+
<_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>
105111
<_ToolchainMissingErrorMessage Condition="'$(_ToolchainMissingErrorMessage)' == '' and '$(_ToolchainMissingPaths)' != ''">Using WASI_SDK_PATH=$(WASI_SDK_PATH), cannot find $(_ToolchainMissingPaths) .</_ToolchainMissingErrorMessage>
106112
<_IsToolchainMissing Condition="'$(_ToolchainMissingErrorMessage)' != ''">true</_IsToolchainMissing>
107113
</PropertyGroup>
@@ -356,7 +362,7 @@
356362
<_WasiLinkStepArgs Include="-Wl,--export=malloc,--export=free,--export=__heap_base,--export=__data_end" />
357363
<!-- keep in sync with src\mono\wasi\wasi.proj -->
358364
<!-- keep in sync with src\native\libs\CMakeLists.txt -->
359-
<_WasiLinkStepArgs Include="-Wl,-z,stack-size=8388608,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/>
365+
<_WasiLinkStepArgs Include="-Wl,-z,stack-size=8388608,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman,-lwasi-emulated-pthread"/>
360366
<!--
361367
this together with some DLLImports makes dependency on wasi:http@0.2.0
362368
it will get trimmed when HTTP is not used and using publish + native rebuild

src/mono/wasi/build/WasiSdk.Defaults.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION24')">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', 'wasi-sdk'))</WASI_SDK_PATH>
3+
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == '' or !Exists('$(WASI_SDK_PATH)/VERSION')">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', 'wasi-sdk'))</WASI_SDK_PATH>
44
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
55
<WasiSysRoot>$([MSBuild]::NormalizeDirectory($(WASI_SDK_PATH), 'share', 'wasi-sysroot'))</WasiSysRoot>
66
<WasiClang>$(WASI_SDK_PATH)bin/clang</WasiClang>

src/mono/wasi/provision.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $ErrorActionPreference='Stop'
1414
$ProgressPreference = 'SilentlyContinue'
1515

1616
New-Item -Path $WasiSdkPath -ItemType "directory"
17-
Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz
18-
tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz -C $WasiSdkPath
17+
Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz
18+
tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz -C $WasiSdkPath
1919
Copy-Item $WasiLocalPath/wasi-sdk-version.txt $WasiSdkPath/wasi-sdk-version.txt
20-
Remove-Item ./wasi-sdk-$WasiSdkVersion.0-x86_64-windows.tar.gz -fo
20+
Remove-Item ./wasi-sdk-$WasiSdkVersion-x86_64-windows.tar.gz -fo

src/mono/wasi/wasi-sdk-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24
1+
25.0

0 commit comments

Comments
 (0)