From 4044fdefe63e5a32cf7d26ef0a65af26ab6ed240 Mon Sep 17 00:00:00 2001 From: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> Date: Sun, 7 Sep 2025 14:55:15 +0300 Subject: [PATCH 1/2] [WASI] Miscellaneous fixes (#119426) --- src/libraries/Common/tests/Tests/System/StringTests.cs | 4 ++-- .../System.Runtime.Tests/System.Runtime.Tests.csproj | 2 +- .../tests/System.Runtime.Tests/System/ArgIteratorTests.cs | 2 +- .../System.Runtime.Tests/System/TimeZoneInfoTests.cs | 8 ++++---- src/mono/wasi/build/WasiApp.targets | 2 -- src/mono/wasi/wasi.proj | 1 - src/native/libs/CMakeLists.txt | 4 ---- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index caa4383c3ce0..6252ad0cc1cb 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -7719,8 +7719,8 @@ public static void InternTestCanReturnNull() Assert.False(s.IsNormalized(NormalizationForm.FormC), "String should be not normalized when checking with FormC"); Assert.False(s.IsNormalized(NormalizationForm.FormD), "String should be not normalized when checking with FormD"); - // Browser's, iOS's, MacCatalyst's, and tvOS's ICU do not support FormKC and FormKD - bool supportsKCKD = !PlatformDetection.IsBrowser && !PlatformDetection.IsiOS && !PlatformDetection.IsMacCatalyst && !PlatformDetection.IstvOS; + // Some platforms' ICUs do not support FormKC and FormKD + bool supportsKCKD = !PlatformDetection.IsBrowser && !PlatformDetection.IsWasi && !PlatformDetection.IsiOS && !PlatformDetection.IsMacCatalyst && !PlatformDetection.IstvOS; if (supportsKCKD) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj index 2fc2204ab958..8d6c7df26391 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi $(DefineConstants);TARGET_BROWSER true diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgIteratorTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgIteratorTests.cs index e194f4db7e04..ba0d88859daa 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgIteratorTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ArgIteratorTests.cs @@ -9,7 +9,7 @@ namespace System.Tests { public static class ArgIteratorTests { - [ActiveIssue("https://github.com/dotnet/runtime/issues/39343", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/39343", TestPlatforms.Browser | TestPlatforms.Wasi)] [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsArgIteratorSupported))] public static void ArgIterator_GetRemainingCount_GetNextArg() { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs index 10a63e0e2bf5..1020d102f8ac 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/TimeZoneInfoTests.cs @@ -57,7 +57,7 @@ static TimeZoneInfoTests() // Name abbreviations, if available, are used instead public static IEnumerable Platform_TimeZoneNamesTestData() { - if (PlatformDetection.IsBrowser || (PlatformDetection.IsNotHybridGlobalizationOnApplePlatform && (PlatformDetection.IsMacCatalyst || PlatformDetection.IsiOS || PlatformDetection.IstvOS))) + if (PlatformDetection.IsBrowser || PlatformDetection.IsWasi) return new TheoryData { { TimeZoneInfo.FindSystemTimeZoneById(s_strPacific), "(UTC-08:00) America/Los_Angeles", null, "PST", "PDT", null }, @@ -2051,9 +2051,9 @@ public static void TimeZoneDisplayNames_Unix(TimeZoneInfo timeZone) { bool isUtc = s_UtcAliases.Contains(timeZone.Id, StringComparer.OrdinalIgnoreCase); - if (PlatformDetection.IsBrowser) + if (PlatformDetection.IsBrowser || PlatformDetection.IsWasi) { - // Browser platform doesn't have full ICU names, but uses the IANA IDs and abbreviations instead. + // WASM platforms don't have full ICU names, but use the IANA IDs and abbreviations instead. // The display name will be the offset plus the ID. // The offset is checked separately in TimeZoneInfo_DisplayNameStartsWithOffset @@ -2425,7 +2425,7 @@ public static IEnumerable AlternativeName_TestData() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser), nameof(PlatformDetection.IsNotWasi))] [MemberData(nameof(AlternativeName_TestData))] public static void UsingAlternativeTimeZoneIdsTest(string windowsId, string ianaId) { diff --git a/src/mono/wasi/build/WasiApp.targets b/src/mono/wasi/build/WasiApp.targets index ca48af019c13..48b2713dd5e1 100644 --- a/src/mono/wasi/build/WasiApp.targets +++ b/src/mono/wasi/build/WasiApp.targets @@ -359,9 +359,7 @@ <_WasiLinkStepArgs Condition="'$(OS)' == 'Windows_NT'" Include=""$([System.String]::new(%(_WasiFilePathForFixup.Identity)).Replace('\', '/'))"" /> <_WasiLinkStepArgs Condition="'$(OS)' != 'Windows_NT'" Include="@(_WasiFilePathForFixup -> '"%(Identity)"')" /> - <_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,-lwasi-emulated-pthread"/> - <_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/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index b2f79ccfde5e..fc07b71cf88f 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -53,7 +53,6 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) if (CLR_CMAKE_TARGET_WASI) set(HOST_WASI 1) - add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-gnu-statement-expression) add_compile_options(-DHOST_WASI) @@ -61,9 +60,6 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) 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,-lwasi-emulated-pthread) endif () if (CLR_CMAKE_TARGET_ANDROID) From d4d4bece97adc75edeb8e285f6ce34dc3d0efbc0 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Thu, 11 Sep 2025 23:55:37 +0300 Subject: [PATCH 2/2] Enable System.Runtime.Tests on WASI --- eng/testing/FindWasmHostExecutable.cmd | 2 +- eng/testing/FindWasmHostExecutable.sh | 2 +- eng/testing/tests.singlefile.targets | 1 + .../System/Threading/PeriodicTimerTests.cs | 2 +- src/libraries/tests.proj | 3 +-- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/testing/FindWasmHostExecutable.cmd b/eng/testing/FindWasmHostExecutable.cmd index e2df828aceee..3d162bb760db 100644 --- a/eng/testing/FindWasmHostExecutable.cmd +++ b/eng/testing/FindWasmHostExecutable.cmd @@ -27,7 +27,7 @@ if exist "%__WasmBinaryPathWithoutExtension%.js" ( if "%__WasmBinaryExtension%" == ".wasm" ( :: Assume wasmtime is in PATH. - set WASM_HOST_EXECUTABLE=wasmtime run -S http + set WASM_HOST_EXECUTABLE=wasmtime run -S http --dir=. ) else ( if "%NODEJS_EXECUTABLE%" == "" ( :: When running tests locally, assume NodeJS is in PATH. diff --git a/eng/testing/FindWasmHostExecutable.sh b/eng/testing/FindWasmHostExecutable.sh index 393e90263e08..271740216afc 100755 --- a/eng/testing/FindWasmHostExecutable.sh +++ b/eng/testing/FindWasmHostExecutable.sh @@ -21,6 +21,6 @@ elif [ -e "${dirname}/main.mjs" ]; then WASM_HOST_EXECUTABLE=$node WASM_BINARY_TO_EXECUTE="${dirname}/main.mjs" elif [ -e "${dirname}/${exename}.wasm" ]; then - WASM_HOST_EXECUTABLE="wasmtime run -S http" + WASM_HOST_EXECUTABLE="wasmtime run -S http --dir=." WASM_BINARY_TO_EXECUTE="${dirname}/${exename}.wasm" fi diff --git a/eng/testing/tests.singlefile.targets b/eng/testing/tests.singlefile.targets index e6e578aa2494..40539dd1e97c 100644 --- a/eng/testing/tests.singlefile.targets +++ b/eng/testing/tests.singlefile.targets @@ -45,6 +45,7 @@ $(DefineConstants);SINGLE_FILE_TEST_RUNNER + $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Threading/PeriodicTimerTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Threading/PeriodicTimerTests.cs index 320b335a0c77..57c05670325b 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Threading/PeriodicTimerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Threading/PeriodicTimerTests.cs @@ -7,7 +7,7 @@ namespace System.Threading.Tests { - [ActiveIssue("https://github.com/dotnet/runtimelab/issues/2505", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot), nameof(PlatformDetection.IsWasm))] + [ActiveIssue("https://github.com/dotnet/runtimelab/issues/2505", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot), nameof(PlatformDetection.IsBrowser))] public class PeriodicTimerTests { [Fact] diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 8eb79b984bf5..f0ee0918c2f1 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -613,8 +613,7 @@ - - +