From 6156bbb118c8dd5f7ec2eb928dbee571e44a1385 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 18:51:59 +0100 Subject: [PATCH 001/116] wip --- Directory.Build.props | 3 ++- eng/Subsets.props | 6 +++-- eng/build.ps1 | 16 ++++++++++++-- eng/build.sh | 10 +++++++-- eng/testing/wasi-provisioning.targets | 3 +++ eng/versioning.targets | 1 + .../src/runtime.compatibility.json | 11 ++++++++++ .../src/runtime.json | 10 +++++++++ .../src/runtimeGroups.props | 5 +++++ src/libraries/OSGroups.json | 2 ++ .../System.Private.CoreLib.Shared.projitems | 21 +++++++++--------- .../src/System/OperatingSystem.cs | 13 +++++++++++ .../System.Runtime/ref/System.Runtime.cs | 1 + src/libraries/pretest.proj | 5 ++++- .../System.Private.CoreLib.csproj | 22 +++++++++++-------- src/mono/wasi/.gitignore | 3 +++ src/mono/wasi/wasi-sdk-version.txt | 1 + 17 files changed, 106 insertions(+), 27 deletions(-) create mode 100644 eng/testing/wasi-provisioning.targets create mode 100644 src/mono/wasi/.gitignore create mode 100644 src/mono/wasi/wasi-sdk-version.txt diff --git a/Directory.Build.props b/Directory.Build.props index 35e506f1ebaa5..4faaff7eb50c2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -217,6 +217,7 @@ true true true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index 9e666f71fe0a6..e0b667e9cd1f6 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,6 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -139,7 +140,8 @@ - + + @@ -343,7 +345,7 @@ - + diff --git a/eng/build.ps1 b/eng/build.ps1 index e7ab6609e8e75..88b2067126513 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","Wasi")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, Wasi or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,24 @@ if ($os -eq "Browser") { } } +if ($os -eq "Wasi") { + # override default arch for Wasi, we only support wasm + $arch = "wasm" + + if ($msbuild -eq $True) { + Write-Error "Using the -msbuild option isn't supported when building for Wasi on Windows, we need need ninja for WASI-SDK." + exit 1 + } +} + foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" + } elseif ($os -eq "Wasi") { + $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" } diff --git a/eng/build.sh b/eng/build.sh index 97fee9151c3e4..2033865d3dcb0 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -280,13 +280,15 @@ while [[ $# > 0 ]]; do os="Android" ;; browser) os="Browser" ;; + wasi) + os="Wasi" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." exit 1 ;; esac @@ -505,6 +507,10 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi +if [[ "$os" == "Wasi" && "$arch" != "wasm" ]]; then + # override default arch for Browser, we only support wasm + arch=wasm +fi initDistroRid $os $arch $crossBuild $portableBuild diff --git a/eng/testing/wasi-provisioning.targets b/eng/testing/wasi-provisioning.targets new file mode 100644 index 0000000000000..ff5c5e02d5efd --- /dev/null +++ b/eng/testing/wasi-provisioning.targets @@ -0,0 +1,3 @@ + + + diff --git a/eng/versioning.targets b/eng/versioning.targets index fb3e315a6935c..fa1b63973d005 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,6 +86,7 @@ diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index aae2543ec5ead..a1b755d470d6b 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -3835,6 +3835,17 @@ "any", "base" ], + "wasi": [ + "wasi", + "any", + "base" + ], + "wasi-wasm": [ + "wasi-wasm", + "wasi", + "any", + "base" + ], "centos": [ "centos", "rhel", diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 0e981e704bc1f..928498570017e 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -1022,6 +1022,16 @@ "browser" ] }, + "wasi": { + "#import": [ + "any" + ] + }, + "wasi-wasm": { + "#import": [ + "wasi" + ] + }, "centos": { "#import": [ "rhel" diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index 3a0135e7cc15a..912fe7693c438 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -45,6 +45,11 @@ wasm + + any + wasm + + ios x64;arm64 diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index df367e07b744e..6bff22611c456 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,6 +4,8 @@ }, "Browser" : { }, + "Wasi" : { + }, "Linux": { "#import": [ "Unix" diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index ad70614a9d462..68849eef5eea2 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -12,7 +12,7 @@ enable true true - true + true true true true @@ -20,7 +20,7 @@ $(MSBuildThisFileDirectory)ILLink\ true true - true + true $(DefineConstants);BIGENDIAN @@ -37,6 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD @@ -2018,7 +2019,7 @@ - + Common\Interop\Unix\Interop.Errors.cs @@ -2267,7 +2268,7 @@ - + @@ -2276,7 +2277,7 @@ - + @@ -2310,7 +2311,7 @@ - + @@ -2412,7 +2413,7 @@ - + @@ -2425,11 +2426,11 @@ - + - + @@ -2447,7 +2448,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index deb0b107eb5cf..6fc2f2257fe7b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -12,6 +12,8 @@ public sealed class OperatingSystem : ISerializable, ICloneable private const string OSPlatformName = #if TARGET_BROWSER "BROWSER" +#elif TARGET_WASI + "WASI" #elif TARGET_WINDOWS "WINDOWS" #elif TARGET_OSX @@ -148,6 +150,17 @@ public static bool IsBrowser() => false; #endif + /// + /// Indicates whether the current application is running as WASI. + /// + [NonVersionable] + public static bool IsWasi() => +#if TARGET_WASI + true; +#else + false; +#endif + /// /// Indicates whether the current application is running on Linux. /// diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index c26b436f41097..0a3275c5ea4ad 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,6 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } + public static bool IsWasi() { throw null; } public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index dc68ed802a448..8a2e1240c1449 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -26,12 +26,15 @@ - + + + AnyCPU $(DefineConstants);TARGET_WASM + + AnyCPU + $(DefineConstants);TARGET_WASI + @@ -125,13 +129,13 @@ $(DefineConstants);MONO_FEATURE_SRE true - true - true + true + true true true - true - true - true + true + true + true true @@ -278,16 +282,16 @@ - + - + - + - + diff --git a/src/mono/wasi/.gitignore b/src/mono/wasi/.gitignore new file mode 100644 index 0000000000000..e81db9a853fcb --- /dev/null +++ b/src/mono/wasi/.gitignore @@ -0,0 +1,3 @@ +!Makefile +.stamp-wasm-install-and-select* +wasi-sdk* diff --git a/src/mono/wasi/wasi-sdk-version.txt b/src/mono/wasi/wasi-sdk-version.txt new file mode 100644 index 0000000000000..3cacc0b93c9c9 --- /dev/null +++ b/src/mono/wasi/wasi-sdk-version.txt @@ -0,0 +1 @@ +12 \ No newline at end of file From 4246b37d90070ae3dc2babb7c565808c83758296 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 18:57:05 +0100 Subject: [PATCH 002/116] wip --- .../System.Private.CoreLib/src/System/AppContext.AnyOS.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs b/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs index 2dc7015dda0a3..b2c83e67dd453 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs @@ -12,7 +12,7 @@ namespace System { public static partial class AppContext { -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI [UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file", Justification = "Single File apps should always set APP_CONTEXT_BASE_DIRECTORY therefore code handles Assembly.Location equals null")] private static string GetBaseDirectoryCore() From 799000875f36da95e5a82209250928daeb1edeba Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 19:08:13 +0100 Subject: [PATCH 003/116] wip --- .../System/Diagnostics/Tracing/EventSource.cs | 4 +- .../src/System/IO/FileStatus.Unix.cs | 8 +-- .../src/System/Reflection/Assembly.cs | 4 +- .../Threading/EventWaitHandle.Windows.cs | 2 +- .../src/System/Threading/Mutex.Windows.cs | 4 +- .../src/System/Threading/Overlapped.cs | 2 +- .../src/System/Threading/Semaphore.Windows.cs | 2 +- .../src/System/Threading/Thread.cs | 2 +- .../Decoding/CustomAttributeDecoderTests.cs | 2 +- .../Web/OptimizedInboxTextEncoder.Ascii.cs | 2 +- src/mono/CMakeLists.txt | 12 +++- src/mono/Directory.Build.props | 8 +++ .../src/System/Threading/Thread.Mono.cs | 10 +-- src/mono/cmake/configure.cmake | 4 +- src/mono/mono.proj | 70 +++++++++++++++---- src/mono/mono/mini/CMakeLists.txt | 2 +- src/mono/mono/profiler/browser.c | 4 +- src/mono/mono/utils/mono-rand.c | 33 +++++---- 18 files changed, 119 insertions(+), 56 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index fc8c2a8226cdd..9cd258cf52b24 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -1327,12 +1327,12 @@ protected unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid* rel if (m_Dispatchers != null && metadata.EnabledForAnyListener) { -#if MONO && !TARGET_BROWSER +#if MONO && !TARGET_BROWSER && !TARGET_WASI // On Mono, managed events from NativeRuntimeEventSource are written using WriteEventCore which can be // written doubly because EventPipe tries to pump it back up to EventListener via NativeRuntimeEventSource.ProcessEvents. // So we need to prevent this from getting written directly to the Listeners. if (this.GetType() != typeof(NativeRuntimeEventSource)) -#endif // MONO && !TARGET_BROWSER +#endif // MONO && !TARGET_BROWSER && !TARGET_WASI { var eventCallbackArgs = new EventWrittenEventArgs(this, eventId, pActivityId, relatedActivityId); WriteToAllListeners(eventCallbackArgs, eventDataCount, data); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs index fe14a0aa99a19..f6342bd32250b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs @@ -57,7 +57,7 @@ private bool HasReadOnlyFlag return false; } -#if TARGET_BROWSER +#if TARGET_BROWSER || TARGET_WASI var mode = ((UnixFileMode)_fileCache.Mode & FileSystem.ValidUnixFileModes); bool isUserReadOnly = (mode & UnixFileMode.UserRead) != 0 && // has read permission (mode & UnixFileMode.UserWrite) == 0; // but not write permission @@ -81,7 +81,7 @@ private bool HasReadOnlyFlag } } -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI // HasReadOnlyFlag cache. // Must only be used after calling EnsureCachesInitialized. private int _isReadOnlyCache; @@ -394,7 +394,7 @@ private unsafe void SetAccessOrWriteTimeCore(SafeFileHandle? handle, string? pat long seconds = time.ToUnixTimeSeconds(); long nanoseconds = UnixTimeSecondsToNanoseconds(time, seconds); -#if TARGET_BROWSER +#if TARGET_BROWSER && !TARGET_WASI buf[0].TvSec = seconds; buf[0].TvNsec = nanoseconds; buf[1].TvSec = seconds; @@ -499,7 +499,7 @@ internal void RefreshCaches(SafeFileHandle? handle, ReadOnlySpan path) { Debug.Assert(handle is not null || path.Length > 0); -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI _isReadOnlyCache = -1; #endif int rv = handle is not null ? diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs index f6445df9671b8..00095ffb7f48b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -265,10 +265,10 @@ public static Assembly LoadFile(string path) return result; // we cannot check for file presence on BROWSER. The files could be embedded and not physically present. -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI if (!File.Exists(normalizedPath)) throw new FileNotFoundException(SR.Format(SR.FileNotFound_LoadFile, normalizedPath), normalizedPath); -#endif // !TARGET_BROWSER +#endif // !TARGET_BROWSER && !TARGET_WASI AssemblyLoadContext alc = new IndividualAssemblyLoadContext($"Assembly.LoadFile({normalizedPath})"); result = alc.LoadFromAssemblyPath(normalizedPath); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs index 95750074698b0..bc41f1bde322e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs @@ -18,7 +18,7 @@ private EventWaitHandle(SafeWaitHandle handle) private void CreateEventCore(bool initialState, EventResetMode mode, string? name, out bool createdNew) { -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (name != null) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs index ab5663297cdc5..10a91926c3e02 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs @@ -24,7 +24,7 @@ private void CreateMutexCore(bool initiallyOwned, string? name, out bool created if (mutexHandle.IsInvalid) { mutexHandle.SetHandleAsInvalid(); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name)); @@ -56,7 +56,7 @@ private static OpenExistingResult OpenExistingWorker(string name, out Mutex? res myHandle.Dispose(); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) { // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 0f130cdc53aa8..29446e444073c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -184,7 +184,7 @@ public static void Free(NativeOverlapped* nativeOverlappedPtr) _pNativeOverlapped = pNativeOverlapped; #if FEATURE_PERFTRACING -#if !(TARGET_BROWSER && !FEATURE_WASM_THREADS) +#if !((TARGET_BROWSER || TARGET_WASI) && !FEATURE_WASM_THREADS) if (NativeRuntimeEventSource.Log.IsEnabled()) NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs index a4cb8323ef5b2..027e9fe93f468 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs @@ -23,7 +23,7 @@ private void CreateSemaphoreCore(int initialCount, int maximumCount, string? nam Debug.Assert(maximumCount >= 1); Debug.Assert(initialCount <= maximumCount); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (name != null) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index a27ced32def89..19d00e5d9ac19 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -153,7 +153,7 @@ public Thread(ParameterizedThreadStart start, int maxStackSize) Initialize(); } -#if !TARGET_BROWSER || FEATURE_WASM_THREADS +#if !(TARGET_BROWSER || TARGET_WASI) || FEATURE_WASM_THREADS [UnsupportedOSPlatformGuard("browser")] internal static bool IsThreadStartSupported => true; internal static bool IsInternalThreadStartSupported => true; diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs index 62944bef46d20..5d6b096956628 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs @@ -197,7 +197,7 @@ public void TestCustomAttributeDecoderUsingReflection() } } -#if NETCOREAPP && !TARGET_BROWSER // Generic attribute is not supported on .NET Framework. +#if NETCOREAPP && !TARGET_BROWSER && !TARGET_WASI // Generic attribute is not supported on .NET Framework. [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60579", TestPlatforms.iOS | TestPlatforms.tvOS)] public void TestCustomAttributeDecoderGenericUsingReflection() diff --git a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs index 03c0e7fc324bf..859b5c5eef9ff 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs +++ b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs @@ -23,7 +23,7 @@ private unsafe partial struct AllowedAsciiCodePoints private fixed byte AsBytes[16]; #if NETCOREAPP -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI [FieldOffset(0)] // ensure same offset with AsBytes field internal Vector128 AsVector; #else diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 85a0f819da4d1..c33dd5845f3e0 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -252,6 +252,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") add_definitions(-DNO_GLOBALIZATION_SHIM) add_definitions(-D_THREAD_SAFE) add_definitions(-DGEN_PINVOKE) + add_definitions(-DDISABLE_SOCKET_TRANSPORT) + add_definitions(-DDISABLE_EGD_SOCKET) + add_definitions(-DDISABLE_EVENTPIPE) + set(ENABLE_PERFTRACING 0) + add_compile_options(-Wl,--allow-undefined) set(DISABLE_SHARED_LIBS 1) set(INTERNAL_ZLIB 1) set(DISABLE_EXECUTABLES 1) @@ -336,6 +341,9 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") endif() elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") set(TARGET_WASI 1) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + add_compile_options(-Os) + endif() elseif(TARGET_SYSTEM_NAME STREQUAL "Windows") set(TARGET_WIN32 1) elseif(TARGET_SYSTEM_NAME STREQUAL "SunOS") @@ -358,7 +366,7 @@ if(NOT "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") endif() -if(HOST_BROWSER) +if(HOST_BROWSER OR HOST_WASI) # CMAKE_SYSTEM_PROCESSOR is set to x86 by emscripten set(CMAKE_SYSTEM_PROCESSOR "wasm") endif() @@ -911,7 +919,7 @@ endif() add_subdirectory("${CLR_SRC_NATIVE_DIR}/public" public_apis) add_subdirectory(mono) -if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCAT) +if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT TARGET_WASI AND NOT HOST_MACCAT) add_subdirectory(dlls/mscordbi) add_subdirectory(dlls/dbgshim) endif() diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index b64f87e11d95c..8795f72f59e69 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -44,6 +44,13 @@ $(ProvisionEmscriptenDir.Replace('\', '/')) + + + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) + $(ProvisionWasiSdkDir.Replace('\', '/')) + true + + $(TargetOS).$(Platform).$(Configuration) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'mono', '$(TargetOS).$(Platform).$(Configuration)')) @@ -52,6 +59,7 @@ true true true + true true <_MonoUseLLVMPackage Condition="'$(MonoLLVMDir)' == '' and '$(MonoEnableLLVM)' == 'true'">true <_MonoUseAOTLLVMPackage Condition="'$(MonoAOTLLVMDir)' == '' and '$(MonoAOTEnableLLVM)' == 'true'">true diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs index 13adc4d13f341..e40507053c681 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs @@ -65,7 +65,7 @@ public partial class Thread private StartHelper? _startHelper; internal ExecutionContext? _executionContext; internal SynchronizationContext? _synchronizationContext; -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI internal WaitSubsystem.ThreadWaitInfo? _waitInfo; #endif @@ -138,7 +138,7 @@ internal static int OptimalMaxSpinWaitsPerSpinIteration return 7; } } -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI internal WaitSubsystem.ThreadWaitInfo WaitInfo { get @@ -196,7 +196,7 @@ public static int GetCurrentProcessorId() public void Interrupt() { -#if TARGET_UNIX || TARGET_BROWSER // TODO: https://github.com/dotnet/runtime/issues/49521 +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI // TODO: https://github.com/dotnet/runtime/issues/49521 WaitSubsystem.Interrupt(this); #endif InterruptInternal(this); @@ -209,7 +209,7 @@ public bool Join(int millisecondsTimeout) return JoinInternal(this, millisecondsTimeout); } -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI [DynamicDependency(nameof(OnThreadExiting))] #endif private void Initialize() @@ -301,7 +301,7 @@ internal void ClearWaitSleepJoinState() private static void OnThreadExiting(Thread thread) { -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI thread.WaitInfo.OnThreadExiting(); #endif } diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index ae55fd112b321..d0c61f25dc848 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -85,7 +85,7 @@ ac_check_funcs ( gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs access inet_ntop Qp2getifaddrs getpid mktemp) -if (HOST_LINUX OR HOST_BROWSER) +if (HOST_LINUX OR HOST_BROWSER OR HOST_WASI) # sysctl is deprecated on Linux and doesn't work on Browser set(HAVE_SYS_SYSCTL_H 0) else () @@ -264,6 +264,8 @@ elseif(HOST_MACCAT) set(HAVE_SYSTEM 0) elseif(HOST_BROWSER) set(HAVE_FORK 0) +elseif(HOST_WASI) + set(HAVE_FORK 0) elseif(HOST_SOLARIS) set(HAVE_GETPROTOBYNAME 1) set(HAVE_NETINET_TCP_H 1) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 56bc7ebaa9179..868eeaffef13b 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -28,7 +28,7 @@ $(CoreClrLibName) $(LibPrefix)$(MonoSharedLibName)$(LibSuffix) $(LibPrefix)$(MonoLibName)$(StaticLibSuffix) - $(MonoStaticLibFileName) + $(MonoStaticLibFileName) $(MonoSharedLibFileName) mono-aot-cross$(ExeSuffix) mono-aot-cross.pdb @@ -46,7 +46,7 @@ $([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross')) $([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'config.h')) true - true + true $(Compiler) clang <_CompilerTargetArch Condition="'$(RealTargetArchitecture)' == ''">$(Platform) @@ -62,7 +62,7 @@ coop - preemptive + preemptive hybrid @@ -70,6 +70,7 @@ true + true true true false @@ -80,12 +81,12 @@ true - + - + <_MonoCMakeArgs Include="-DENABLE_WERROR=1"/> @@ -98,6 +99,7 @@ + @@ -161,6 +163,30 @@ IgnoreStandardErrorWarningFormat="true" /> + + + + + + + + $(ProvisionWasiSdkDir) + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) + wasi-sdk + %(_VersionLines.Identity) + + + + + + + + + @@ -338,13 +364,13 @@ <_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" /> - + <_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages <_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads <_MonoMinimal Condition="'$(MonoWasmThreadsNoUser)' == 'true'">$(_MonoMinimal),wasm_user_threads - + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/> <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> @@ -360,6 +386,16 @@ <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + @@ -487,7 +523,7 @@ <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> - + <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_CONNECT_PORTS=1" /> @@ -512,19 +548,23 @@ $([MSBuild]::EnsureTrailingSlash('$(EMSDK_PATH)')) + $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)')) <_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) "$(MonoProjectRoot.TrimEnd('\/'))" - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' != 'windows'">bash -c 'source $(RepositoryEngineeringCommonDir)native/init-compiler.sh "$(RepositoryEngineeringCommonDir)native" "$(_CompilerTargetArch)" "$(MonoCCompiler)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)' - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' == 'false'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' != 'windows'">bash -c 'source $(RepositoryEngineeringCommonDir)native/init-compiler.sh "$(RepositoryEngineeringCommonDir)native" "$(_CompilerTargetArch)" "$(MonoCCompiler)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)' + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' == 'false'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && emcmake $(_MonoCMakeConfigureCommand)' <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && emcmake $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" + <_MonoCMakeBuildCommand>cmake --build . --target install --config $(Configuration) <_MonoCMakeBuildCommand Condition="'$(MonoVerboseBuild)' == 'true'">$(_MonoCMakeBuildCommand) --verbose <_MonoCMakeBuildCommand Condition="'$(_MonoUseNinja)' != 'true'">$(_MonoCMakeBuildCommand) --parallel $([System.Environment]::ProcessorCount) - <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(HostOS)' != 'windows'">@(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) - <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' != 'windows'">@(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsWasi)' == 'true' and '$(HostOS)' == 'windows'">echo TODOWASI building with cmake is not implemented on windows @@ -716,6 +756,7 @@ + @@ -796,6 +837,7 @@ CheckEnv;GetXcodeDir;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross GenerateRuntimeVersionFile;ProvisionEmscripten;$(MonoDependsOnTargets) + GenerateRuntimeVersionFile;ProvisionWasiSdk;$(MonoDependsOnTargets) @@ -804,7 +846,7 @@ <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true'">$(MonoObjDir)out\bin\$(MonoFileName) <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName) <_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName) - <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true'">true + <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true <_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index c68af8beb34ca..b1a0c147af40b 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -339,7 +339,7 @@ endif() if(HOST_WIN32) set(mini_sources "${mini_sources};${VERSION_FILE_RC_PATH}") # this is generated by GenerateNativeVersionFile in Arcade -elseif(NOT HOST_BROWSER) +elseif(NOT HOST_BROWSER AND NOT HOST_WASI) set(mini_sources "${mini_sources};${VERSION_FILE_PATH}") # this is generated by GenerateNativeVersionFile in Arcade endif() diff --git a/src/mono/mono/profiler/browser.c b/src/mono/mono/profiler/browser.c index 8140b03b535d8..01ec7fee11146 100644 --- a/src/mono/mono/profiler/browser.c +++ b/src/mono/mono/profiler/browser.c @@ -7,7 +7,7 @@ #include -#ifdef TARGET_WASM +#ifdef TARGET_BROWSER #include #include @@ -104,4 +104,4 @@ mono_profiler_init_browser (const char *desc) #endif /* HOST_WASM */ } -#endif /* TARGET_WASM */ +#endif /* TARGET_BROWSER */ diff --git a/src/mono/mono/utils/mono-rand.c b/src/mono/mono/utils/mono-rand.c index cb78275d75677..0f64d3b9eacdb 100644 --- a/src/mono/mono/utils/mono-rand.c +++ b/src/mono/mono/utils/mono-rand.c @@ -121,6 +121,7 @@ mono_getentropy (guchar *buffer, gssize buffer_size, MonoError *error) } #endif /* HAVE_GETENTROPY */ +#if !defined(DISABLE_EGD_SOCKET) static void get_entropy_from_egd (const char *path, guchar *buffer, gssize buffer_size, MonoError *error) { @@ -222,6 +223,7 @@ mono_rand_open (void) return TRUE; } +#endif /* !DISABLE_EGD_SOCKET */ gpointer mono_rand_init (const guchar *seed, gssize seed_size) @@ -250,9 +252,9 @@ mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gssize buffer_size, M if (res == 1) return TRUE; +#elif !defined(DISABLE_EGD_SOCKET) /* getrandom() or getentropy() function is not available: failed with ENOSYS or EPERM. Fall back on reading from /dev/urandom. */ -#endif if (use_egd) { char *socket_path = g_getenv ("MONO_EGD_SOCKET"); @@ -263,21 +265,22 @@ mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gssize buffer_size, M } get_entropy_from_egd (socket_path, buffer, buffer_size, error); g_free (socket_path); - } else { - /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */ - while (buffer_size > 0) { - gssize const err = read (file, buffer, buffer_size); - if (err < 0) { - if (errno == EINTR) - continue; - g_warning("Entropy error! Error in read (%s).", strerror (errno)); - /* exception will be thrown in managed code */ - mono_error_set_execution_engine (error, "Entropy error! Error in read (%s).", strerror (errno)); - return FALSE; - } - buffer += err; - buffer_size -= err; + return TRUE; + } +#endif + /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */ + while (buffer_size > 0) { + gssize const err = read (file, buffer, buffer_size); + if (err < 0) { + if (errno == EINTR) + continue; + g_warning("Entropy error! Error in read (%s).", strerror (errno)); + /* exception will be thrown in managed code */ + mono_error_set_execution_engine (error, "Entropy error! Error in read (%s).", strerror (errno)); + return FALSE; } + buffer += err; + buffer_size -= err; } return TRUE; } From b0068e03c9a331115114793f6dcc77223ade4730 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 21:04:52 +0100 Subject: [PATCH 004/116] wip --- Directory.Build.props | 1 + eng/Subsets.props | 4 ++ src/mono/CMakeLists.txt | 2 +- src/mono/wasi/wasi.proj | 140 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 src/mono/wasi/wasi.proj diff --git a/Directory.Build.props b/Directory.Build.props index 4faaff7eb50c2..1e62178294698 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -157,6 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser + <_portableOS Condition="'$(_runtimeOS)' == 'Wasi'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator diff --git a/eng/Subsets.props b/eng/Subsets.props index e0b667e9cd1f6..ed775e3daf0dd 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -414,6 +414,10 @@ + + + + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index c33dd5845f3e0..463e00fe62bb3 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -251,7 +251,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") add_definitions(-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) add_definitions(-DNO_GLOBALIZATION_SHIM) add_definitions(-D_THREAD_SAFE) - add_definitions(-DGEN_PINVOKE) + # add_definitions(-DGEN_PINVOKE) TODOWASI add_definitions(-DDISABLE_SOCKET_TRANSPORT) add_definitions(-DDISABLE_EGD_SOCKET) add_definitions(-DDISABLE_EVENTPIPE) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj new file mode 100644 index 0000000000000..7110326ac179a --- /dev/null +++ b/src/mono/wasi/wasi.proj @@ -0,0 +1,140 @@ + + + + + wasi-wasm + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'native', '$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)')) + + + + + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib')) + false + false + $(ArtifactsObjDir)wasm + false + + + + + + + + + + + + + + + + + $(NativeBinDir)dotnet.timezones.blat + + + + + + + + + $(WasmObjDir)\pinvoke-table.h + $(WasmObjDir)\wasm_m2n_invoke.g.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(ArtifactsObjDir)wasm/pinvoke-table.h + $(ArtifactsObjDir)wasm/wasm_m2n_invoke.g.h + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3e66f94c2fba9427a6c38dddad92772e7ca5f2fa Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 22:09:17 +0100 Subject: [PATCH 005/116] wip --- src/mono/CMakeLists.txt | 9 -- src/mono/mono.proj | 1 - src/mono/mono/profiler/CMakeLists.txt | 2 +- .../{mono-wasi-driver => include}/driver.h | 0 src/mono/wasi/include/pinvoke.h | 50 ++++++++++ src/mono/wasi/runtime/CMakeLists.txt | 37 +++++++ .../{mono-wasi-driver => runtime}/driver.c | 2 +- .../{mono-wasi-driver => runtime}/stubs.c | 0 .../synthetic-pthread.c | 0 src/mono/wasi/runtime/wasm-config.h.in | 13 +++ src/mono/wasi/sample/console/main.c | 2 +- src/mono/wasi/wasi.proj | 96 ++++++++++++++++++- 12 files changed, 198 insertions(+), 14 deletions(-) rename src/mono/wasi/{mono-wasi-driver => include}/driver.h (100%) create mode 100644 src/mono/wasi/include/pinvoke.h create mode 100644 src/mono/wasi/runtime/CMakeLists.txt rename src/mono/wasi/{mono-wasi-driver => runtime}/driver.c (99%) rename src/mono/wasi/{mono-wasi-driver => runtime}/stubs.c (100%) rename src/mono/wasi/{mono-wasi-driver => runtime}/synthetic-pthread.c (100%) create mode 100644 src/mono/wasi/runtime/wasm-config.h.in diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 463e00fe62bb3..174e13ab5bce2 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -261,15 +261,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") set(INTERNAL_ZLIB 1) set(DISABLE_EXECUTABLES 1) set(STATIC_COMPONENTS 1) - - set(WASI_DRIVER_SOURCES - wasi/mono-wasi-driver/driver.c - wasi/mono-wasi-driver/stubs.c - wasi/mono-wasi-driver/synthetic-pthread.c - ) - add_library(mono-wasi-driver STATIC ${WASI_DRIVER_SOURCES}) - target_compile_options(mono-wasi-driver PRIVATE -Wno-missing-prototypes -Wno-strict-prototypes) - install(TARGETS mono-wasi-driver LIBRARY) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(HOST_WIN32 1) set(EXE_SUFFIX ".exe") diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 868eeaffef13b..2d5e2f3b13a95 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -384,7 +384,6 @@ <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> diff --git a/src/mono/mono/profiler/CMakeLists.txt b/src/mono/mono/profiler/CMakeLists.txt index cd5bf36dfa67d..3fc180dfab683 100644 --- a/src/mono/mono/profiler/CMakeLists.txt +++ b/src/mono/mono/profiler/CMakeLists.txt @@ -36,7 +36,7 @@ if(NOT DISABLE_LIBS) install(TARGETS mono-profiler-aot-static LIBRARY) endif() - if(HOST_WASM) + if(HOST_WASM AND NOT HOST_WASI) add_library(mono-profiler-browser-static STATIC browser.c) target_link_libraries(mono-profiler-browser-static monoapi) set_target_properties(mono-profiler-browser-static PROPERTIES OUTPUT_NAME mono-profiler-browser) diff --git a/src/mono/wasi/mono-wasi-driver/driver.h b/src/mono/wasi/include/driver.h similarity index 100% rename from src/mono/wasi/mono-wasi-driver/driver.h rename to src/mono/wasi/include/driver.h diff --git a/src/mono/wasi/include/pinvoke.h b/src/mono/wasi/include/pinvoke.h new file mode 100644 index 0000000000000..a89030d92f4be --- /dev/null +++ b/src/mono/wasi/include/pinvoke.h @@ -0,0 +1,50 @@ +#ifndef __PINVOKE_H__ +#define __PINVOKE_H__ + +#include + +typedef struct { + const char *name; + void *func; +} PinvokeImport; + +typedef struct { + void *func; + void *arg; +} InterpFtnDesc; + +void* +wasm_dl_lookup_pinvoke_table (const char *name); + +int +wasm_dl_is_pinvoke_table (void *handle); + +void* +wasm_dl_get_native_to_interp (const char *key, void *extra_arg); + +void +mono_wasm_pinvoke_vararg_stub (void); + +typedef void* (*MonoWasmNativeToInterpCallback) (char * cookie); + +void +mono_wasm_install_interp_to_native_callback (MonoWasmNativeToInterpCallback cb); + +typedef struct _MonoInterpMethodArguments MonoInterpMethodArguments; + +int +mono_wasm_interp_method_args_get_iarg (MonoInterpMethodArguments *margs, int i); + +int64_t +mono_wasm_interp_method_args_get_larg (MonoInterpMethodArguments *margs, int i); + +float +mono_wasm_interp_method_args_get_farg (MonoInterpMethodArguments *margs, int i); + +double +mono_wasm_interp_method_args_get_darg (MonoInterpMethodArguments *margs, int i); + +void* +mono_wasm_interp_method_args_get_retval (MonoInterpMethodArguments *margs); + +#endif diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt new file mode 100644 index 0000000000000..1140e760c23e6 --- /dev/null +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.14.5) + +project(mono-wasi-runtime C) + +option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON) +option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF) + +add_executable(dotnet driver.c stubs.c synthetic-pthread.c) + +target_include_directories(dotnet PUBLIC ${MONO_INCLUDES} ${MONO_OBJ_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/include/wasm) +target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-compile.rsp -DCORE_BINDINGS -DGEN_PINVOKE=1) + +set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLAGS}) + +target_link_libraries(dotnet + ${ICU_LIB_DIR}/libicuuc.a + ${ICU_LIB_DIR}/libicui18n.a + ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a + ${MONO_ARTIFACTS_DIR}/libmono-component-debugger-static.a + ${MONO_ARTIFACTS_DIR}/libmono-component-diagnostics_tracing-stub-static.a + ${MONO_ARTIFACTS_DIR}/libmono-ee-interp.a + ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a + ${MONO_ARTIFACTS_DIR}/libmono-ilgen.a + ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a + ${NATIVE_BIN_DIR}/libSystem.Native.a + ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a) + +set_target_properties(dotnet PROPERTIES + LINK_DEPENDS "${NATIVE_BIN_DIR}/src/wasi-default.rsp;" + LINK_FLAGS "@${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-link.rsp ${CONFIGURATION_LINK_FLAGS} " + RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}") + +set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}") + +#TODOWASI wasm-opt + +configure_file(wasm-config.h.in include/wasm/wasm-config.h) diff --git a/src/mono/wasi/mono-wasi-driver/driver.c b/src/mono/wasi/runtime/driver.c similarity index 99% rename from src/mono/wasi/mono-wasi-driver/driver.c rename to src/mono/wasi/runtime/driver.c index fdaf95a571f61..49bda4792833d 100644 --- a/src/mono/wasi/mono-wasi-driver/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -33,7 +33,7 @@ #include #include -#include "wasm/runtime/pinvoke.h" +#include "pinvoke.h" #ifdef GEN_PINVOKE #include "wasm_m2n_invoke.g.h" diff --git a/src/mono/wasi/mono-wasi-driver/stubs.c b/src/mono/wasi/runtime/stubs.c similarity index 100% rename from src/mono/wasi/mono-wasi-driver/stubs.c rename to src/mono/wasi/runtime/stubs.c diff --git a/src/mono/wasi/mono-wasi-driver/synthetic-pthread.c b/src/mono/wasi/runtime/synthetic-pthread.c similarity index 100% rename from src/mono/wasi/mono-wasi-driver/synthetic-pthread.c rename to src/mono/wasi/runtime/synthetic-pthread.c diff --git a/src/mono/wasi/runtime/wasm-config.h.in b/src/mono/wasi/runtime/wasm-config.h.in new file mode 100644 index 0000000000000..c5650ed200b45 --- /dev/null +++ b/src/mono/wasi/runtime/wasm-config.h.in @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +#ifndef __MONO_WASM_CONFIG_H__ +#define __MONO_WASM_CONFIG_H__ + +/* Support for threads is disabled */ +#cmakedefine DISABLE_THREADS + +/* Support for starting user threads is disabled */ +#cmakedefine DISABLE_WASM_USER_THREADS + +#endif/*__MONO_WASM_CONFIG_H__*/ diff --git a/src/mono/wasi/sample/console/main.c b/src/mono/wasi/sample/console/main.c index 8647c4878f2ab..251d88342e449 100644 --- a/src/mono/wasi/sample/console/main.c +++ b/src/mono/wasi/sample/console/main.c @@ -1,5 +1,5 @@ #include -#include "../../mono-wasi-driver/driver.h" +#include "../../runtime/driver.h" int main() { // Assume the runtime pack has been copied into the output directory as 'runtime' diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 7110326ac179a..e4002a5027271 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -13,6 +13,9 @@ false false $(ArtifactsObjDir)wasm + <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp + <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp + <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp false @@ -70,10 +73,69 @@ + + + + + + <_WasiLinkFlags Include="-Wl,--allow-undefined"/> + + + + + + + + <_WasiFlags Include="@(_WasiCommonFlags)" /> + + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + + + + + <_WasmOptConfigurationFlags>@(WasmOptConfigurationFlags, '%3B ') + <_WasiPropsJson> + + + + + + + + + + + + + DependsOnTargets="GenerateWasiPropsAndRspFiles;GenerateManagedToNative;BundleTimeZones"> -g -Os -s -DDEBUG=1 -DENABLE_AOT_PROFILER=1 + -Oz + + $(CMakeConfigurationWasiFlags) + -O2 + $(CMakeConfigurationLinkFlags) --emit-symbol-map + + -DWASI_SDK_PATH="$(WASI_SDK_PATH.TrimEnd('\/'))" + + cmake $(MSBuildThisFileDirectory)runtime + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_BUILD_TYPE=$(Configuration) + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_OBJ_INCLUDES="$(MonoObjDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DICU_LIB_DIR="$(ICULibDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_ARTIFACTS_DIR="$(MonoArtifactsPath.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd" + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1 + $(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath) + + -v + cmake --build . --config $(Configuration) $(CmakeOptions) + echo not implemented for WASI on Windows + + + + From 31758b4bcf286032d004659f9c9d16ac5316cd46 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 7 Nov 2022 22:21:57 +0100 Subject: [PATCH 006/116] wip --- src/native/libs/build-native.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index f896736cfd7b1..636bdcd158f3e 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -42,8 +42,7 @@ __VerboseBuild=false source "$__RepoRootDir"/eng/native/build-commons.sh # Set cross build - -if [[ "$__TargetArch" == wasm ]]; then +if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." exit 1 @@ -51,6 +50,8 @@ if [[ "$__TargetArch" == wasm ]]; then source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) +elif [[ "$__TargetOS" == Wasi ]]; then + export CLR_CC=$(WASI_SDK_PATH)/bin/clang elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true From 013852f5161c67b112d8d771d8406de535adfba3 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 02:57:22 +0100 Subject: [PATCH 007/116] wip --- eng/native/build-commons.sh | 2 +- eng/native/configurecompiler.cmake | 6 +++--- eng/native/configureplatform.cmake | 16 ++++++++++++++-- eng/native/configuretools.cmake | 2 +- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 8 ++++++-- src/mono/CMakeLists.txt | 2 ++ src/mono/wasi/runtime/driver.c | 7 +++++-- src/native/libs/CMakeLists.txt | 10 +++++----- .../System.Globalization.Native/CMakeLists.txt | 4 ++-- .../System.IO.Compression.Native/CMakeLists.txt | 8 ++++---- .../extra_libs.cmake | 2 +- src/native/libs/System.Native/CMakeLists.txt | 6 +++--- .../System.Net.Security.Native/CMakeLists.txt | 4 ++-- src/native/libs/configure.cmake | 4 ++-- src/tests/build.sh | 2 +- 16 files changed, 53 insertions(+), 32 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index ae0761c84a1af..0daa04f26e23a 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -163,7 +163,7 @@ build_native() popd else cmake_command=cmake - if [[ "$build_arch" == "wasm" ]]; then + if [[ "$__TargetOS" == "Browser" ]]; then cmake_command="emcmake cmake" echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c7cb47bfcbb56..844dfc0874a84 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -169,7 +169,7 @@ elseif (CLR_CMAKE_HOST_UNIX) endif () endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) - if(CLR_CMAKE_HOST_BROWSER) + if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI) # The emscripten build has additional warnings so -Werror breaks add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-alloca) @@ -391,7 +391,7 @@ if (CLR_CMAKE_HOST_UNIX) add_definitions(-DLSE_INSTRUCTIONS_ENABLED_BY_DEFAULT) add_compile_options(-mcpu=apple-m1) endif(CLR_CMAKE_HOST_UNIX_ARM64) - elseif(NOT CLR_CMAKE_HOST_BROWSER) + elseif(NOT CLR_CMAKE_HOST_BROWSER AND NOT CLR_CMAKE_HOST_WASI) check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) add_compile_options(-fstack-protector-strong) @@ -789,7 +789,7 @@ if (CLR_CMAKE_HOST_WIN32) message(FATAL_ERROR "MC not found") endif() -elseif (NOT CLR_CMAKE_HOST_BROWSER) +elseif (NOT CLR_CMAKE_HOST_BROWSER AND NOT CLR_CMAKE_HOST_WASI) # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995. # # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 506211704068a..cc358ae63697c 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -214,6 +214,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten) set(CLR_CMAKE_HOST_BROWSER 1) endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_HOST_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + #-------------------------------------------- # This repo builds two set of binaries # 1. binaries which execute on target arch machine @@ -263,6 +267,9 @@ elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) elseif(CLR_CMAKE_HOST_BROWSER) set(CLR_CMAKE_HOST_ARCH_WASM 1) set(CLR_CMAKE_HOST_ARCH "wasm") +elseif(CLR_CMAKE_HOST_WASI) + set(CLR_CMAKE_HOST_ARCH_WASM 1) + set(CLR_CMAKE_HOST_ARCH "wasm") elseif(CLR_CMAKE_HOST_UNIX_MIPS64) set(CLR_CMAKE_HOST_ARCH_MIPS64 1) set(CLR_CMAKE_HOST_ARCH "mips64") @@ -410,6 +417,11 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) set(CLR_CMAKE_TARGET_BROWSER 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_TARGET_UNIX 1) + set(CLR_CMAKE_TARGET_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + if(CLR_CMAKE_TARGET_UNIX) if(CLR_CMAKE_TARGET_ARCH STREQUAL x64) set(CLR_CMAKE_TARGET_UNIX_AMD64 1) @@ -443,7 +455,7 @@ else() endif(CLR_CMAKE_TARGET_UNIX) # check if host & target os/arch combination are valid -if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)) +if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI) if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows)) message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}") endif() @@ -455,7 +467,7 @@ if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)) endif() endif() -if(NOT CLR_CMAKE_TARGET_BROWSER) +if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) # The default linker on Solaris also does not support PIE. if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 07a3bbfafe4dd..1f800b0f89789 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -6,7 +6,7 @@ if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$") set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}") endif() -if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) +if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(APPLE) set(TOOLSET_PREFIX "") diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index c3bf9adbbef53..22c6b88d79823 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -92,7 +92,7 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then cmake_command="$SCAN_BUILD_COMMAND $cmake_command" fi -if [[ "$host_arch" == "wasm" ]]; then +if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" fi diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 75012240633da..4b3f006c5e144 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -148,8 +148,10 @@ initDistroRidGlobal() initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}" if [ "$buildArch" = "wasm" ]; then - __DistroRid=browser-wasm - export __DistroRid + if [ "$targetOs" = "Browser" ]; then + __DistroRid=browser-wasm + export __DistroRid + fi fi if [ -z "${__DistroRid}" ]; then @@ -186,6 +188,8 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" + elif [ "$targetOs" = "Wasi" ]; then + distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" elif [ "$targetOs" = "illumos" ]; then diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 174e13ab5bce2..bbe2b5e1e0966 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -743,6 +743,8 @@ elseif(GC_SUSPEND STREQUAL "default") # use preemptive elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") # use preemptive + elseif(TARGET_SYSTEM_NAME STREQUAL "Wasi") + # use preemptive else() set(ENABLE_HYBRID_SUSPEND 1) endif() diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 49bda4792833d..7530042b6539e 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -155,7 +155,7 @@ typedef struct } FileStatus; char* gai_strerror(int code) { - char result[256]; + char* result = malloc(256); sprintf(result, "Error code %i", code); return result; } @@ -780,7 +780,10 @@ void add_assembly(const char* base_dir, const char *name) { rewind(fileptr); buffer = (unsigned char *)malloc(filelen * sizeof(char)); - fread(buffer, filelen, 1, fileptr); + if(!fread(buffer, filelen, 1, fileptr)) { + printf("Failed to load %s\n", filename); + fflush(stdout); + } fclose(fileptr); assert(mono_wasm_add_assembly(name, buffer, filelen)); diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 26ff71928ffb6..056a46411f9be 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -35,7 +35,7 @@ else () set(STATIC_LIB_DESTINATION .) endif () -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(CMAKE_MACOSX_RPATH ON) if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) @@ -48,7 +48,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common) add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(GEN_SHARED_LIB 0) set(STATIC_LIB_DESTINATION .) endif () @@ -133,10 +133,10 @@ endif () add_subdirectory(System.IO.Compression.Native) -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) include(configure.cmake) - if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) + if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) add_subdirectory(System.IO.Ports.Native) endif () @@ -154,7 +154,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) add_subdirectory(System.Native) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) # skip for now elseif (CLR_CMAKE_TARGET_MACCATALYST) add_subdirectory(System.Net.Security.Native) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 5e2fb2948cc43..0ee4e400c5f4c 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -77,11 +77,11 @@ if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS endif() # time zone names are filtered out of icu data for the browser and associated functionality is disabled -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt index a44f847dfca43..78f4d2ba90b19 100644 --- a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +++ b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt @@ -6,7 +6,7 @@ set(NATIVECOMPRESSION_SOURCES pal_zlib.c ) -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) if (CLR_CMAKE_USE_SYSTEM_BROTLI) add_definitions(-DFEATURE_USE_SYSTEM_BROTLI) @@ -25,11 +25,11 @@ if (NOT CLR_CMAKE_TARGET_BROWSER) ) endif () -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(NATIVE_LIBS_EXTRA) append_extra_compression_libs(NATIVE_LIBS_EXTRA) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) include(${CLR_SRC_NATIVE_DIR}/external/zlib.cmake) add_definitions(-DINTERNAL_ZLIB) set(NATIVECOMPRESSION_SOURCES ${ZLIB_SOURCES} ${NATIVECOMPRESSION_SOURCES}) @@ -118,7 +118,7 @@ else () ) endif () - if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVECOMPRESSION_SOURCES ${NATIVECOMPRESSION_SOURCES} entrypoints.c) endif () diff --git a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake index b10776372f6cf..78530ae98e8ff 100644 --- a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake +++ b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake @@ -1,7 +1,7 @@ macro(append_extra_compression_libs NativeLibsExtra) # TODO: remove the mono-style HOST_ variable checks once Mono is using eng/native/configureplatform.cmake to define the CLR_CMAKE_TARGET_ defines - if (CLR_CMAKE_TARGET_BROWSER OR HOST_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR HOST_BROWSER OR CLR_CMAKE_TARGET_WASI OR HOST_WASI) # nothing special to link elseif (CLR_CMAKE_TARGET_ANDROID OR HOST_ANDROID) # need special case here since we want to link against libz.so but find_package() would resolve libz.a diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 61cd36da93b79..5a3fb30fd9d1c 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -79,7 +79,7 @@ else () pal_iossupportversion.c) endif () -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) list (APPEND NATIVE_SOURCES pal_networkchange.c) endif () @@ -107,7 +107,7 @@ if (GEN_SHARED_LIB) ${NATIVE_LIBS_EXTRA} ) - if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) add_custom_command(TARGET System.Native POST_BUILD COMMENT "Verifying System.Native entry points against entrypoints.c " COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh @@ -121,7 +121,7 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Native PROGRAMS .) endif () -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVE_SOURCES ${NATIVE_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Net.Security.Native/CMakeLists.txt b/src/native/libs/System.Net.Security.Native/CMakeLists.txt index 6fbe18f76872e..50c9228fe3dd3 100644 --- a/src/native/libs/System.Net.Security.Native/CMakeLists.txt +++ b/src/native/libs/System.Net.Security.Native/CMakeLists.txt @@ -19,7 +19,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGSS_SOURCES ${NATIVEGSS_SOURCES} entrypoints.c) endif() @@ -35,7 +35,7 @@ if (GEN_SHARED_LIB) ${NATIVE_LIBS_EXTRA} ) - if (NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) add_custom_command(TARGET System.Net.Security.Native POST_BUILD COMMENT "Verifying System.Net.Security.Native entry points against entrypoints.c " COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index bc6c133fe8921..068a10e2947b7 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -572,7 +572,7 @@ elseif(CLR_CMAKE_TARGET_ANDROID) unset(HAVE_ALIGNED_ALLOC) # only exists on newer Android set(HAVE_CLOCK_MONOTONIC 1) set(HAVE_CLOCK_REALTIME 1) -elseif(CLR_CMAKE_TARGET_BROWSER) +elseif(CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(HAVE_FORK 0) else() if(CLR_CMAKE_TARGET_OSX) @@ -1002,7 +1002,7 @@ set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES}) set (HAVE_INOTIFY 0) if (HAVE_INOTIFY_INIT AND HAVE_INOTIFY_ADD_WATCH AND HAVE_INOTIFY_RM_WATCH) set (HAVE_INOTIFY 1) -elseif (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_BROWSER) +elseif (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) message(FATAL_ERROR "Cannot find inotify functions on a Linux platform.") endif() diff --git a/src/tests/build.sh b/src/tests/build.sh index c6f30ccf3670c..319b5958a99ca 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "Wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From 3783bcf5b0e31390d8e846f86a33bc4dee500104 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 02:58:11 +0100 Subject: [PATCH 008/116] wip --- src/native/libs/build-native.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 636bdcd158f3e..87482f7ad11ee 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -51,7 +51,11 @@ if [[ "$__TargetOS" == Browser ]]; then export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == Wasi ]]; then - export CLR_CC=$(WASI_SDK_PATH)/bin/clang + export CLR_CC="$__RepoRootDir"/src/mono/wasi/wasi-sdk/bin/clang + export TARGET_BUILD_ARCH=wasm + __CMakeArgs="-DCLR_CMAKE_TARGET_OS=Wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$__RepoRootDir/src/mono/wasi/wasi-sdk/ -DCMAKE_TOOLCHAIN_FILE=$__RepoRootDir/src/mono/wasi/wasi-sdk/share/cmake/wasi-sdk.cmake" + echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! + exit 0 elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true From b304cb5d4eef04cd58895914b9492cd143f2cc61 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 03:46:40 +0100 Subject: [PATCH 009/116] wip --- eng/targetingpacks.targets | 2 +- .../src/System/Environment.NativeAot.cs | 2 +- src/coreclr/scripts/coreclr_arguments.py | 2 +- .../System.CodeDom/Directory.Build.props | 2 +- .../System.Console/src/System.Console.csproj | 20 +++++++++++++++++-- .../System.Data.Odbc/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 6 ++++++ .../src/System.IO.Compression.csproj | 4 ++-- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.IO.MemoryMappedFiles.csproj | 4 ++-- .../System.IO.Pipes/Directory.Build.props | 2 +- .../System.IO.Ports/Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 6 ++++++ .../System.Linq/src/System.Linq.csproj | 4 ++-- .../src/System.Net.Http.csproj | 13 ++++++------ .../Directory.Build.props | 2 +- .../src/System.Net.Mail.csproj | 6 +++--- .../Directory.Build.props | 2 +- .../src/System.Net.NameResolution.csproj | 8 ++++---- .../Directory.Build.props | 2 +- .../System.Net.Ping/Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 12 +++++++++++ .../src/System.Net.Primitives.csproj | 6 +++--- .../System.Net.Requests/Directory.Build.props | 2 +- .../System.Net.Security/Directory.Build.props | 2 +- .../System.Net.Sockets/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.Net.WebClient.csproj | 6 +++--- .../src/System.Net.WebProxy.csproj | 6 +++--- .../src/System.Net.WebSockets.Client.csproj | 6 +++++- .../Net/WebSockets/WebSocketHandle.Managed.cs | 5 ++++- .../src/System.Net.WebSockets.csproj | 4 ++-- .../src/CompatibilitySuppressions.xml | 12 +++++++++++ ...em.Runtime.Serialization.Formatters.csproj | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.Security.Cryptography.csproj | 6 +++--- src/native/libs/build-native.cmd | 1 + 48 files changed, 127 insertions(+), 66 deletions(-) diff --git a/eng/targetingpacks.targets b/eng/targetingpacks.targets index 744a0cd20b469..e7386ccb5e8d4 100644 --- a/eng/targetingpacks.targets +++ b/eng/targetingpacks.targets @@ -41,7 +41,7 @@ RuntimeFrameworkName="$(LocalFrameworkOverrideName)" LatestRuntimeFrameworkVersion="$(ProductVersion)" RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.Mono.**RID**" - RuntimePackRuntimeIdentifiers="linux-arm;linux-armv6;linux-arm64;linux-musl-arm64;linux-bionic-arm64;linux-loongarch64;linux-musl-x64;linux-bionic-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" + RuntimePackRuntimeIdentifiers="linux-arm;linux-armv6;linux-arm64;linux-musl-arm64;linux-bionic-arm64;linux-loongarch64;linux-musl-x64;linux-bionic-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;wasi-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" RuntimePackLabels="Mono" Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/> true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst \ No newline at end of file diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 1c45c5a8f932a..0da14bee7a594 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -47,7 +47,7 @@ Common\Interop\Android\Interop.Libraries.cs - + + + + + + + + + + + diff --git a/src/libraries/System.Data.Odbc/Directory.Build.props b/src/libraries/System.Data.Odbc/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Data.Odbc/Directory.Build.props +++ b/src/libraries/System.Data.Odbc/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props +++ b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/Directory.Build.props b/src/libraries/System.Diagnostics.Process/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Diagnostics.Process/Directory.Build.props +++ b/src/libraries/System.Diagnostics.Process/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props b/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props index 525d9a0d12ab6..ed868ac7937d9 100644 --- a/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props +++ b/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props @@ -7,6 +7,6 @@ 4.0.0.0 Microsoft true - browser;android;ios;tvos + browser;wasi;android;ios;tvos diff --git a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props index f3f5769f93616..76ee806bc1a2b 100644 --- a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props +++ b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props @@ -3,6 +3,6 @@ ECMA true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml b/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml index 5914451471cbb..8d4094d4b8c18 100644 --- a/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml @@ -7,6 +7,12 @@ ref/net7.0/System.IO.Compression.dll runtimes/browser/lib/net7.0/System.IO.Compression.dll + + CP0001 + T:System.IO.Compression.ZLibException + ref/net7.0/System.IO.Compression.dll + runtimes/wasi/lib/net7.0/System.IO.Compression.dll + CP0001 T:System.IO.Compression.ZLibException diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 150b3efdb70ea..35d81f1850284 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -50,7 +50,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + Microsoft true - browser;ios;tvos + browser;wasi;ios;tvos maccatalyst \ No newline at end of file diff --git a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props +++ b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index 9be9a376620fd..bf933e1f51356 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -80,7 +80,7 @@ - + Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.Ports/Directory.Build.props b/src/libraries/System.IO.Ports/Directory.Build.props index 42ef4884cef5d..a93b4c306837b 100644 --- a/src/libraries/System.IO.Ports/Directory.Build.props +++ b/src/libraries/System.IO.Ports/Directory.Build.props @@ -2,6 +2,6 @@ true - browser;android;ios;tvos + browser;wasi;android;ios;tvos diff --git a/src/libraries/System.Linq/src/CompatibilitySuppressions.xml b/src/libraries/System.Linq/src/CompatibilitySuppressions.xml index bbdfa98547610..df413125cabf9 100644 --- a/src/libraries/System.Linq/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Linq/src/CompatibilitySuppressions.xml @@ -19,6 +19,12 @@ ref/net7.0/System.Linq.dll runtimes/browser/lib/net7.0/System.Linq.dll + + CP0001 + T:System.Linq.Grouping`2 + ref/net7.0/System.Linq.dll + runtimes/wasi/lib/net7.0/System.Linq.dll + CP0001 T:System.Linq.Grouping`2 diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index e0509ff215fd8..43f57a18c26e2 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -1,11 +1,11 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true + true diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index fadb5f1bd51ec..9099c4b182dfa 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -17,6 +17,7 @@ $(DefineConstants);TARGET_MACCATALYST $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI $(MSBuildThisFileDirectory)ILLink\ @@ -24,7 +25,7 @@ - + @@ -156,7 +157,7 @@ Link="Common\System\Text\ValueStringBuilder.AppendSpanFormattable.cs" /> - + @@ -304,12 +305,12 @@ - + - + @@ -385,7 +386,7 @@ - + - + diff --git a/src/libraries/System.Net.HttpListener/Directory.Build.props b/src/libraries/System.Net.HttpListener/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Net.HttpListener/Directory.Build.props +++ b/src/libraries/System.Net.HttpListener/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 5d2ce4cc28099..12dc021efc05a 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -1,7 +1,7 @@  true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -78,12 +78,12 @@ Link="Common\System\HexConverter.cs" /> - + - + diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 6d7ee08de0bc5..1e567b1ec0934 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Browser.txt + SR.SystemNetNameResolution_PlatformNotSupported + ExcludeApiList.PNSE.Browser.txt @@ -100,7 +100,7 @@ - + diff --git a/src/libraries/System.Net.NetworkInformation/Directory.Build.props b/src/libraries/System.Net.NetworkInformation/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.NetworkInformation/Directory.Build.props +++ b/src/libraries/System.Net.NetworkInformation/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Ping/Directory.Build.props b/src/libraries/System.Net.Ping/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Ping/Directory.Build.props +++ b/src/libraries/System.Net.Ping/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml b/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml index b359c8b66a64f..cba3412551413 100644 --- a/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml @@ -13,6 +13,18 @@ ref/net7.0/System.Net.Primitives.dll runtimes/browser/lib/net7.0/System.Net.Primitives.dll + + CP0001 + T:System.Net.CookieVariant + ref/net7.0/System.Net.Primitives.dll + runtimes/wasi/lib/net7.0/System.Net.Primitives.dll + + + CP0001 + T:System.Net.PathList + ref/net7.0/System.Net.Primitives.dll + runtimes/wasi/lib/net7.0/System.Net.Primitives.dll + CP0001 T:System.Net.CookieVariant diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index b77d6366c7a96..0484a5a990bbd 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -2,7 +2,7 @@ true false - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL @@ -113,7 +113,7 @@ - + @@ -144,7 +144,7 @@ - + Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Security/Directory.Build.props b/src/libraries/System.Net.Security/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Security/Directory.Build.props +++ b/src/libraries/System.Net.Security/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/Directory.Build.props b/src/libraries/System.Net.Sockets/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Sockets/Directory.Build.props +++ b/src/libraries/System.Net.Sockets/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/Directory.Build.props b/src/libraries/System.Net.WebClient/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Net.WebClient/Directory.Build.props +++ b/src/libraries/System.Net.WebClient/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj index fdbfd8f017d68..447c8b7dc4e50 100644 --- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj +++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetWebClient_PlatformNotSupported + SR.SystemNetWebClient_PlatformNotSupported - + diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index fbe0e197d113c..7fd1104f3a853 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi - - + + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index b7da9d3e90bec..67e8c09e735c5 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -1,11 +1,15 @@ True - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER + + $(DefineConstants);TARGET_WASI + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs index 0ab159c1c42cb..9451871439f60 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs @@ -280,8 +280,9 @@ private static HttpMessageInvoker SetupInvoker(ClientWebSocketOptions options, o handler.PooledConnectionLifetime = TimeSpan.Zero; handler.CookieContainer = options.Cookies; handler.UseCookies = options.Cookies != null; +#if !TARGET_WASI handler.SslOptions.RemoteCertificateValidationCallback = options.RemoteCertificateValidationCallback; - +#endif handler.Credentials = options.UseDefaultCredentials ? CredentialCache.DefaultCredentials : options.Credentials; @@ -297,9 +298,11 @@ private static HttpMessageInvoker SetupInvoker(ClientWebSocketOptions options, o if (options._clientCertificates?.Count > 0) // use field to avoid lazily initializing the collection { +#if !TARGET_WASI Debug.Assert(handler.SslOptions.ClientCertificates == null); handler.SslOptions.ClientCertificates = new X509Certificate2Collection(); handler.SslOptions.ClientCertificates.AddRange(options.ClientCertificates); +#endif } return new HttpMessageInvoker(handler); diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index c0c4ded0d332a..2e8b009d92d09 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -1,7 +1,7 @@ True - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -40,7 +40,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml b/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml index edac62595c48a..5dca51f6147da 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml @@ -37,6 +37,18 @@ ref/net7.0/System.Runtime.Serialization.Formatters.dll runtimes/browser/lib/net7.0/System.Runtime.Serialization.Formatters.dll + + CP0001 + T:System.Runtime.Serialization.SerializationEventHandler + ref/net7.0/System.Runtime.Serialization.Formatters.dll + runtimes/wasi/lib/net7.0/System.Runtime.Serialization.Formatters.dll + + + CP0001 + T:System.Runtime.Serialization.TypeLoadExceptionHolder + ref/net7.0/System.Runtime.Serialization.Formatters.dll + runtimes/wasi/lib/net7.0/System.Runtime.Serialization.Formatters.dll + CP0001 T:System.Runtime.Serialization.SerializationEventHandler diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index a9438b21825df..2cb707b45af45 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android $(MSBuildThisFileDirectory)ILLink\ true diff --git a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props index e7d357018da7b..7d407028f6632 100644 --- a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props +++ b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props @@ -4,6 +4,6 @@ Microsoft true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst diff --git a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props index c4db04cc6c252..d13e60dc1f013 100644 --- a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props b/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props b/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props b/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props index 1e1390709dcc5..4342451c25a83 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - windows;browser;android;ios;tvos + windows;browser;wasi;android;ios;tvos diff --git a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props index 1f799d605feb9..e3cd1bcddea8e 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props b/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index dadeb106d6613..8b16b293ac37c 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -2,7 +2,7 @@ true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $(NoWarn);CA5350;CA5351;CA5379;CA5384;SYSLIB0026 $(NoWarn);CS0809 @@ -549,7 +549,7 @@ System\Security\Cryptography\X509Certificates\Asn1\PolicyInformationAsn.xml - + @@ -1835,7 +1835,7 @@ - + diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index ae97ff4e3262f..3de7efd78bb84 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,6 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) +if /i [%1] == [Wasi] ( set __TargetOS=Wasi&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) From aa93b6f28919cecb5d2241b984e33801d66a444e Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 04:12:45 +0100 Subject: [PATCH 010/116] wip --- .../System.Console/src/System.Console.csproj | 25 ++++++------------- .../src/System/ConsolePal.Unix.cs | 2 ++ .../src/System.Text.Encodings.Web.csproj | 3 ++- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 0da14bee7a594..4a08e5d43543e 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -8,6 +8,9 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole + + $(DefineConstants);TARGET_WASI + @@ -63,22 +66,6 @@ - - - - - - - - - - @@ -172,7 +159,7 @@ Link="Common\System\IO\Win32Marshal.cs" /> - + + Link="Common\Interop\Unix\Interop.SetTerminalInvalidationHandler.cs" + Condition="'$(TargetPlatformIdentifier)' != 'Wasi'" + /> - $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-Wasi;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true @@ -18,6 +18,7 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI From e6933d966b38b564cdebd9f8295d558a417af3be Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 10:02:05 +0100 Subject: [PATCH 011/116] wip --- src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs | 3 ++- .../Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index a4f11204e48ba..f6f0c00812f42 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,7 +20,8 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser, + Wasi = 2048, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | Wasi, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index b71b554f37ca1..a22a168e0aacb 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -655,6 +655,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, + "wasi" => Xunit.TestPlatforms.Wasi, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, From 6cc9bd1a41fe3ccacb34861572be592fb6dd951b Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 12:25:06 +0100 Subject: [PATCH 012/116] wip --- eng/native/build-commons.sh | 11 +++++++ eng/native/gen-buildsys.sh | 6 ++++ eng/native/init-distro-rid.sh | 6 ++++ .../Directory.Build.props | 2 +- .../src/System.Net.Http.csproj | 3 ++ .../Directory.Build.props | 2 +- src/mono/Directory.Build.props | 2 ++ src/mono/mono.proj | 32 +++++++++++++------ src/mono/mono/metadata/profiler.c | 4 +-- src/mono/wasi/.gitignore | 4 +-- src/mono/wasi/Makefile | 25 --------------- src/mono/wasi/include/pinvoke.h | 2 ++ .../{runtime => include}/wasm-config.h.in | 2 ++ src/mono/wasi/runtime/CMakeLists.txt | 2 +- src/mono/wasi/runtime/driver.c | 1 + src/native/libs/build-native.sh | 4 +++ 16 files changed, 65 insertions(+), 43 deletions(-) rename src/mono/wasi/{runtime => include}/wasm-config.h.in (85%) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 0daa04f26e23a..419ddfb72c259 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -168,6 +168,17 @@ build_native() echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" exit_code="$?" + elif [[ "$__TargetOS" == "Wasi" ]]; then + pushd "$intermediatesDir" + + echo "Executing $buildTool $target -j $__NumProc" + "$buildTool" $target -j "$__NumProc" + exit_code="$?" + + popd + elif [[ "$build_arch" == "wasm" ]]; then + echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!! unexpected" + exit 1 else # For non-wasm Unix scenarios, we may have to use an old version of CMake that doesn't support # multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation. diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 22c6b88d79823..1f921bf3333c9 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -94,6 +94,12 @@ fi if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" + echo "!!!!!!!!!!!!!!! emcmake !!!!!!!!!!!!!!" +elif [[ "$host_arch" == "wasm" && "$2" =~ "-Wasi-" ]]; then + true +elif [[ "$host_arch" == "wasm" ]]; then + echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!! unexpected2" + exit 1 fi # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 4b3f006c5e144..2e5aab352f4e5 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -151,6 +151,12 @@ initDistroRidGlobal() if [ "$targetOs" = "Browser" ]; then __DistroRid=browser-wasm export __DistroRid + elif [ "$targetOs" = "Wasi" ]; then + __DistroRid=wasi-wasm + export __DistroRid + else + echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!! unexpected3" + exit 1 fi fi diff --git a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props +++ b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 9099c4b182dfa..780a473f282e4 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -5,6 +5,9 @@ $(DefineConstants);HTTP_DLL $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent) true + diff --git a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 8795f72f59e69..6c1aece9573a3 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -59,7 +59,9 @@ true true true + true <_MonoUseLLVMPackage Condition="'$(MonoLLVMDir)' == '' and '$(MonoEnableLLVM)' == 'true'">true <_MonoUseAOTLLVMPackage Condition="'$(MonoAOTLLVMDir)' == '' and '$(MonoAOTEnableLLVM)' == 'true'">true diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 2d5e2f3b13a95..e86b229cb29a9 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -42,6 +42,9 @@ true true true + true $([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross')) $([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'config.h')) @@ -385,17 +388,26 @@ <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> - + + + + <_MonoBuildEnv Include="TARGET_BUILD_ARCH=wasm" /> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + + + <_MonoCCOption>CC="$(XcodeDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" diff --git a/src/mono/mono/metadata/profiler.c b/src/mono/mono/metadata/profiler.c index d632fc3b6f62e..0a76a5dace43e 100644 --- a/src/mono/mono/metadata/profiler.c +++ b/src/mono/mono/metadata/profiler.c @@ -22,7 +22,7 @@ typedef void (*MonoProfilerInitializer) (const char *); #define OLD_INITIALIZER_NAME "mono_profiler_startup" #define NEW_INITIALIZER_NAME "mono_profiler_init" -#if defined(TARGET_WASM) && defined(MONO_CROSS_COMPILE) +#if defined(TARGET_BROWSER) && defined(MONO_CROSS_COMPILE) MONO_API void mono_profiler_init_browser (const char *desc); #endif @@ -178,7 +178,7 @@ mono_profiler_load (const char *desc) mname = g_strdup (desc); } -#if defined(TARGET_WASM) && defined(MONO_CROSS_COMPILE) +#if defined(TARGET_BROWSER) && defined(MONO_CROSS_COMPILE) // this code could be running as part of mono-aot-cross.exe // in case of WASM we staticaly link in the browser.c profiler plugin if(strcmp (mname, "browser") == 0) { diff --git a/src/mono/wasi/.gitignore b/src/mono/wasi/.gitignore index e81db9a853fcb..faf8da9dc8468 100644 --- a/src/mono/wasi/.gitignore +++ b/src/mono/wasi/.gitignore @@ -1,3 +1 @@ -!Makefile -.stamp-wasm-install-and-select* -wasi-sdk* +wasi-sdk/** diff --git a/src/mono/wasi/Makefile b/src/mono/wasi/Makefile index 53ae87f4f76ea..00a4306a9c920 100644 --- a/src/mono/wasi/Makefile +++ b/src/mono/wasi/Makefile @@ -24,28 +24,3 @@ build-all: $(WASI_SDK_CLANG) rm -rf $(WASI_BIN_DIR)/libmono-component-diagnostics_tracing-static.a mkdir -p $(WASI_BIN_DIR)/include/mono-wasi cp mono-wasi-driver/*.h $(WASI_BIN_DIR)/include/mono-wasi - -$(WASI_SDK_CLANG): - mkdir -p $(WASI_OBJ_DIR) - cd $(WASI_OBJ_DIR) && \ - wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASI_SDK_VERSION)/wasi-sdk-$(WASI_SDK_VERSION).0-linux.tar.gz && \ - tar xf wasi-sdk-*.tar.gz - -.stamp-wasmtime-$(WASMTIME_VERSION): - @echo "** Provisioning wasmtime $(WASMTIME_VERSION) **" - rm -Rf $(WASMTIME_DIR) && \ - wget -q https://github.com/bytecodealliance/wasmtime/releases/download/$(WASMTIME_VERSION)/$(WASMTIME_DIR_NAME).tar.xz -O - | tar -C `dirname $(WASMTIME_DIR)` -Jxf - && \ - touch $@ - -.stamp-ninja-$(NINJA_VERSION): - @echo "** Provisioning ninja $(NINJA_VERSION) **" - rm -Rf $(NINJA_DIR); \ - mkdir $(NINJA_DIR) && \ - wget -q https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-linux.zip -O $(NINJA_DIR)/ninja.zip && \ - (cd $(NINJA_DIR) && unzip -q ninja.zip && rm ninja.zip) && \ - touch $@ - -provision-deps: .stamp-wasmtime-$(WASMTIME_VERSION) .stamp-ninja-$(NINJA_VERSION) - @echo "-------------------------------------------" - @echo "** Installed wasmtime in $(WASMTIME_DIR)" - @echo "** Installed ninja in $(NINJA_DIR)" diff --git a/src/mono/wasi/include/pinvoke.h b/src/mono/wasi/include/pinvoke.h index a89030d92f4be..78c30f22693c8 100644 --- a/src/mono/wasi/include/pinvoke.h +++ b/src/mono/wasi/include/pinvoke.h @@ -1,3 +1,5 @@ +// TODOWASI deduplicate src/mono/wasm/runtime/pinvoke.h + #ifndef __PINVOKE_H__ #define __PINVOKE_H__ diff --git a/src/mono/wasi/runtime/wasm-config.h.in b/src/mono/wasi/include/wasm-config.h.in similarity index 85% rename from src/mono/wasi/runtime/wasm-config.h.in rename to src/mono/wasi/include/wasm-config.h.in index c5650ed200b45..4c33fd663663c 100644 --- a/src/mono/wasi/runtime/wasm-config.h.in +++ b/src/mono/wasi/include/wasm-config.h.in @@ -11,3 +11,5 @@ #cmakedefine DISABLE_WASM_USER_THREADS #endif/*__MONO_WASM_CONFIG_H__*/ + +// TODOWASI deduplicate with src/mono/wasm/runtime/wasm-config.h.in \ No newline at end of file diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 1140e760c23e6..815be6c7c7e6b 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -34,4 +34,4 @@ set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}") #TODOWASI wasm-opt -configure_file(wasm-config.h.in include/wasm/wasm-config.h) +configure_file(../include/wasm-config.h.in include/wasm/wasm-config.h) diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 7530042b6539e..b7691ab4da50f 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -278,6 +278,7 @@ int64_t SystemNative_GetTimestamp2() { : 0; } +// TODOWASI replace with native libs static PinvokeImport SystemNativeImports [] = { {"SystemNative_GetEnv", SystemNative_GetEnv }, {"SystemNative_GetEnviron", SystemNative_GetEnviron }, diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 87482f7ad11ee..fcabe57c32091 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -49,6 +49,7 @@ if [[ "$__TargetOS" == Browser ]]; then fi source "$EMSDK_PATH"/emsdk_env.sh + echo !!!!!!!!!!!!!!!!! browser-wasm !!!!!!!!!!!!!!!!! export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == Wasi ]]; then export CLR_CC="$__RepoRootDir"/src/mono/wasi/wasi-sdk/bin/clang @@ -56,6 +57,9 @@ elif [[ "$__TargetOS" == Wasi ]]; then __CMakeArgs="-DCLR_CMAKE_TARGET_OS=Wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$__RepoRootDir/src/mono/wasi/wasi-sdk/ -DCMAKE_TOOLCHAIN_FILE=$__RepoRootDir/src/mono/wasi/wasi-sdk/share/cmake/wasi-sdk.cmake" echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! exit 0 +elif [[ "$__TargetArch" == wasm ]]; then + echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! unexpected4 + exit 1 elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true From 709f54eda1e76061903fba3200c2d095753c6eda Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 14:54:46 +0100 Subject: [PATCH 013/116] wip --- src/mono/Directory.Build.props | 2 +- src/mono/mono.proj | 6 +++--- src/native/libs/build-native.sh | 21 +++++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 6c1aece9573a3..ef74df52c446a 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -40,7 +40,7 @@ $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasm', 'emsdk')) - true + true $(ProvisionEmscriptenDir.Replace('\', '/')) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e86b229cb29a9..70dc73b3955f1 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -144,15 +144,15 @@ - .sh + .ps1 $(ProvisionEmscriptenDir) $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasm')) emsdk %(_VersionLines.Identity) - ./emsdk$(EmsdkExt) install $(EmscriptenVersion) - ./emsdk$(EmsdkExt) activate $(EmscriptenVersion) + $(EMSDK_PATH)/emsdk$(EmsdkExt) install $(EmscriptenVersion) + $(EMSDK_PATH)/emsdk$(EmsdkExt) activate $(EmscriptenVersion) powershell -NonInteractive -command "& $(InstallCmd); Exit $LastExitCode " powershell -NonInteractive -command "& $(ActivateCmd); Exit $LastExitCode " diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index fcabe57c32091..aaa1c22942722 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -44,17 +44,30 @@ source "$__RepoRootDir"/eng/native/build-commons.sh # Set cross build if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then - echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." - exit 1 + if [[ -d "$__RepoRootDir"/src/mono/wasm/emsdk/ ]]; then + export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + else + echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." + exit 1 + fi fi source "$EMSDK_PATH"/emsdk_env.sh echo !!!!!!!!!!!!!!!!! browser-wasm !!!!!!!!!!!!!!!!! export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == Wasi ]]; then - export CLR_CC="$__RepoRootDir"/src/mono/wasi/wasi-sdk/bin/clang + if [[ -z "$WASI_SDK_PATH" ]]; then + if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk/ ]]; then + export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + else + echo "Error: You need to set the WASI_SDK_PATH environment variable pointing to the WASI SDK root." + exit 1 + fi + fi + + export CLR_CC="$WASI_SDK_PATH"bin/clang export TARGET_BUILD_ARCH=wasm - __CMakeArgs="-DCLR_CMAKE_TARGET_OS=Wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$__RepoRootDir/src/mono/wasi/wasi-sdk/ -DCMAKE_TOOLCHAIN_FILE=$__RepoRootDir/src/mono/wasi/wasi-sdk/share/cmake/wasi-sdk.cmake" + __CMakeArgs="-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.cmake" echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! exit 0 elif [[ "$__TargetArch" == wasm ]]; then From 0f35f0ee86c6dfeb050ddce56427d6ce9e99e7ab Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 16:03:37 +0100 Subject: [PATCH 014/116] wip --- Directory.Build.props | 4 +- eng/Subsets.props | 10 +- eng/build.ps1 | 16 +- eng/build.sh | 10 +- eng/targetingpacks.targets | 2 +- eng/testing/wasi-provisioning.targets | 3 + .../src/System/Environment.NativeAot.cs | 2 +- src/coreclr/scripts/coreclr_arguments.py | 2 +- .../src/runtime.compatibility.json | 11 + .../src/runtime.json | 10 + .../src/runtimeGroups.props | 5 + src/libraries/OSGroups.json | 2 + .../System.CodeDom/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../System.Console/src/System.Console.csproj | 13 +- .../src/System/ConsolePal.Unix.cs | 2 + .../System.Data.Odbc/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 6 + .../src/System.IO.Compression.csproj | 4 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.IO.MemoryMappedFiles.csproj | 4 +- .../System.IO.Pipes/Directory.Build.props | 2 +- .../System.IO.Ports/Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 6 + .../System.Linq/src/System.Linq.csproj | 4 +- .../src/System.Net.Http.csproj | 16 +- .../Directory.Build.props | 2 +- .../src/System.Net.Mail.csproj | 6 +- .../Directory.Build.props | 2 +- .../src/System.Net.NameResolution.csproj | 8 +- .../Directory.Build.props | 2 +- .../System.Net.Ping/Directory.Build.props | 2 +- .../src/CompatibilitySuppressions.xml | 12 + .../src/System.Net.Primitives.csproj | 6 +- .../System.Net.Requests/Directory.Build.props | 2 +- .../System.Net.Security/Directory.Build.props | 2 +- .../System.Net.Sockets/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.Net.WebClient.csproj | 6 +- .../src/System.Net.WebProxy.csproj | 6 +- .../src/System.Net.WebSockets.Client.csproj | 6 +- .../Net/WebSockets/WebSocketHandle.Managed.cs | 5 +- .../src/System.Net.WebSockets.csproj | 4 +- .../src/System/AppContext.AnyOS.cs | 2 +- .../System/Diagnostics/Tracing/EventSource.cs | 4 +- .../src/System/IO/FileStatus.Unix.cs | 8 +- .../src/System/OperatingSystem.cs | 13 + .../src/System/Reflection/Assembly.cs | 4 +- .../Threading/EventWaitHandle.Windows.cs | 2 +- .../src/System/Threading/Mutex.Windows.cs | 4 +- .../src/System/Threading/Overlapped.cs | 2 +- .../src/System/Threading/Semaphore.Windows.cs | 2 +- .../src/System/Threading/Thread.cs | 2 +- .../Decoding/CustomAttributeDecoderTests.cs | 2 +- .../src/CompatibilitySuppressions.xml | 12 + ...em.Runtime.Serialization.Formatters.csproj | 2 +- .../Directory.Build.props | 2 +- .../System.Runtime/ref/System.Runtime.cs | 1 + .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.Security.Cryptography.csproj | 6 +- .../src/System.Text.Encodings.Web.csproj | 3 +- .../Web/OptimizedInboxTextEncoder.Ascii.cs | 2 +- src/libraries/pretest.proj | 5 +- .../src/System/Threading/Thread.Mono.cs | 10 +- src/mono/mono/metadata/profiler.c | 4 +- src/mono/mono/profiler/browser.c | 4 +- src/mono/wasi/.gitignore | 1 + src/mono/wasi/Makefile | 25 -- .../{mono-wasi-driver => include}/driver.h | 0 src/mono/wasi/include/pinvoke.h | 52 ++++ src/mono/wasi/include/wasm-config.h.in | 15 ++ src/mono/wasi/runtime/CMakeLists.txt | 37 +++ .../{mono-wasi-driver => runtime}/driver.c | 10 +- .../{mono-wasi-driver => runtime}/stubs.c | 0 .../synthetic-pthread.c | 0 src/mono/wasi/sample/console/main.c | 2 +- src/mono/wasi/wasi-sdk-version.txt | 1 + src/mono/wasi/wasi.proj | 234 ++++++++++++++++++ src/native/libs/build-native.cmd | 1 + .../XUnitWrapperGenerator/TestPlatforms.cs | 3 +- .../XUnitWrapperGenerator.cs | 1 + 92 files changed, 586 insertions(+), 135 deletions(-) create mode 100644 eng/testing/wasi-provisioning.targets create mode 100644 src/mono/wasi/.gitignore rename src/mono/wasi/{mono-wasi-driver => include}/driver.h (100%) create mode 100644 src/mono/wasi/include/pinvoke.h create mode 100644 src/mono/wasi/include/wasm-config.h.in create mode 100644 src/mono/wasi/runtime/CMakeLists.txt rename src/mono/wasi/{mono-wasi-driver => runtime}/driver.c (99%) rename src/mono/wasi/{mono-wasi-driver => runtime}/stubs.c (100%) rename src/mono/wasi/{mono-wasi-driver => runtime}/synthetic-pthread.c (100%) create mode 100644 src/mono/wasi/wasi-sdk-version.txt create mode 100644 src/mono/wasi/wasi.proj diff --git a/Directory.Build.props b/Directory.Build.props index 35e506f1ebaa5..1e62178294698 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -157,6 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser + <_portableOS Condition="'$(_runtimeOS)' == 'Wasi'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -217,6 +218,7 @@ true true true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index 9e666f71fe0a6..ed775e3daf0dd 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,6 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -139,7 +140,8 @@ - + + @@ -343,7 +345,7 @@ - + @@ -412,6 +414,10 @@ + + + + diff --git a/eng/build.ps1 b/eng/build.ps1 index e7ab6609e8e75..88b2067126513 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","Wasi")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, Wasi or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,24 @@ if ($os -eq "Browser") { } } +if ($os -eq "Wasi") { + # override default arch for Wasi, we only support wasm + $arch = "wasm" + + if ($msbuild -eq $True) { + Write-Error "Using the -msbuild option isn't supported when building for Wasi on Windows, we need need ninja for WASI-SDK." + exit 1 + } +} + foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" + } elseif ($os -eq "Wasi") { + $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" } diff --git a/eng/build.sh b/eng/build.sh index 97fee9151c3e4..2033865d3dcb0 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -280,13 +280,15 @@ while [[ $# > 0 ]]; do os="Android" ;; browser) os="Browser" ;; + wasi) + os="Wasi" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." exit 1 ;; esac @@ -505,6 +507,10 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi +if [[ "$os" == "Wasi" && "$arch" != "wasm" ]]; then + # override default arch for Browser, we only support wasm + arch=wasm +fi initDistroRid $os $arch $crossBuild $portableBuild diff --git a/eng/targetingpacks.targets b/eng/targetingpacks.targets index 744a0cd20b469..e7386ccb5e8d4 100644 --- a/eng/targetingpacks.targets +++ b/eng/targetingpacks.targets @@ -41,7 +41,7 @@ RuntimeFrameworkName="$(LocalFrameworkOverrideName)" LatestRuntimeFrameworkVersion="$(ProductVersion)" RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.Mono.**RID**" - RuntimePackRuntimeIdentifiers="linux-arm;linux-armv6;linux-arm64;linux-musl-arm64;linux-bionic-arm64;linux-loongarch64;linux-musl-x64;linux-bionic-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" + RuntimePackRuntimeIdentifiers="linux-arm;linux-armv6;linux-arm64;linux-musl-arm64;linux-bionic-arm64;linux-loongarch64;linux-musl-x64;linux-bionic-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;wasi-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86" RuntimePackLabels="Mono" Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/> + + diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs index c5648c28885a3..d85cb39e5d357 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs @@ -58,7 +58,7 @@ internal static void FailFast(string message, Exception exception, string errorS internal static void ShutdownCore() { -#if !TARGET_WASM // WASMTODO Be careful what happens here as if the code has called emscripten_set_main_loop then the main loop method will normally be called repeatedly after this method +#if !TARGET_BROWSER // WASMTODO Be careful what happens here as if the code has called emscripten_set_main_loop then the main loop method will normally be called repeatedly after this method AppContext.OnProcessExit(); #endif } diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py index a568bc9e78e71..db8fdb1d132ba 100644 --- a/src/coreclr/scripts/coreclr_arguments.py +++ b/src/coreclr/scripts/coreclr_arguments.py @@ -65,7 +65,7 @@ def __init__(self, self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "wasm"] self.valid_build_types = ["Debug", "Checked", "Release"] - self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android"] + self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "Wasi"] self.__initialize__(args) diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index aae2543ec5ead..a1b755d470d6b 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -3835,6 +3835,17 @@ "any", "base" ], + "wasi": [ + "wasi", + "any", + "base" + ], + "wasi-wasm": [ + "wasi-wasm", + "wasi", + "any", + "base" + ], "centos": [ "centos", "rhel", diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 0e981e704bc1f..928498570017e 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -1022,6 +1022,16 @@ "browser" ] }, + "wasi": { + "#import": [ + "any" + ] + }, + "wasi-wasm": { + "#import": [ + "wasi" + ] + }, "centos": { "#import": [ "rhel" diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index 3a0135e7cc15a..912fe7693c438 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -45,6 +45,11 @@ wasm + + any + wasm + + ios x64;arm64 diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index df367e07b744e..6bff22611c456 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,6 +4,8 @@ }, "Browser" : { }, + "Wasi" : { + }, "Linux": { "#import": [ "Unix" diff --git a/src/libraries/System.CodeDom/Directory.Build.props b/src/libraries/System.CodeDom/Directory.Build.props index 72712f3351c12..5377378125810 100644 --- a/src/libraries/System.CodeDom/Directory.Build.props +++ b/src/libraries/System.CodeDom/Directory.Build.props @@ -2,6 +2,6 @@ true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst \ No newline at end of file diff --git a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props +++ b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 1c45c5a8f932a..4a08e5d43543e 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -1,13 +1,16 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole + + $(DefineConstants);TARGET_WASI + @@ -47,7 +50,7 @@ Common\Interop\Android\Interop.Libraries.cs - + - + + Link="Common\Interop\Unix\Interop.SetTerminalInvalidationHandler.cs" + Condition="'$(TargetPlatformIdentifier)' != 'Wasi'" + /> true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props +++ b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/Directory.Build.props b/src/libraries/System.Diagnostics.Process/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Diagnostics.Process/Directory.Build.props +++ b/src/libraries/System.Diagnostics.Process/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props b/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props index 525d9a0d12ab6..ed868ac7937d9 100644 --- a/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props +++ b/src/libraries/System.DirectoryServices.Protocols/Directory.Build.props @@ -7,6 +7,6 @@ 4.0.0.0 Microsoft true - browser;android;ios;tvos + browser;wasi;android;ios;tvos diff --git a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props index f3f5769f93616..76ee806bc1a2b 100644 --- a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props +++ b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props @@ -3,6 +3,6 @@ ECMA true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml b/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml index 5914451471cbb..8d4094d4b8c18 100644 --- a/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.IO.Compression/src/CompatibilitySuppressions.xml @@ -7,6 +7,12 @@ ref/net7.0/System.IO.Compression.dll runtimes/browser/lib/net7.0/System.IO.Compression.dll + + CP0001 + T:System.IO.Compression.ZLibException + ref/net7.0/System.IO.Compression.dll + runtimes/wasi/lib/net7.0/System.IO.Compression.dll + CP0001 T:System.IO.Compression.ZLibException diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 150b3efdb70ea..35d81f1850284 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -50,7 +50,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + Microsoft true - browser;ios;tvos + browser;wasi;ios;tvos maccatalyst \ No newline at end of file diff --git a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props +++ b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index 9be9a376620fd..bf933e1f51356 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -80,7 +80,7 @@ - + Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.Ports/Directory.Build.props b/src/libraries/System.IO.Ports/Directory.Build.props index 42ef4884cef5d..a93b4c306837b 100644 --- a/src/libraries/System.IO.Ports/Directory.Build.props +++ b/src/libraries/System.IO.Ports/Directory.Build.props @@ -2,6 +2,6 @@ true - browser;android;ios;tvos + browser;wasi;android;ios;tvos diff --git a/src/libraries/System.Linq/src/CompatibilitySuppressions.xml b/src/libraries/System.Linq/src/CompatibilitySuppressions.xml index bbdfa98547610..df413125cabf9 100644 --- a/src/libraries/System.Linq/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Linq/src/CompatibilitySuppressions.xml @@ -19,6 +19,12 @@ ref/net7.0/System.Linq.dll runtimes/browser/lib/net7.0/System.Linq.dll + + CP0001 + T:System.Linq.Grouping`2 + ref/net7.0/System.Linq.dll + runtimes/wasi/lib/net7.0/System.Linq.dll + CP0001 T:System.Linq.Grouping`2 diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index e0509ff215fd8..43f57a18c26e2 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -1,11 +1,11 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true + true diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index fadb5f1bd51ec..780a473f282e4 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -5,6 +5,9 @@ $(DefineConstants);HTTP_DLL $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent) true + @@ -17,6 +20,7 @@ $(DefineConstants);TARGET_MACCATALYST $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI $(MSBuildThisFileDirectory)ILLink\ @@ -24,7 +28,7 @@ - + @@ -156,7 +160,7 @@ Link="Common\System\Text\ValueStringBuilder.AppendSpanFormattable.cs" /> - + @@ -304,12 +308,12 @@ - + - + @@ -385,7 +389,7 @@ - + - + diff --git a/src/libraries/System.Net.HttpListener/Directory.Build.props b/src/libraries/System.Net.HttpListener/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Net.HttpListener/Directory.Build.props +++ b/src/libraries/System.Net.HttpListener/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 5d2ce4cc28099..12dc021efc05a 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -1,7 +1,7 @@  true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -78,12 +78,12 @@ Link="Common\System\HexConverter.cs" /> - + - + diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 6d7ee08de0bc5..1e567b1ec0934 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Browser.txt + SR.SystemNetNameResolution_PlatformNotSupported + ExcludeApiList.PNSE.Browser.txt @@ -100,7 +100,7 @@ - + diff --git a/src/libraries/System.Net.NetworkInformation/Directory.Build.props b/src/libraries/System.Net.NetworkInformation/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.NetworkInformation/Directory.Build.props +++ b/src/libraries/System.Net.NetworkInformation/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Ping/Directory.Build.props b/src/libraries/System.Net.Ping/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Ping/Directory.Build.props +++ b/src/libraries/System.Net.Ping/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml b/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml index b359c8b66a64f..cba3412551413 100644 --- a/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Net.Primitives/src/CompatibilitySuppressions.xml @@ -13,6 +13,18 @@ ref/net7.0/System.Net.Primitives.dll runtimes/browser/lib/net7.0/System.Net.Primitives.dll + + CP0001 + T:System.Net.CookieVariant + ref/net7.0/System.Net.Primitives.dll + runtimes/wasi/lib/net7.0/System.Net.Primitives.dll + + + CP0001 + T:System.Net.PathList + ref/net7.0/System.Net.Primitives.dll + runtimes/wasi/lib/net7.0/System.Net.Primitives.dll + CP0001 T:System.Net.CookieVariant diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index b77d6366c7a96..0484a5a990bbd 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -2,7 +2,7 @@ true false - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL @@ -113,7 +113,7 @@ - + @@ -144,7 +144,7 @@ - + Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Security/Directory.Build.props b/src/libraries/System.Net.Security/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Security/Directory.Build.props +++ b/src/libraries/System.Net.Security/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/Directory.Build.props b/src/libraries/System.Net.Sockets/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Net.Sockets/Directory.Build.props +++ b/src/libraries/System.Net.Sockets/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/Directory.Build.props b/src/libraries/System.Net.WebClient/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Net.WebClient/Directory.Build.props +++ b/src/libraries/System.Net.WebClient/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj index fdbfd8f017d68..447c8b7dc4e50 100644 --- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj +++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetWebClient_PlatformNotSupported + SR.SystemNetWebClient_PlatformNotSupported - + diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index fbe0e197d113c..7fd1104f3a853 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi - - + + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index b7da9d3e90bec..67e8c09e735c5 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -1,11 +1,15 @@ True - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER + + $(DefineConstants);TARGET_WASI + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs index 0ab159c1c42cb..9451871439f60 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs @@ -280,8 +280,9 @@ private static HttpMessageInvoker SetupInvoker(ClientWebSocketOptions options, o handler.PooledConnectionLifetime = TimeSpan.Zero; handler.CookieContainer = options.Cookies; handler.UseCookies = options.Cookies != null; +#if !TARGET_WASI handler.SslOptions.RemoteCertificateValidationCallback = options.RemoteCertificateValidationCallback; - +#endif handler.Credentials = options.UseDefaultCredentials ? CredentialCache.DefaultCredentials : options.Credentials; @@ -297,9 +298,11 @@ private static HttpMessageInvoker SetupInvoker(ClientWebSocketOptions options, o if (options._clientCertificates?.Count > 0) // use field to avoid lazily initializing the collection { +#if !TARGET_WASI Debug.Assert(handler.SslOptions.ClientCertificates == null); handler.SslOptions.ClientCertificates = new X509Certificate2Collection(); handler.SslOptions.ClientCertificates.AddRange(options.ClientCertificates); +#endif } return new HttpMessageInvoker(handler); diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index c0c4ded0d332a..2e8b009d92d09 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -1,7 +1,7 @@ True - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) @@ -40,7 +40,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + diff --git a/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs b/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs index 2dc7015dda0a3..b2c83e67dd453 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs @@ -12,7 +12,7 @@ namespace System { public static partial class AppContext { -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI [UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file", Justification = "Single File apps should always set APP_CONTEXT_BASE_DIRECTORY therefore code handles Assembly.Location equals null")] private static string GetBaseDirectoryCore() diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index fc8c2a8226cdd..9cd258cf52b24 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -1327,12 +1327,12 @@ protected unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid* rel if (m_Dispatchers != null && metadata.EnabledForAnyListener) { -#if MONO && !TARGET_BROWSER +#if MONO && !TARGET_BROWSER && !TARGET_WASI // On Mono, managed events from NativeRuntimeEventSource are written using WriteEventCore which can be // written doubly because EventPipe tries to pump it back up to EventListener via NativeRuntimeEventSource.ProcessEvents. // So we need to prevent this from getting written directly to the Listeners. if (this.GetType() != typeof(NativeRuntimeEventSource)) -#endif // MONO && !TARGET_BROWSER +#endif // MONO && !TARGET_BROWSER && !TARGET_WASI { var eventCallbackArgs = new EventWrittenEventArgs(this, eventId, pActivityId, relatedActivityId); WriteToAllListeners(eventCallbackArgs, eventDataCount, data); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs index fe14a0aa99a19..f6342bd32250b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.Unix.cs @@ -57,7 +57,7 @@ private bool HasReadOnlyFlag return false; } -#if TARGET_BROWSER +#if TARGET_BROWSER || TARGET_WASI var mode = ((UnixFileMode)_fileCache.Mode & FileSystem.ValidUnixFileModes); bool isUserReadOnly = (mode & UnixFileMode.UserRead) != 0 && // has read permission (mode & UnixFileMode.UserWrite) == 0; // but not write permission @@ -81,7 +81,7 @@ private bool HasReadOnlyFlag } } -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI // HasReadOnlyFlag cache. // Must only be used after calling EnsureCachesInitialized. private int _isReadOnlyCache; @@ -394,7 +394,7 @@ private unsafe void SetAccessOrWriteTimeCore(SafeFileHandle? handle, string? pat long seconds = time.ToUnixTimeSeconds(); long nanoseconds = UnixTimeSecondsToNanoseconds(time, seconds); -#if TARGET_BROWSER +#if TARGET_BROWSER && !TARGET_WASI buf[0].TvSec = seconds; buf[0].TvNsec = nanoseconds; buf[1].TvSec = seconds; @@ -499,7 +499,7 @@ internal void RefreshCaches(SafeFileHandle? handle, ReadOnlySpan path) { Debug.Assert(handle is not null || path.Length > 0); -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI _isReadOnlyCache = -1; #endif int rv = handle is not null ? diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index deb0b107eb5cf..6fc2f2257fe7b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -12,6 +12,8 @@ public sealed class OperatingSystem : ISerializable, ICloneable private const string OSPlatformName = #if TARGET_BROWSER "BROWSER" +#elif TARGET_WASI + "WASI" #elif TARGET_WINDOWS "WINDOWS" #elif TARGET_OSX @@ -148,6 +150,17 @@ public static bool IsBrowser() => false; #endif + /// + /// Indicates whether the current application is running as WASI. + /// + [NonVersionable] + public static bool IsWasi() => +#if TARGET_WASI + true; +#else + false; +#endif + /// /// Indicates whether the current application is running on Linux. /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs index f6445df9671b8..00095ffb7f48b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -265,10 +265,10 @@ public static Assembly LoadFile(string path) return result; // we cannot check for file presence on BROWSER. The files could be embedded and not physically present. -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI if (!File.Exists(normalizedPath)) throw new FileNotFoundException(SR.Format(SR.FileNotFound_LoadFile, normalizedPath), normalizedPath); -#endif // !TARGET_BROWSER +#endif // !TARGET_BROWSER && !TARGET_WASI AssemblyLoadContext alc = new IndividualAssemblyLoadContext($"Assembly.LoadFile({normalizedPath})"); result = alc.LoadFromAssemblyPath(normalizedPath); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs index 95750074698b0..bc41f1bde322e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Windows.cs @@ -18,7 +18,7 @@ private EventWaitHandle(SafeWaitHandle handle) private void CreateEventCore(bool initialState, EventResetMode mode, string? name, out bool createdNew) { -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (name != null) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs index ab5663297cdc5..10a91926c3e02 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Mutex.Windows.cs @@ -24,7 +24,7 @@ private void CreateMutexCore(bool initiallyOwned, string? name, out bool created if (mutexHandle.IsInvalid) { mutexHandle.SetHandleAsInvalid(); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name)); @@ -56,7 +56,7 @@ private static OpenExistingResult OpenExistingWorker(string name, out Mutex? res myHandle.Dispose(); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) { // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 0f130cdc53aa8..29446e444073c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -184,7 +184,7 @@ public static void Free(NativeOverlapped* nativeOverlappedPtr) _pNativeOverlapped = pNativeOverlapped; #if FEATURE_PERFTRACING -#if !(TARGET_BROWSER && !FEATURE_WASM_THREADS) +#if !((TARGET_BROWSER || TARGET_WASI) && !FEATURE_WASM_THREADS) if (NativeRuntimeEventSource.Log.IsEnabled()) NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs index a4cb8323ef5b2..027e9fe93f468 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Windows.cs @@ -23,7 +23,7 @@ private void CreateSemaphoreCore(int initialCount, int maximumCount, string? nam Debug.Assert(maximumCount >= 1); Debug.Assert(initialCount <= maximumCount); -#if TARGET_UNIX || TARGET_BROWSER +#if TARGET_UNIX || TARGET_BROWSER || TARGET_WASI if (name != null) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index a27ced32def89..19d00e5d9ac19 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -153,7 +153,7 @@ public Thread(ParameterizedThreadStart start, int maxStackSize) Initialize(); } -#if !TARGET_BROWSER || FEATURE_WASM_THREADS +#if !(TARGET_BROWSER || TARGET_WASI) || FEATURE_WASM_THREADS [UnsupportedOSPlatformGuard("browser")] internal static bool IsThreadStartSupported => true; internal static bool IsInternalThreadStartSupported => true; diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs index 62944bef46d20..5d6b096956628 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/CustomAttributeDecoderTests.cs @@ -197,7 +197,7 @@ public void TestCustomAttributeDecoderUsingReflection() } } -#if NETCOREAPP && !TARGET_BROWSER // Generic attribute is not supported on .NET Framework. +#if NETCOREAPP && !TARGET_BROWSER && !TARGET_WASI // Generic attribute is not supported on .NET Framework. [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60579", TestPlatforms.iOS | TestPlatforms.tvOS)] public void TestCustomAttributeDecoderGenericUsingReflection() diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml b/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml index edac62595c48a..5dca51f6147da 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/CompatibilitySuppressions.xml @@ -37,6 +37,18 @@ ref/net7.0/System.Runtime.Serialization.Formatters.dll runtimes/browser/lib/net7.0/System.Runtime.Serialization.Formatters.dll + + CP0001 + T:System.Runtime.Serialization.SerializationEventHandler + ref/net7.0/System.Runtime.Serialization.Formatters.dll + runtimes/wasi/lib/net7.0/System.Runtime.Serialization.Formatters.dll + + + CP0001 + T:System.Runtime.Serialization.TypeLoadExceptionHolder + ref/net7.0/System.Runtime.Serialization.Formatters.dll + runtimes/wasi/lib/net7.0/System.Runtime.Serialization.Formatters.dll + CP0001 T:System.Runtime.Serialization.SerializationEventHandler diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index a9438b21825df..2cb707b45af45 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android $(MSBuildThisFileDirectory)ILLink\ true diff --git a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props index e7d357018da7b..7d407028f6632 100644 --- a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props +++ b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props @@ -4,6 +4,6 @@ Microsoft true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index c26b436f41097..0a3275c5ea4ad 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,6 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } + public static bool IsWasi() { throw null; } public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props index c4db04cc6c252..d13e60dc1f013 100644 --- a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props b/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Csp/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props b/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Encoding/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props b/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props index 1e1390709dcc5..4342451c25a83 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.OpenSsl/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - windows;browser;android;ios;tvos + windows;browser;wasi;android;ios;tvos diff --git a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props index 1f799d605feb9..e3cd1bcddea8e 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props b/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props index ce244cbea5619..58979d42f0695 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.X509Certificates/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props index c843a6347ce61..3a3d8f9832479 100644 --- a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index dadeb106d6613..8b16b293ac37c 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -2,7 +2,7 @@ true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) $(NoWarn);CA5350;CA5351;CA5379;CA5384;SYSLIB0026 $(NoWarn);CS0809 @@ -549,7 +549,7 @@ System\Security\Cryptography\X509Certificates\Asn1\PolicyInformationAsn.xml - + @@ -1835,7 +1835,7 @@ - + diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 37e7d332f8433..510c94c79adaf 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-Wasi;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true @@ -18,6 +18,7 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs index 03c0e7fc324bf..859b5c5eef9ff 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs +++ b/src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.cs @@ -23,7 +23,7 @@ private unsafe partial struct AllowedAsciiCodePoints private fixed byte AsBytes[16]; #if NETCOREAPP -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI [FieldOffset(0)] // ensure same offset with AsBytes field internal Vector128 AsVector; #else diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index dc68ed802a448..8a2e1240c1449 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -26,12 +26,15 @@ - + + + -#ifdef TARGET_WASM +#ifdef TARGET_BROWSER #include #include @@ -104,4 +104,4 @@ mono_profiler_init_browser (const char *desc) #endif /* HOST_WASM */ } -#endif /* TARGET_WASM */ +#endif /* TARGET_BROWSER */ diff --git a/src/mono/wasi/.gitignore b/src/mono/wasi/.gitignore new file mode 100644 index 0000000000000..faf8da9dc8468 --- /dev/null +++ b/src/mono/wasi/.gitignore @@ -0,0 +1 @@ +wasi-sdk/** diff --git a/src/mono/wasi/Makefile b/src/mono/wasi/Makefile index 53ae87f4f76ea..00a4306a9c920 100644 --- a/src/mono/wasi/Makefile +++ b/src/mono/wasi/Makefile @@ -24,28 +24,3 @@ build-all: $(WASI_SDK_CLANG) rm -rf $(WASI_BIN_DIR)/libmono-component-diagnostics_tracing-static.a mkdir -p $(WASI_BIN_DIR)/include/mono-wasi cp mono-wasi-driver/*.h $(WASI_BIN_DIR)/include/mono-wasi - -$(WASI_SDK_CLANG): - mkdir -p $(WASI_OBJ_DIR) - cd $(WASI_OBJ_DIR) && \ - wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASI_SDK_VERSION)/wasi-sdk-$(WASI_SDK_VERSION).0-linux.tar.gz && \ - tar xf wasi-sdk-*.tar.gz - -.stamp-wasmtime-$(WASMTIME_VERSION): - @echo "** Provisioning wasmtime $(WASMTIME_VERSION) **" - rm -Rf $(WASMTIME_DIR) && \ - wget -q https://github.com/bytecodealliance/wasmtime/releases/download/$(WASMTIME_VERSION)/$(WASMTIME_DIR_NAME).tar.xz -O - | tar -C `dirname $(WASMTIME_DIR)` -Jxf - && \ - touch $@ - -.stamp-ninja-$(NINJA_VERSION): - @echo "** Provisioning ninja $(NINJA_VERSION) **" - rm -Rf $(NINJA_DIR); \ - mkdir $(NINJA_DIR) && \ - wget -q https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-linux.zip -O $(NINJA_DIR)/ninja.zip && \ - (cd $(NINJA_DIR) && unzip -q ninja.zip && rm ninja.zip) && \ - touch $@ - -provision-deps: .stamp-wasmtime-$(WASMTIME_VERSION) .stamp-ninja-$(NINJA_VERSION) - @echo "-------------------------------------------" - @echo "** Installed wasmtime in $(WASMTIME_DIR)" - @echo "** Installed ninja in $(NINJA_DIR)" diff --git a/src/mono/wasi/mono-wasi-driver/driver.h b/src/mono/wasi/include/driver.h similarity index 100% rename from src/mono/wasi/mono-wasi-driver/driver.h rename to src/mono/wasi/include/driver.h diff --git a/src/mono/wasi/include/pinvoke.h b/src/mono/wasi/include/pinvoke.h new file mode 100644 index 0000000000000..78c30f22693c8 --- /dev/null +++ b/src/mono/wasi/include/pinvoke.h @@ -0,0 +1,52 @@ +// TODOWASI deduplicate src/mono/wasm/runtime/pinvoke.h + +#ifndef __PINVOKE_H__ +#define __PINVOKE_H__ + +#include + +typedef struct { + const char *name; + void *func; +} PinvokeImport; + +typedef struct { + void *func; + void *arg; +} InterpFtnDesc; + +void* +wasm_dl_lookup_pinvoke_table (const char *name); + +int +wasm_dl_is_pinvoke_table (void *handle); + +void* +wasm_dl_get_native_to_interp (const char *key, void *extra_arg); + +void +mono_wasm_pinvoke_vararg_stub (void); + +typedef void* (*MonoWasmNativeToInterpCallback) (char * cookie); + +void +mono_wasm_install_interp_to_native_callback (MonoWasmNativeToInterpCallback cb); + +typedef struct _MonoInterpMethodArguments MonoInterpMethodArguments; + +int +mono_wasm_interp_method_args_get_iarg (MonoInterpMethodArguments *margs, int i); + +int64_t +mono_wasm_interp_method_args_get_larg (MonoInterpMethodArguments *margs, int i); + +float +mono_wasm_interp_method_args_get_farg (MonoInterpMethodArguments *margs, int i); + +double +mono_wasm_interp_method_args_get_darg (MonoInterpMethodArguments *margs, int i); + +void* +mono_wasm_interp_method_args_get_retval (MonoInterpMethodArguments *margs); + +#endif diff --git a/src/mono/wasi/include/wasm-config.h.in b/src/mono/wasi/include/wasm-config.h.in new file mode 100644 index 0000000000000..4c33fd663663c --- /dev/null +++ b/src/mono/wasi/include/wasm-config.h.in @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +#ifndef __MONO_WASM_CONFIG_H__ +#define __MONO_WASM_CONFIG_H__ + +/* Support for threads is disabled */ +#cmakedefine DISABLE_THREADS + +/* Support for starting user threads is disabled */ +#cmakedefine DISABLE_WASM_USER_THREADS + +#endif/*__MONO_WASM_CONFIG_H__*/ + +// TODOWASI deduplicate with src/mono/wasm/runtime/wasm-config.h.in \ No newline at end of file diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt new file mode 100644 index 0000000000000..815be6c7c7e6b --- /dev/null +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.14.5) + +project(mono-wasi-runtime C) + +option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON) +option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF) + +add_executable(dotnet driver.c stubs.c synthetic-pthread.c) + +target_include_directories(dotnet PUBLIC ${MONO_INCLUDES} ${MONO_OBJ_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/include/wasm) +target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-compile.rsp -DCORE_BINDINGS -DGEN_PINVOKE=1) + +set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLAGS}) + +target_link_libraries(dotnet + ${ICU_LIB_DIR}/libicuuc.a + ${ICU_LIB_DIR}/libicui18n.a + ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a + ${MONO_ARTIFACTS_DIR}/libmono-component-debugger-static.a + ${MONO_ARTIFACTS_DIR}/libmono-component-diagnostics_tracing-stub-static.a + ${MONO_ARTIFACTS_DIR}/libmono-ee-interp.a + ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a + ${MONO_ARTIFACTS_DIR}/libmono-ilgen.a + ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a + ${NATIVE_BIN_DIR}/libSystem.Native.a + ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a) + +set_target_properties(dotnet PROPERTIES + LINK_DEPENDS "${NATIVE_BIN_DIR}/src/wasi-default.rsp;" + LINK_FLAGS "@${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-link.rsp ${CONFIGURATION_LINK_FLAGS} " + RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}") + +set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}") + +#TODOWASI wasm-opt + +configure_file(../include/wasm-config.h.in include/wasm/wasm-config.h) diff --git a/src/mono/wasi/mono-wasi-driver/driver.c b/src/mono/wasi/runtime/driver.c similarity index 99% rename from src/mono/wasi/mono-wasi-driver/driver.c rename to src/mono/wasi/runtime/driver.c index fdaf95a571f61..b7691ab4da50f 100644 --- a/src/mono/wasi/mono-wasi-driver/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -33,7 +33,7 @@ #include #include -#include "wasm/runtime/pinvoke.h" +#include "pinvoke.h" #ifdef GEN_PINVOKE #include "wasm_m2n_invoke.g.h" @@ -155,7 +155,7 @@ typedef struct } FileStatus; char* gai_strerror(int code) { - char result[256]; + char* result = malloc(256); sprintf(result, "Error code %i", code); return result; } @@ -278,6 +278,7 @@ int64_t SystemNative_GetTimestamp2() { : 0; } +// TODOWASI replace with native libs static PinvokeImport SystemNativeImports [] = { {"SystemNative_GetEnv", SystemNative_GetEnv }, {"SystemNative_GetEnviron", SystemNative_GetEnviron }, @@ -780,7 +781,10 @@ void add_assembly(const char* base_dir, const char *name) { rewind(fileptr); buffer = (unsigned char *)malloc(filelen * sizeof(char)); - fread(buffer, filelen, 1, fileptr); + if(!fread(buffer, filelen, 1, fileptr)) { + printf("Failed to load %s\n", filename); + fflush(stdout); + } fclose(fileptr); assert(mono_wasm_add_assembly(name, buffer, filelen)); diff --git a/src/mono/wasi/mono-wasi-driver/stubs.c b/src/mono/wasi/runtime/stubs.c similarity index 100% rename from src/mono/wasi/mono-wasi-driver/stubs.c rename to src/mono/wasi/runtime/stubs.c diff --git a/src/mono/wasi/mono-wasi-driver/synthetic-pthread.c b/src/mono/wasi/runtime/synthetic-pthread.c similarity index 100% rename from src/mono/wasi/mono-wasi-driver/synthetic-pthread.c rename to src/mono/wasi/runtime/synthetic-pthread.c diff --git a/src/mono/wasi/sample/console/main.c b/src/mono/wasi/sample/console/main.c index 8647c4878f2ab..251d88342e449 100644 --- a/src/mono/wasi/sample/console/main.c +++ b/src/mono/wasi/sample/console/main.c @@ -1,5 +1,5 @@ #include -#include "../../mono-wasi-driver/driver.h" +#include "../../runtime/driver.h" int main() { // Assume the runtime pack has been copied into the output directory as 'runtime' diff --git a/src/mono/wasi/wasi-sdk-version.txt b/src/mono/wasi/wasi-sdk-version.txt new file mode 100644 index 0000000000000..3cacc0b93c9c9 --- /dev/null +++ b/src/mono/wasi/wasi-sdk-version.txt @@ -0,0 +1 @@ +12 \ No newline at end of file diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj new file mode 100644 index 0000000000000..e4002a5027271 --- /dev/null +++ b/src/mono/wasi/wasi.proj @@ -0,0 +1,234 @@ + + + + + wasi-wasm + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'native', '$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)')) + + + + + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib')) + false + false + $(ArtifactsObjDir)wasm + <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp + <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp + <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp + false + + + + + + + + + + + + + + + + + $(NativeBinDir)dotnet.timezones.blat + + + + + + + + + $(WasmObjDir)\pinvoke-table.h + $(WasmObjDir)\wasm_m2n_invoke.g.h + + + + + + + + + + + + + + + + + + + + + + + + + + + <_WasiLinkFlags Include="-Wl,--allow-undefined"/> + + + + + + + + <_WasiFlags Include="@(_WasiCommonFlags)" /> + + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + + + + + <_WasmOptConfigurationFlags>@(WasmOptConfigurationFlags, '%3B ') + <_WasiPropsJson> + + + + + + + + + + + + + + + + + + + + + $(ArtifactsObjDir)wasm/pinvoke-table.h + $(ArtifactsObjDir)wasm/wasm_m2n_invoke.g.h + + -g -Os -s -DDEBUG=1 -DENABLE_AOT_PROFILER=1 + -Oz + + $(CMakeConfigurationWasiFlags) + -O2 + $(CMakeConfigurationLinkFlags) --emit-symbol-map + + -DWASI_SDK_PATH="$(WASI_SDK_PATH.TrimEnd('\/'))" + + cmake $(MSBuildThisFileDirectory)runtime + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_BUILD_TYPE=$(Configuration) + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_OBJ_INCLUDES="$(MonoObjDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DICU_LIB_DIR="$(ICULibDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_ARTIFACTS_DIR="$(MonoArtifactsPath.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd" + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1 + $(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath) + + -v + cmake --build . --config $(Configuration) $(CmakeOptions) + echo not implemented for WASI on Windows + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index ae97ff4e3262f..3de7efd78bb84 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,6 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) +if /i [%1] == [Wasi] ( set __TargetOS=Wasi&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index a4f11204e48ba..f6f0c00812f42 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,7 +20,8 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser, + Wasi = 2048, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | Wasi, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index adcfa65fabe09..a76025db7d727 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -709,6 +709,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, + "wasi" => Xunit.TestPlatforms.Wasi, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, From 1f0cb148c2a441874269951de2dd5fbeb1e23805 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 16:12:10 +0100 Subject: [PATCH 015/116] wip --- eng/versioning.targets | 1 + src/mono/CMakeLists.txt | 25 ++++---- src/mono/Directory.Build.props | 12 +++- src/mono/cmake/configure.cmake | 4 +- src/mono/mono.proj | 89 +++++++++++++++++++++------ src/mono/mono/mini/CMakeLists.txt | 2 +- src/mono/mono/profiler/CMakeLists.txt | 2 +- src/mono/mono/utils/mono-rand.c | 33 +++++----- 8 files changed, 119 insertions(+), 49 deletions(-) diff --git a/eng/versioning.targets b/eng/versioning.targets index fb3e315a6935c..fa1b63973d005 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,6 +86,7 @@ diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 85a0f819da4d1..bbe2b5e1e0966 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -251,20 +251,16 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") add_definitions(-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) add_definitions(-DNO_GLOBALIZATION_SHIM) add_definitions(-D_THREAD_SAFE) - add_definitions(-DGEN_PINVOKE) + # add_definitions(-DGEN_PINVOKE) TODOWASI + add_definitions(-DDISABLE_SOCKET_TRANSPORT) + add_definitions(-DDISABLE_EGD_SOCKET) + add_definitions(-DDISABLE_EVENTPIPE) + set(ENABLE_PERFTRACING 0) + add_compile_options(-Wl,--allow-undefined) set(DISABLE_SHARED_LIBS 1) set(INTERNAL_ZLIB 1) set(DISABLE_EXECUTABLES 1) set(STATIC_COMPONENTS 1) - - set(WASI_DRIVER_SOURCES - wasi/mono-wasi-driver/driver.c - wasi/mono-wasi-driver/stubs.c - wasi/mono-wasi-driver/synthetic-pthread.c - ) - add_library(mono-wasi-driver STATIC ${WASI_DRIVER_SOURCES}) - target_compile_options(mono-wasi-driver PRIVATE -Wno-missing-prototypes -Wno-strict-prototypes) - install(TARGETS mono-wasi-driver LIBRARY) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(HOST_WIN32 1) set(EXE_SUFFIX ".exe") @@ -336,6 +332,9 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") endif() elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") set(TARGET_WASI 1) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + add_compile_options(-Os) + endif() elseif(TARGET_SYSTEM_NAME STREQUAL "Windows") set(TARGET_WIN32 1) elseif(TARGET_SYSTEM_NAME STREQUAL "SunOS") @@ -358,7 +357,7 @@ if(NOT "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") endif() -if(HOST_BROWSER) +if(HOST_BROWSER OR HOST_WASI) # CMAKE_SYSTEM_PROCESSOR is set to x86 by emscripten set(CMAKE_SYSTEM_PROCESSOR "wasm") endif() @@ -744,6 +743,8 @@ elseif(GC_SUSPEND STREQUAL "default") # use preemptive elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") # use preemptive + elseif(TARGET_SYSTEM_NAME STREQUAL "Wasi") + # use preemptive else() set(ENABLE_HYBRID_SUSPEND 1) endif() @@ -911,7 +912,7 @@ endif() add_subdirectory("${CLR_SRC_NATIVE_DIR}/public" public_apis) add_subdirectory(mono) -if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCAT) +if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT TARGET_WASI AND NOT HOST_MACCAT) add_subdirectory(dlls/mscordbi) add_subdirectory(dlls/dbgshim) endif() diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index b64f87e11d95c..ef74df52c446a 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -40,10 +40,17 @@ $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasm', 'emsdk')) - true + true $(ProvisionEmscriptenDir.Replace('\', '/')) + + + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) + $(ProvisionWasiSdkDir.Replace('\', '/')) + true + + $(TargetOS).$(Platform).$(Configuration) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'mono', '$(TargetOS).$(Platform).$(Configuration)')) @@ -52,6 +59,9 @@ true true true + true <_MonoUseLLVMPackage Condition="'$(MonoLLVMDir)' == '' and '$(MonoEnableLLVM)' == 'true'">true <_MonoUseAOTLLVMPackage Condition="'$(MonoAOTLLVMDir)' == '' and '$(MonoAOTEnableLLVM)' == 'true'">true diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index ae55fd112b321..d0c61f25dc848 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -85,7 +85,7 @@ ac_check_funcs ( gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs access inet_ntop Qp2getifaddrs getpid mktemp) -if (HOST_LINUX OR HOST_BROWSER) +if (HOST_LINUX OR HOST_BROWSER OR HOST_WASI) # sysctl is deprecated on Linux and doesn't work on Browser set(HAVE_SYS_SYSCTL_H 0) else () @@ -264,6 +264,8 @@ elseif(HOST_MACCAT) set(HAVE_SYSTEM 0) elseif(HOST_BROWSER) set(HAVE_FORK 0) +elseif(HOST_WASI) + set(HAVE_FORK 0) elseif(HOST_SOLARIS) set(HAVE_GETPROTOBYNAME 1) set(HAVE_NETINET_TCP_H 1) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 56bc7ebaa9179..70dc73b3955f1 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -28,7 +28,7 @@ $(CoreClrLibName) $(LibPrefix)$(MonoSharedLibName)$(LibSuffix) $(LibPrefix)$(MonoLibName)$(StaticLibSuffix) - $(MonoStaticLibFileName) + $(MonoStaticLibFileName) $(MonoSharedLibFileName) mono-aot-cross$(ExeSuffix) mono-aot-cross.pdb @@ -42,11 +42,14 @@ true true true + true $([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross')) $([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'config.h')) true - true + true $(Compiler) clang <_CompilerTargetArch Condition="'$(RealTargetArchitecture)' == ''">$(Platform) @@ -62,7 +65,7 @@ coop - preemptive + preemptive hybrid @@ -70,6 +73,7 @@ true + true true true false @@ -80,12 +84,12 @@ true - + - + <_MonoCMakeArgs Include="-DENABLE_WERROR=1"/> @@ -98,6 +102,7 @@ + @@ -139,15 +144,15 @@ - .sh + .ps1 $(ProvisionEmscriptenDir) $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasm')) emsdk %(_VersionLines.Identity) - ./emsdk$(EmsdkExt) install $(EmscriptenVersion) - ./emsdk$(EmsdkExt) activate $(EmscriptenVersion) + $(EMSDK_PATH)/emsdk$(EmsdkExt) install $(EmscriptenVersion) + $(EMSDK_PATH)/emsdk$(EmsdkExt) activate $(EmscriptenVersion) powershell -NonInteractive -command "& $(InstallCmd); Exit $LastExitCode " powershell -NonInteractive -command "& $(ActivateCmd); Exit $LastExitCode " @@ -161,6 +166,30 @@ IgnoreStandardErrorWarningFormat="true" /> + + + + + + + + $(ProvisionWasiSdkDir) + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) + wasi-sdk + %(_VersionLines.Identity) + + + + + + + + + @@ -338,13 +367,13 @@ <_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" /> - + <_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages <_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads <_MonoMinimal Condition="'$(MonoWasmThreadsNoUser)' == 'true'">$(_MonoMinimal),wasm_user_threads - + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/> <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> @@ -358,9 +387,27 @@ <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + + + + <_MonoBuildEnv Include="TARGET_BUILD_ARCH=wasm" /> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + + + <_MonoCCOption>CC="$(XcodeDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" @@ -487,7 +534,7 @@ <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> - + <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_CONNECT_PORTS=1" /> @@ -512,19 +559,23 @@ $([MSBuild]::EnsureTrailingSlash('$(EMSDK_PATH)')) + $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)')) <_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) "$(MonoProjectRoot.TrimEnd('\/'))" - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' != 'windows'">bash -c 'source $(RepositoryEngineeringCommonDir)native/init-compiler.sh "$(RepositoryEngineeringCommonDir)native" "$(_CompilerTargetArch)" "$(MonoCCompiler)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)' - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) - <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' == 'false'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' != 'windows'">bash -c 'source $(RepositoryEngineeringCommonDir)native/init-compiler.sh "$(RepositoryEngineeringCommonDir)native" "$(_CompilerTargetArch)" "$(MonoCCompiler)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)' + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoRunInitCompiler)' == 'false'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && emcmake $(_MonoCMakeConfigureCommand)' <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && emcmake $(_MonoCMakeConfigureCommand) + <_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" + <_MonoCMakeBuildCommand>cmake --build . --target install --config $(Configuration) <_MonoCMakeBuildCommand Condition="'$(MonoVerboseBuild)' == 'true'">$(_MonoCMakeBuildCommand) --verbose <_MonoCMakeBuildCommand Condition="'$(_MonoUseNinja)' != 'true'">$(_MonoCMakeBuildCommand) --parallel $([System.Environment]::ProcessorCount) - <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(HostOS)' != 'windows'">@(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) - <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' != 'windows'">@(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && $(_MonoCMakeBuildCommand) + <_MonoCMakeBuildCommand Condition="'$(TargetsWasi)' == 'true' and '$(HostOS)' == 'windows'">echo TODOWASI building with cmake is not implemented on windows @@ -716,6 +767,7 @@ + @@ -796,6 +848,7 @@ CheckEnv;GetXcodeDir;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross GenerateRuntimeVersionFile;ProvisionEmscripten;$(MonoDependsOnTargets) + GenerateRuntimeVersionFile;ProvisionWasiSdk;$(MonoDependsOnTargets) @@ -804,7 +857,7 @@ <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true'">$(MonoObjDir)out\bin\$(MonoFileName) <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName) <_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName) - <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true'">true + <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true <_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index c68af8beb34ca..b1a0c147af40b 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -339,7 +339,7 @@ endif() if(HOST_WIN32) set(mini_sources "${mini_sources};${VERSION_FILE_RC_PATH}") # this is generated by GenerateNativeVersionFile in Arcade -elseif(NOT HOST_BROWSER) +elseif(NOT HOST_BROWSER AND NOT HOST_WASI) set(mini_sources "${mini_sources};${VERSION_FILE_PATH}") # this is generated by GenerateNativeVersionFile in Arcade endif() diff --git a/src/mono/mono/profiler/CMakeLists.txt b/src/mono/mono/profiler/CMakeLists.txt index cd5bf36dfa67d..3fc180dfab683 100644 --- a/src/mono/mono/profiler/CMakeLists.txt +++ b/src/mono/mono/profiler/CMakeLists.txt @@ -36,7 +36,7 @@ if(NOT DISABLE_LIBS) install(TARGETS mono-profiler-aot-static LIBRARY) endif() - if(HOST_WASM) + if(HOST_WASM AND NOT HOST_WASI) add_library(mono-profiler-browser-static STATIC browser.c) target_link_libraries(mono-profiler-browser-static monoapi) set_target_properties(mono-profiler-browser-static PROPERTIES OUTPUT_NAME mono-profiler-browser) diff --git a/src/mono/mono/utils/mono-rand.c b/src/mono/mono/utils/mono-rand.c index cb78275d75677..0f64d3b9eacdb 100644 --- a/src/mono/mono/utils/mono-rand.c +++ b/src/mono/mono/utils/mono-rand.c @@ -121,6 +121,7 @@ mono_getentropy (guchar *buffer, gssize buffer_size, MonoError *error) } #endif /* HAVE_GETENTROPY */ +#if !defined(DISABLE_EGD_SOCKET) static void get_entropy_from_egd (const char *path, guchar *buffer, gssize buffer_size, MonoError *error) { @@ -222,6 +223,7 @@ mono_rand_open (void) return TRUE; } +#endif /* !DISABLE_EGD_SOCKET */ gpointer mono_rand_init (const guchar *seed, gssize seed_size) @@ -250,9 +252,9 @@ mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gssize buffer_size, M if (res == 1) return TRUE; +#elif !defined(DISABLE_EGD_SOCKET) /* getrandom() or getentropy() function is not available: failed with ENOSYS or EPERM. Fall back on reading from /dev/urandom. */ -#endif if (use_egd) { char *socket_path = g_getenv ("MONO_EGD_SOCKET"); @@ -263,21 +265,22 @@ mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gssize buffer_size, M } get_entropy_from_egd (socket_path, buffer, buffer_size, error); g_free (socket_path); - } else { - /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */ - while (buffer_size > 0) { - gssize const err = read (file, buffer, buffer_size); - if (err < 0) { - if (errno == EINTR) - continue; - g_warning("Entropy error! Error in read (%s).", strerror (errno)); - /* exception will be thrown in managed code */ - mono_error_set_execution_engine (error, "Entropy error! Error in read (%s).", strerror (errno)); - return FALSE; - } - buffer += err; - buffer_size -= err; + return TRUE; + } +#endif + /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */ + while (buffer_size > 0) { + gssize const err = read (file, buffer, buffer_size); + if (err < 0) { + if (errno == EINTR) + continue; + g_warning("Entropy error! Error in read (%s).", strerror (errno)); + /* exception will be thrown in managed code */ + mono_error_set_execution_engine (error, "Entropy error! Error in read (%s).", strerror (errno)); + return FALSE; } + buffer += err; + buffer_size -= err; } return TRUE; } From 2b596afa0f33735b6bf17052a03857fecc59fc54 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 16:14:27 +0100 Subject: [PATCH 016/116] wip --- .../System.Private.CoreLib.Shared.projitems | 21 +++++++++--------- .../System.Private.CoreLib.csproj | 22 +++++++++++-------- .../CMakeLists.txt | 4 ++-- .../CMakeLists.txt | 8 +++---- .../extra_libs.cmake | 2 +- src/native/libs/System.Native/CMakeLists.txt | 6 ++--- .../System.Net.Security.Native/CMakeLists.txt | 4 ++-- src/tests/build.sh | 2 +- 8 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index b5f1f4217c2f2..a8744ffc3e59d 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -12,7 +12,7 @@ enable true true - true + true true true true @@ -20,7 +20,7 @@ $(MSBuildThisFileDirectory)ILLink\ true true - true + true $(DefineConstants);BIGENDIAN @@ -37,6 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD @@ -2019,7 +2020,7 @@ - + Common\Interop\Unix\Interop.Errors.cs @@ -2268,7 +2269,7 @@ - + @@ -2277,7 +2278,7 @@ - + @@ -2311,7 +2312,7 @@ - + @@ -2413,7 +2414,7 @@ - + @@ -2426,11 +2427,11 @@ - + - + @@ -2448,7 +2449,7 @@ - + diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index e1a6a89baec33..91cc8204c03bc 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -87,6 +87,10 @@ AnyCPU $(DefineConstants);TARGET_WASM + + AnyCPU + $(DefineConstants);TARGET_WASI + @@ -125,13 +129,13 @@ $(DefineConstants);MONO_FEATURE_SRE true - true - true + true + true true true - true - true - true + true + true + true true @@ -278,16 +282,16 @@ - + - + - + - + diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 5e2fb2948cc43..0ee4e400c5f4c 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -77,11 +77,11 @@ if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS endif() # time zone names are filtered out of icu data for the browser and associated functionality is disabled -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt index a44f847dfca43..78f4d2ba90b19 100644 --- a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +++ b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt @@ -6,7 +6,7 @@ set(NATIVECOMPRESSION_SOURCES pal_zlib.c ) -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) if (CLR_CMAKE_USE_SYSTEM_BROTLI) add_definitions(-DFEATURE_USE_SYSTEM_BROTLI) @@ -25,11 +25,11 @@ if (NOT CLR_CMAKE_TARGET_BROWSER) ) endif () -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(NATIVE_LIBS_EXTRA) append_extra_compression_libs(NATIVE_LIBS_EXTRA) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) include(${CLR_SRC_NATIVE_DIR}/external/zlib.cmake) add_definitions(-DINTERNAL_ZLIB) set(NATIVECOMPRESSION_SOURCES ${ZLIB_SOURCES} ${NATIVECOMPRESSION_SOURCES}) @@ -118,7 +118,7 @@ else () ) endif () - if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVECOMPRESSION_SOURCES ${NATIVECOMPRESSION_SOURCES} entrypoints.c) endif () diff --git a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake index b10776372f6cf..78530ae98e8ff 100644 --- a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake +++ b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake @@ -1,7 +1,7 @@ macro(append_extra_compression_libs NativeLibsExtra) # TODO: remove the mono-style HOST_ variable checks once Mono is using eng/native/configureplatform.cmake to define the CLR_CMAKE_TARGET_ defines - if (CLR_CMAKE_TARGET_BROWSER OR HOST_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR HOST_BROWSER OR CLR_CMAKE_TARGET_WASI OR HOST_WASI) # nothing special to link elseif (CLR_CMAKE_TARGET_ANDROID OR HOST_ANDROID) # need special case here since we want to link against libz.so but find_package() would resolve libz.a diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 61cd36da93b79..5a3fb30fd9d1c 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -79,7 +79,7 @@ else () pal_iossupportversion.c) endif () -if (NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) list (APPEND NATIVE_SOURCES pal_networkchange.c) endif () @@ -107,7 +107,7 @@ if (GEN_SHARED_LIB) ${NATIVE_LIBS_EXTRA} ) - if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) add_custom_command(TARGET System.Native POST_BUILD COMMENT "Verifying System.Native entry points against entrypoints.c " COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh @@ -121,7 +121,7 @@ if (GEN_SHARED_LIB) install_with_stripped_symbols (System.Native PROGRAMS .) endif () -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVE_SOURCES ${NATIVE_SOURCES} entrypoints.c) endif() diff --git a/src/native/libs/System.Net.Security.Native/CMakeLists.txt b/src/native/libs/System.Net.Security.Native/CMakeLists.txt index 6fbe18f76872e..50c9228fe3dd3 100644 --- a/src/native/libs/System.Net.Security.Native/CMakeLists.txt +++ b/src/native/libs/System.Net.Security.Native/CMakeLists.txt @@ -19,7 +19,7 @@ if (GEN_SHARED_LIB) ) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) +if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGSS_SOURCES ${NATIVEGSS_SOURCES} entrypoints.c) endif() @@ -35,7 +35,7 @@ if (GEN_SHARED_LIB) ${NATIVE_LIBS_EXTRA} ) - if (NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER) + if (NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) add_custom_command(TARGET System.Net.Security.Native POST_BUILD COMMENT "Verifying System.Net.Security.Native entry points against entrypoints.c " COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-entrypoints.sh diff --git a/src/tests/build.sh b/src/tests/build.sh index c6f30ccf3670c..319b5958a99ca 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "Wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From cf1bf9d101ac67ae873f2cd5068824e900891f78 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 16:23:27 +0100 Subject: [PATCH 017/116] wip --- eng/native/configurecompiler.cmake | 6 +++--- eng/native/configureplatform.cmake | 16 ++++++++++++++-- eng/native/configuretools.cmake | 2 +- src/native/libs/CMakeLists.txt | 10 +++++----- src/native/libs/configure.cmake | 4 ++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c7cb47bfcbb56..844dfc0874a84 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -169,7 +169,7 @@ elseif (CLR_CMAKE_HOST_UNIX) endif () endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED) - if(CLR_CMAKE_HOST_BROWSER) + if(CLR_CMAKE_HOST_BROWSER OR CLR_CMAKE_HOST_WASI) # The emscripten build has additional warnings so -Werror breaks add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-alloca) @@ -391,7 +391,7 @@ if (CLR_CMAKE_HOST_UNIX) add_definitions(-DLSE_INSTRUCTIONS_ENABLED_BY_DEFAULT) add_compile_options(-mcpu=apple-m1) endif(CLR_CMAKE_HOST_UNIX_ARM64) - elseif(NOT CLR_CMAKE_HOST_BROWSER) + elseif(NOT CLR_CMAKE_HOST_BROWSER AND NOT CLR_CMAKE_HOST_WASI) check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) add_compile_options(-fstack-protector-strong) @@ -789,7 +789,7 @@ if (CLR_CMAKE_HOST_WIN32) message(FATAL_ERROR "MC not found") endif() -elseif (NOT CLR_CMAKE_HOST_BROWSER) +elseif (NOT CLR_CMAKE_HOST_BROWSER AND NOT CLR_CMAKE_HOST_WASI) # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995. # # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 506211704068a..cc358ae63697c 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -214,6 +214,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten) set(CLR_CMAKE_HOST_BROWSER 1) endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_HOST_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + #-------------------------------------------- # This repo builds two set of binaries # 1. binaries which execute on target arch machine @@ -263,6 +267,9 @@ elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) elseif(CLR_CMAKE_HOST_BROWSER) set(CLR_CMAKE_HOST_ARCH_WASM 1) set(CLR_CMAKE_HOST_ARCH "wasm") +elseif(CLR_CMAKE_HOST_WASI) + set(CLR_CMAKE_HOST_ARCH_WASM 1) + set(CLR_CMAKE_HOST_ARCH "wasm") elseif(CLR_CMAKE_HOST_UNIX_MIPS64) set(CLR_CMAKE_HOST_ARCH_MIPS64 1) set(CLR_CMAKE_HOST_ARCH "mips64") @@ -410,6 +417,11 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) set(CLR_CMAKE_TARGET_BROWSER 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_TARGET_UNIX 1) + set(CLR_CMAKE_TARGET_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + if(CLR_CMAKE_TARGET_UNIX) if(CLR_CMAKE_TARGET_ARCH STREQUAL x64) set(CLR_CMAKE_TARGET_UNIX_AMD64 1) @@ -443,7 +455,7 @@ else() endif(CLR_CMAKE_TARGET_UNIX) # check if host & target os/arch combination are valid -if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)) +if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI) if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows)) message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}") endif() @@ -455,7 +467,7 @@ if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)) endif() endif() -if(NOT CLR_CMAKE_TARGET_BROWSER) +if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) # The default linker on Solaris also does not support PIE. if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 07a3bbfafe4dd..1f800b0f89789 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -6,7 +6,7 @@ if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$") set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}") endif() -if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) +if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(APPLE) set(TOOLSET_PREFIX "") diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 26ff71928ffb6..056a46411f9be 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -35,7 +35,7 @@ else () set(STATIC_LIB_DESTINATION .) endif () -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(CMAKE_MACOSX_RPATH ON) if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) @@ -48,7 +48,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common) add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(GEN_SHARED_LIB 0) set(STATIC_LIB_DESTINATION .) endif () @@ -133,10 +133,10 @@ endif () add_subdirectory(System.IO.Compression.Native) -if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) +if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) include(configure.cmake) - if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) + if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID) add_subdirectory(System.IO.Ports.Native) endif () @@ -154,7 +154,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER) add_subdirectory(System.Native) - if (CLR_CMAKE_TARGET_BROWSER) + if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) # skip for now elseif (CLR_CMAKE_TARGET_MACCATALYST) add_subdirectory(System.Net.Security.Native) diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 7c5b88e96d5d0..2e9056f6c42f7 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -577,7 +577,7 @@ elseif(CLR_CMAKE_TARGET_ANDROID) unset(HAVE_ALIGNED_ALLOC) # only exists on newer Android set(HAVE_CLOCK_MONOTONIC 1) set(HAVE_CLOCK_REALTIME 1) -elseif(CLR_CMAKE_TARGET_BROWSER) +elseif(CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(HAVE_FORK 0) else() if(CLR_CMAKE_TARGET_OSX) @@ -1007,7 +1007,7 @@ set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES}) set (HAVE_INOTIFY 0) if (HAVE_INOTIFY_INIT AND HAVE_INOTIFY_ADD_WATCH AND HAVE_INOTIFY_RM_WATCH) set (HAVE_INOTIFY 1) -elseif (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_BROWSER) +elseif (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) message(FATAL_ERROR "Cannot find inotify functions on a Linux platform.") endif() From f22c691190b1ddca737195ca671f54ba33f6dd7e Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 16:53:13 +0100 Subject: [PATCH 018/116] wip --- eng/native/build-commons.sh | 5 ++++- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 11 +++++++++-- src/native/libs/build-native.sh | 26 ++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index ae0761c84a1af..c8af8e08dbbf6 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -163,11 +163,14 @@ build_native() popd else cmake_command=cmake - if [[ "$build_arch" == "wasm" ]]; then + if [[ "$build_arch" == "wasm" && "$__TargetOS" == "Browser" ]]; then cmake_command="emcmake cmake" echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" exit_code="$?" + elif [[ "$build_arch" == "wasm" ]]; then + echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!" + exit 1 else # For non-wasm Unix scenarios, we may have to use an old version of CMake that doesn't support # multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation. diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index c3bf9adbbef53..22c6b88d79823 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -92,7 +92,7 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then cmake_command="$SCAN_BUILD_COMMAND $cmake_command" fi -if [[ "$host_arch" == "wasm" ]]; then +if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" fi diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 75012240633da..ab5d9c2ff6561 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -148,8 +148,13 @@ initDistroRidGlobal() initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}" if [ "$buildArch" = "wasm" ]; then - __DistroRid=browser-wasm - export __DistroRid + if [ "$targetOs" = "Browser" ]; then + __DistroRid=browser-wasm + export __DistroRid + elif [ "$targetOs" = "Wasi" ]; then + __DistroRid=wasi-wasm + export __DistroRid + fi fi if [ -z "${__DistroRid}" ]; then @@ -186,6 +191,8 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" + elif [ "$targetOs" = "Wasi" ]; then + distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" elif [ "$targetOs" = "illumos" ]; then diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index f896736cfd7b1..e89da93691612 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -42,15 +42,33 @@ __VerboseBuild=false source "$__RepoRootDir"/eng/native/build-commons.sh # Set cross build - -if [[ "$__TargetArch" == wasm ]]; then +if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then - echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." - exit 1 + if [[ -d "$__RepoRootDir"/src/mono/wasm/emsdk/ ]]; then + export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + else + echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." + exit 1 + fi fi source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) +elif [[ "$__TargetOS" == Wasi ]]; then + if [[ -z "$WASI_SDK_PATH" ]]; then + if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk/ ]]; then + export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + else + echo "Error: You need to set the WASI_SDK_PATH environment variable pointing to the WASI SDK root." + exit 1 + fi + fi + + export CLR_CC="$WASI_SDK_PATH"bin/clang + export TARGET_BUILD_ARCH=wasm + __CMakeArgs="-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.cmake" + echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! + exit 0 elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true From ace97ff32ef19687d104e0af1772238c787a3a78 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 17:28:00 +0100 Subject: [PATCH 019/116] wip --- src/mono/mono/utils/CMakeLists.txt | 2 +- src/mono/wasi/Makefile | 26 -------------------------- src/mono/wasi/Makefile.variable | 16 ---------------- src/mono/wasi/runtime/CMakeLists.txt | 5 +++-- src/mono/wasi/wasi.proj | 15 +++++++++------ 5 files changed, 13 insertions(+), 51 deletions(-) delete mode 100644 src/mono/wasi/Makefile delete mode 100644 src/mono/wasi/Makefile.variable diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 4d552b6e033dd..6738f5eb7ca7d 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -217,7 +217,7 @@ elseif(TARGET_RISCV64) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-riscv.c") elseif(TARGET_S390X) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-s390x.c") -elseif(TARGET_WASM) +elseif(TARGET_BROWSER) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-wasm.c;mono-mmap-wasm.c") elseif(TARGET_POWERPC OR TARGET_POWERPC64) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-ppc.c") diff --git a/src/mono/wasi/Makefile b/src/mono/wasi/Makefile deleted file mode 100644 index 00a4306a9c920..0000000000000 --- a/src/mono/wasi/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -include Makefile.variable - -all: build-all - -build-all: $(WASI_SDK_CLANG) - mkdir -p $(WASI_OBJ_DIR) - cd $(WASI_OBJ_DIR) && \ - PATH=$(NINJA_DIR):${PATH} cmake -G Ninja \ - -DWASI_SDK_PREFIX=$(WASI_SDK_ROOT) \ - -DCMAKE_SYSROOT=$(WASI_SDK_ROOT)/share/wasi-sysroot \ - -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_ROOT)/share/cmake/wasi-sdk.cmake \ - -DCMAKE_C_FLAGS="--sysroot=$(WASI_SDK_ROOT)/share/wasi-sysroot \ - -I$(CURDIR)/include -I$(TOP)/src/mono -I$(TOP)/src/native/public -I$(TOP)/src/mono/mono/eglib -I$(WASI_OBJ_DIR)/mono/eglib -I$(WASI_OBJ_DIR) -I$(TOP)/artifacts/obj/wasm -I$(TOP)/src/mono/wasm/runtime" \ - -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_ROOT)/share/wasi-sysroot" \ - -DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,threads,qcalls,debugger_agent,sockets,eventpipe \ - -DDISABLE_SHARED_LIBS=1 \ - -Wl,--allow-undefined \ - $(TOP)/src/mono - cd $(WASI_OBJ_DIR) && PATH=$(NINJA_DIR):${PATH} ninja - - mkdir -p $(WASI_BIN_DIR) - cp $(WASI_OBJ_DIR)/mono/mini/*.a $(WASI_OBJ_DIR)/libmono-wasi-driver.a $(WASI_BIN_DIR) - rm -rf $(WASI_BIN_DIR)/libmono-component-hot_reload-static.a - rm -rf $(WASI_BIN_DIR)/libmono-component-diagnostics_tracing-static.a - mkdir -p $(WASI_BIN_DIR)/include/mono-wasi - cp mono-wasi-driver/*.h $(WASI_BIN_DIR)/include/mono-wasi diff --git a/src/mono/wasi/Makefile.variable b/src/mono/wasi/Makefile.variable deleted file mode 100644 index ef8b91b245c24..0000000000000 --- a/src/mono/wasi/Makefile.variable +++ /dev/null @@ -1,16 +0,0 @@ -TOP=$(realpath $(CURDIR)/../../..) -CONFIG?=Release -RUNTIME_CONFIG?=Release -WASI_SDK_VERSION=12 - -WASI_OBJ_DIR=$(TOP)/artifacts/obj/mono/Wasi.$(RUNTIME_CONFIG) -WASI_BIN_DIR=$(TOP)/artifacts/bin/mono/Wasi.$(RUNTIME_CONFIG) -WASI_SDK_ROOT=$(WASI_OBJ_DIR)/wasi-sdk-$(WASI_SDK_VERSION).0 -WASI_SDK_CLANG=$(WASI_SDK_ROOT)/bin/clang - -WASMTIME_VERSION=v0.39.1 -WASMTIME_DIR_NAME=wasmtime-$(WASMTIME_VERSION)-x86_64-linux -WASMTIME_DIR=$(TOP)/artifacts/bin/$(WASMTIME_DIR_NAME) - -NINJA_VERSION=v1.11.0 -NINJA_DIR=$(TOP)/artifacts/bin/ninja diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 815be6c7c7e6b..fee2401fe2de1 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -22,8 +22,9 @@ target_link_libraries(dotnet ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a ${MONO_ARTIFACTS_DIR}/libmono-ilgen.a ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a - ${NATIVE_BIN_DIR}/libSystem.Native.a - ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a) +#TODOWASI ${NATIVE_BIN_DIR}/libSystem.Native.a +#TODOWASI ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a +) set_target_properties(dotnet PROPERTIES LINK_DEPENDS "${NATIVE_BIN_DIR}/src/wasi-default.rsp;" diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index e4002a5027271..c1fd1ca34f97b 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -147,17 +147,19 @@ $(ArtifactsObjDir)wasm/pinvoke-table.h $(ArtifactsObjDir)wasm/wasm_m2n_invoke.g.h - -g -Os -s -DDEBUG=1 -DENABLE_AOT_PROFILER=1 + -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -Oz $(CMakeConfigurationWasiFlags) -O2 - $(CMakeConfigurationLinkFlags) --emit-symbol-map - - -DWASI_SDK_PATH="$(WASI_SDK_PATH.TrimEnd('\/'))" cmake $(MSBuildThisFileDirectory)runtime - $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_BUILD_TYPE=$(Configuration) + + $(CMakeBuildRuntimeConfigureCmd) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" @@ -169,7 +171,8 @@ $(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd" $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1 - $(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath) + + -v cmake --build . --config $(Configuration) $(CmakeOptions) From ea5db8735830087d2b503ee88502b7272c4e50de Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 17:51:40 +0100 Subject: [PATCH 020/116] wip --- src/mono/cmake/configure.cmake | 5 ++++- src/mono/mono.proj | 1 - src/mono/mono/utils/CMakeLists.txt | 3 +++ src/mono/wasi/runtime/CMakeLists.txt | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index d0c61f25dc848..28b664b466721 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -99,7 +99,10 @@ if(NOT HOST_DARWIN) ac_check_funcs (getentropy) endif() -find_package(Threads) +if(NOT HOST_WASI) + # TODOWASI + find_package(Threads) +endif() # Needed to find pthread_ symbols set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}") diff --git a/src/mono/mono.proj b/src/mono/mono.proj index aae312cec6854..7060baba963f2 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -396,7 +396,6 @@ <_MonoCMakeArgs Include="$(EscapedQuoteW)-DWASI_SDK_PREFIX=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)'))$(EscapedQuoteW)" /> <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'cmake', 'wasi-sdk.cmake'))$(EscapedQuoteW)" /> <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_SYSROOT=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'wasi-sysroot'))$(EscapedQuoteW)" /> - <_MonoCMakeArgs Include="-DCMAKE_CXX_FLAGS=$(EscapedQuoteW) - -sysroot=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'wasi-sysroot'))$(EscapedQuoteW)" /> --> <_MonoBuildEnv Include="TARGET_BUILD_ARCH=wasm" /> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 6738f5eb7ca7d..30c10c7ff986d 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -219,6 +219,9 @@ elseif(TARGET_S390X) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-s390x.c") elseif(TARGET_BROWSER) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-wasm.c;mono-mmap-wasm.c") +elseif(TARGET_WASI) +#TODOWASI +set(utils_arch_sources "${utils_arch_sources}") elseif(TARGET_POWERPC OR TARGET_POWERPC64) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-ppc.c") else() diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index fee2401fe2de1..1027aaceb354e 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -31,7 +31,7 @@ set_target_properties(dotnet PROPERTIES LINK_FLAGS "@${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-link.rsp ${CONFIGURATION_LINK_FLAGS} " RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}") -set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}") +set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}${CMAKE_CXX_FLAGS}") #TODOWASI wasm-opt From 318ef0fe95e5c6b69a99b7495aa4c4953a412cef Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 8 Nov 2022 18:11:18 +0100 Subject: [PATCH 021/116] wip --- eng/native/configurecompiler.cmake | 6 +++++- eng/native/gen-buildsys.sh | 4 ---- src/native/libs/System.Native/pal_io.c | 2 ++ src/native/libs/build-native.sh | 4 +--- src/native/libs/configure.cmake | 19 ++++++++++++------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 844dfc0874a84..4c52cd49bf7bc 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -543,7 +543,11 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_ILLUMOS>) endif() endif() -else(CLR_CMAKE_TARGET_UNIX) +elseif(CLR_CMAKE_TARGET_WASI) + add_compile_definitions($<$>>:TARGET_WASI>) +elseif(CLR_CMAKE_TARGET_BROWSER) + add_compile_definitions($<$>>:TARGET_BROWSER>) +else() add_compile_definitions($<$>>:TARGET_WINDOWS>) endif(CLR_CMAKE_TARGET_UNIX) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 1f921bf3333c9..9f371a68f0bae 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -94,12 +94,8 @@ fi if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" - echo "!!!!!!!!!!!!!!! emcmake !!!!!!!!!!!!!!" elif [[ "$host_arch" == "wasm" && "$2" =~ "-Wasi-" ]]; then true -elif [[ "$host_arch" == "wasm" ]]; then - echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!! unexpected2" - exit 1 fi # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 9332b46bb28bb..ea8ee924acfab 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -840,6 +840,8 @@ intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) { pathTemplate[firstSuffixIndex] = firstSuffixChar; } +#elif TARGET_WASI + // TODOWASI #else #error "Cannot find mkstemps nor mkstemp on this platform" #endif diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index ec40708e6f444..62387cd15d685 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -58,7 +58,7 @@ if [[ "$__TargetOS" == Browser ]]; then elif [[ "$__TargetOS" == Wasi ]]; then if [[ -z "$WASI_SDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk/ ]]; then - export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasi/wasi-sdk/ else echo "Error: You need to set the WASI_SDK_PATH environment variable pointing to the WASI SDK root." exit 1 @@ -68,8 +68,6 @@ elif [[ "$__TargetOS" == Wasi ]]; then export CLR_CC="$WASI_SDK_PATH"bin/clang export TARGET_BUILD_ARCH=wasm __CMakeArgs="-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.cmake" - echo !!!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!!!! - exit 0 elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 2e9056f6c42f7..237c8b16f1978 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -661,7 +661,10 @@ elseif (HAVE_PTHREAD_IN_LIBC) set(PTHREAD_LIBRARY c) endif() -check_library_exists(${PTHREAD_LIBRARY} pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK) +if (NOT CLR_CMAKE_TARGET_WASI) + # TODOWASI + check_library_exists(${PTHREAD_LIBRARY} pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK) +endif() check_symbol_exists( futimes @@ -784,7 +787,7 @@ check_c_source_compiles( " HAVE_MKSTEMP) -if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP) +if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP AND NOT CLR_CMAKE_TARGET_WASI) message(FATAL_ERROR "Cannot find mkstemps nor mkstemp on this platform.") endif() @@ -1092,14 +1095,16 @@ check_symbol_exists( sys/sysmacros.h HAVE_MAKEDEV_SYSMACROSH) -if (NOT HAVE_MAKEDEV_FILEH AND NOT HAVE_MAKEDEV_SYSMACROSH) +if (NOT HAVE_MAKEDEV_FILEH AND NOT HAVE_MAKEDEV_SYSMACROSH AND NOT CLR_CMAKE_TARGET_WASI) message(FATAL_ERROR "Cannot find the makedev function on this platform.") endif() -check_symbol_exists( - getgrgid_r - grp.h - HAVE_GETGRGID_R) +if (NOT CLR_CMAKE_TARGET_WASI) + check_symbol_exists( + getgrgid_r + grp.h + HAVE_GETGRGID_R) +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Common/pal_config.h.in From e785d9e95456c54ede4026d99f91fbba8cc990db Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 9 Nov 2022 17:12:26 +0100 Subject: [PATCH 022/116] wip --- src/mono/wasi/runtime/CMakeLists.txt | 2 +- src/native/libs/CMakeLists.txt | 4 ++++ src/native/libs/System.IO.Compression.Native/CMakeLists.txt | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 1027aaceb354e..33ab84f9f9718 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -12,7 +12,7 @@ target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${ set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLAGS}) -target_link_libraries(dotnet +target_link_libraries(dotnet.wasm ${ICU_LIB_DIR}/libicuuc.a ${ICU_LIB_DIR}/libicui18n.a ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 056a46411f9be..9a7d06ad89181 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -53,6 +53,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(STATIC_LIB_DESTINATION .) endif () + if (CLR_CMAKE_TARGET_WASI) + add_compile_options(-I${CLR_REPO_ROOT_DIR}/src/mono/wasi/include/) + endif () + if (CLR_CMAKE_TARGET_TVOS) # with -fembed-bitcode passing -headerpad_max_install_names is not allowed so remove it from the CMake flags string(REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS}) diff --git a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt index 78f4d2ba90b19..5208182988c2a 100644 --- a/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +++ b/src/native/libs/System.IO.Compression.Native/CMakeLists.txt @@ -44,7 +44,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) # Delete this suppression once brotli is upgraded to vNext (current latest v1.0.9 # does not contain upstream fix: https://github.com/google/brotli/commit/0a3944c) - set(FLAGS "${FLAGS} -Wno-vla-parameter") + if (NOT CLR_CMAKE_TARGET_WASI) + # TODOWASI + set(FLAGS "${FLAGS} -Wno-vla-parameter") + endif () set_source_files_properties(${NATIVECOMPRESSION_SOURCES} PROPERTIES COMPILE_FLAGS ${FLAGS}) From 357c9788d88a6244eb5022828efbb93a6986c846 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 9 Nov 2022 18:31:38 +0100 Subject: [PATCH 023/116] wip --- src/mono/mono/profiler/browser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/profiler/browser.c b/src/mono/mono/profiler/browser.c index 01ec7fee11146..d25f0ecc4c9fa 100644 --- a/src/mono/mono/profiler/browser.c +++ b/src/mono/mono/profiler/browser.c @@ -7,7 +7,7 @@ #include -#ifdef TARGET_BROWSER +#ifdef HOST_BROWSER #include #include @@ -104,4 +104,4 @@ mono_profiler_init_browser (const char *desc) #endif /* HOST_WASM */ } -#endif /* TARGET_BROWSER */ +#endif /* HOST_BROWSER */ From 4b4a8b09056a70168f3f549a70de6e085a74ce48 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 9 Nov 2022 19:52:11 +0100 Subject: [PATCH 024/116] wip --- src/mono/cmake/configure.cmake | 6 ++---- src/mono/mono/mini/CMakeLists.txt | 2 +- src/mono/wasi/wasi-sdk-version.txt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 28b664b466721..e0952bd5abccd 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -265,14 +265,12 @@ elseif(HOST_IOS) endif() elseif(HOST_MACCAT) set(HAVE_SYSTEM 0) -elseif(HOST_BROWSER) - set(HAVE_FORK 0) -elseif(HOST_WASI) - set(HAVE_FORK 0) elseif(HOST_SOLARIS) set(HAVE_GETPROTOBYNAME 1) set(HAVE_NETINET_TCP_H 1) set(HAVE_GETADDRINFO 1) +elseif(HOST_BROWSER) + set(HAVE_FORK 0) elseif(HOST_WASI) # Redirected to errno.h set(SYS_ERRNO_H 0) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index b1a0c147af40b..ed445a1943045 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -325,7 +325,7 @@ else() set(llvm_runtime_sources) endif() -if(TARGET_WASM AND MONO_CROSS_COMPILE) +if(HOST_WASM AND MONO_CROSS_COMPILE) set(profiler_sources ../profiler/browser.c) else() set(profiler_sources "") diff --git a/src/mono/wasi/wasi-sdk-version.txt b/src/mono/wasi/wasi-sdk-version.txt index 3cacc0b93c9c9..19c7bdba7b1e9 100644 --- a/src/mono/wasi/wasi-sdk-version.txt +++ b/src/mono/wasi/wasi-sdk-version.txt @@ -1 +1 @@ -12 \ No newline at end of file +16 \ No newline at end of file From 5ccf1a4cc08d51065bd6e519f55e948e627d7feb Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 10 Nov 2022 17:43:39 +0100 Subject: [PATCH 025/116] dummy libs --- eng/native/configureplatform.cmake | 1 - src/mono/mono.proj | 6 +- src/mono/wasi/include/netdb.h | 1 + .../wasi/{include => mono-include}/driver.h | 0 .../wasi/{include => mono-include}/pinvoke.h | 0 .../wasi/{include => mono-include}/pthread.h | 0 .../wasi/{include => mono-include}/setjmp.h | 0 .../wasm-config.h.in | 0 src/mono/wasi/runtime/CMakeLists.txt | 5 +- src/mono/wasi/wasi.proj | 15 +- src/native/libs/CMakeLists.txt | 6 + src/native/libs/Common/pal_config.h.in | 8 + src/native/libs/Common/pal_error_common.h | 14 + src/native/libs/Common/pal_io_common.h | 4 + src/native/libs/System.Native/pal_console.c | 74 ++++ .../libs/System.Native/pal_dynamicload.c | 31 +- .../System.Native/pal_interfaceaddresses.c | 9 + src/native/libs/System.Native/pal_io.c | 359 +++++++++++++++++- .../libs/System.Native/pal_maphardwaretype.c | 4 + src/native/libs/System.Native/pal_mount.c | 24 ++ .../libs/System.Native/pal_networkchange.c | 2 + .../libs/System.Native/pal_networking.c | 332 ++++++++++++++++ .../System.Native/pal_networkstatistics.c | 2 + src/native/libs/System.Native/pal_process.c | 117 ++++++ src/native/libs/System.Native/pal_signal.c | 44 +++ src/native/libs/System.Native/pal_threading.c | 74 ++++ src/native/libs/System.Native/pal_uid.c | 50 +++ src/native/libs/configure.cmake | 32 ++ 28 files changed, 1197 insertions(+), 17 deletions(-) create mode 100644 src/mono/wasi/include/netdb.h rename src/mono/wasi/{include => mono-include}/driver.h (100%) rename src/mono/wasi/{include => mono-include}/pinvoke.h (100%) rename src/mono/wasi/{include => mono-include}/pthread.h (100%) rename src/mono/wasi/{include => mono-include}/setjmp.h (100%) rename src/mono/wasi/{include => mono-include}/wasm-config.h.in (100%) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index cc358ae63697c..2e10489fb370d 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -418,7 +418,6 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) - set(CLR_CMAKE_TARGET_UNIX 1) set(CLR_CMAKE_TARGET_WASI 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 7060baba963f2..b0aed859e4328 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -396,12 +396,16 @@ <_MonoCMakeArgs Include="$(EscapedQuoteW)-DWASI_SDK_PREFIX=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)'))$(EscapedQuoteW)" /> <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'cmake', 'wasi-sdk.cmake'))$(EscapedQuoteW)" /> <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_SYSROOT=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'wasi-sysroot'))$(EscapedQuoteW)" /> - --> <_MonoBuildEnv Include="TARGET_BUILD_ARCH=wasm" /> + --> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> + <_MonoCFLAGS Include="-D_WASI_EMULATED_SIGNAL"/> + <_MonoCFLAGS Include="-D_WASI_EMULATED_MMAN"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> diff --git a/src/mono/wasi/include/netdb.h b/src/mono/wasi/include/netdb.h new file mode 100644 index 0000000000000..f905f3bb8cd19 --- /dev/null +++ b/src/mono/wasi/include/netdb.h @@ -0,0 +1 @@ +const char *gai_strerror(int); diff --git a/src/mono/wasi/include/driver.h b/src/mono/wasi/mono-include/driver.h similarity index 100% rename from src/mono/wasi/include/driver.h rename to src/mono/wasi/mono-include/driver.h diff --git a/src/mono/wasi/include/pinvoke.h b/src/mono/wasi/mono-include/pinvoke.h similarity index 100% rename from src/mono/wasi/include/pinvoke.h rename to src/mono/wasi/mono-include/pinvoke.h diff --git a/src/mono/wasi/include/pthread.h b/src/mono/wasi/mono-include/pthread.h similarity index 100% rename from src/mono/wasi/include/pthread.h rename to src/mono/wasi/mono-include/pthread.h diff --git a/src/mono/wasi/include/setjmp.h b/src/mono/wasi/mono-include/setjmp.h similarity index 100% rename from src/mono/wasi/include/setjmp.h rename to src/mono/wasi/mono-include/setjmp.h diff --git a/src/mono/wasi/include/wasm-config.h.in b/src/mono/wasi/mono-include/wasm-config.h.in similarity index 100% rename from src/mono/wasi/include/wasm-config.h.in rename to src/mono/wasi/mono-include/wasm-config.h.in diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 33ab84f9f9718..53c289c42d0fd 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -5,6 +5,7 @@ project(mono-wasi-runtime C) option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON) option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF) +set(CMAKE_EXECUTABLE_SUFFIX ".wasm") add_executable(dotnet driver.c stubs.c synthetic-pthread.c) target_include_directories(dotnet PUBLIC ${MONO_INCLUDES} ${MONO_OBJ_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/include/wasm) @@ -12,7 +13,7 @@ target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${ set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLAGS}) -target_link_libraries(dotnet.wasm +target_link_libraries(dotnet ${ICU_LIB_DIR}/libicuuc.a ${ICU_LIB_DIR}/libicui18n.a ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a @@ -35,4 +36,4 @@ set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}${CMAKE_CXX_FLAGS}") #TODOWASI wasm-opt -configure_file(../include/wasm-config.h.in include/wasm/wasm-config.h) +configure_file(../mono-include/wasm-config.h.in include/wasm/wasm-config.h) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index c1fd1ca34f97b..f51d66977e04a 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -90,11 +90,14 @@ <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(TargetsWasi)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> - + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> @@ -212,7 +215,7 @@ - + +#endif #include #if HAVE_GNU_LIBNAMES_H #include #endif +#if !defined(TARGET_WASI) void* SystemNative_LoadLibrary(const char* filename) { // Check whether we have been requested to load 'libc'. If that's the case, then: @@ -55,11 +58,35 @@ void SystemNative_FreeLibrary(void* handle) { dlclose(handle); } +#else /* TARGET_WASI */ +void* SystemNative_LoadLibrary(const char* filename) +{ + // TODOWASI + return NULL; +} + +void* SystemNative_GetLoadLibraryError(void) +{ + // TODOWASI + return NULL; +} + +void* SystemNative_GetProcAddress(void* handle, const char* symbol) +{ + // TODOWASI + return NULL; +} + +void SystemNative_FreeLibrary(void* handle) +{ + // TODOWASI +} +#endif /* TARGET_WASI */ -#ifdef TARGET_ANDROID +#if defined TARGET_ANDROID || defined TARGET_WASI void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) { - return (void*)RTLD_DEFAULT; + return NULL; } #else static void* volatile g_defaultSearchOrderPseudoHandle = NULL; diff --git a/src/native/libs/System.Native/pal_interfaceaddresses.c b/src/native/libs/System.Native/pal_interfaceaddresses.c index 4af5d59ae96db..8fee3e0e3e964 100644 --- a/src/native/libs/System.Native/pal_interfaceaddresses.c +++ b/src/native/libs/System.Native/pal_interfaceaddresses.c @@ -15,11 +15,17 @@ #include #endif #ifdef ANDROID_GETIFADDRS_WORKAROUND +#if HAVE_DLFCN_H #include +#endif +#if HAVE_PTHREAD_H #include +#endif #include "pal_ifaddrs.h" // fallback for Android API 21-23 #endif +#if HAVE_NET_IF_H #include +#endif #include #include #include @@ -50,6 +56,7 @@ #elif defined(AF_LINK) #include #include +#elif defined(TARGET_WASI) #else #error System must have AF_PACKET or AF_LINK. #endif @@ -66,6 +73,7 @@ // mask parameter is pointer to buffer where address starts and length is // buffer length e.g. 4 for IPv4 and 16 for IPv6. // Code bellow counts consecutive number of 1 bits. +#if !defined(TARGET_WASI) static inline uint8_t mask2prefix(uint8_t* mask, int length) { uint8_t len = 0; @@ -101,6 +109,7 @@ static inline uint8_t mask2prefix(uint8_t* mask, int length) return len; } +#endif /* TARGET_WASI */ #ifdef ANDROID_GETIFADDRS_WORKAROUND // This workaround is necessary as long as we support Android API 21-23 and it can be removed once diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index ea8ee924acfab..b2b9bab549dc1 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -26,8 +26,12 @@ #include #endif #include +#if HAVE_SYSLOG_H #include +#endif +#if HAVE_TERMIOS_H #include +#endif #include #include #if HAVE_FCOPYFILE @@ -42,7 +46,7 @@ #include #elif HAVE_STATFS_MOUNT // BSD #include -#elif !HAVE_NON_LEGACY_STATFS // SunOS +#elif HAVE_SYS_STATVFS_H && !HAVE_NON_LEGACY_STATFS // SunOS #include #include #include @@ -70,7 +74,7 @@ extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__); // Ensure FICLONE is defined for all Linux builds. #ifndef FICLONE #define FICLONE _IOW(0x94, 9, int) -#endif +#endif /* __linux__ */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-id-macro" @@ -93,15 +97,16 @@ extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__); #endif +#if !defined(TARGET_WASI) #if HAVE_STAT64 #define stat_ stat64 #define fstat_ fstat64 #define lstat_ lstat64 -#else +#else /* HAVE_STAT64 */ #define stat_ stat #define fstat_ fstat #define lstat_ lstat -#endif +#endif /* HAVE_STAT64 */ // These numeric values are specified by POSIX. // Validate that our definitions match. @@ -132,6 +137,7 @@ c_static_assert(PAL_S_IFDIR == S_IFDIR); c_static_assert(PAL_S_IFREG == S_IFREG); c_static_assert(PAL_S_IFLNK == S_IFLNK); c_static_assert(PAL_S_IFSOCK == S_IFSOCK); +#endif /* TARGET_WASI */ // Validate that our enum for inode types is the same as what is // declared by the dirent.h header on the local system. @@ -139,7 +145,7 @@ c_static_assert(PAL_S_IFSOCK == S_IFSOCK); // WebAssembly (BROWSER) has dirent d_type but is not correct // by returning UNKNOWN the managed code properly stats the file // to detect if entry is directory or not. -#if defined(DT_UNKNOWN) || defined(TARGET_WASM) +#if (defined(DT_UNKNOWN) || defined(TARGET_WASM)) && !defined(TARGET_WASI) c_static_assert((int)PAL_DT_UNKNOWN == (int)DT_UNKNOWN); c_static_assert((int)PAL_DT_FIFO == (int)DT_FIFO); c_static_assert((int)PAL_DT_CHR == (int)DT_CHR); @@ -187,6 +193,7 @@ c_static_assert(PAL_IN_EXCL_UNLINK == IN_EXCL_UNLINK); c_static_assert(PAL_IN_ISDIR == IN_ISDIR); #endif // HAVE_INOTIFY +#if !defined(TARGET_WASI) static void ConvertFileStatus(const struct stat_* src, FileStatus* dst) { dst->Dev = (int64_t)src->st_dev; @@ -1857,3 +1864,345 @@ int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount assert(count >= -1); return count; } + +#else /* TARGET_WASI */ + +int32_t SystemNative_Stat(const char* path, FileStatus* output) +{ + return -1; +} + +int32_t SystemNative_FStat(intptr_t fd, FileStatus* output) +{ + return -1; +} + +int32_t SystemNative_LStat(const char* path, FileStatus* output) +{ + return -1; +} + +intptr_t SystemNative_Open(const char* path, int32_t flags, int32_t mode) +{ + return -1; +} + +int32_t SystemNative_Close(intptr_t fd) +{ + return -1; +} + +intptr_t SystemNative_Dup(intptr_t oldfd) +{ + return -1; +} + +int32_t SystemNative_Unlink(const char* path) +{ + return -1; +} + +intptr_t SystemNative_ShmOpen(const char* name, int32_t flags, int32_t mode) +{ + return -1; +} + +int32_t SystemNative_ShmUnlink(const char* name) +{ + return -1; +} + +int32_t SystemNative_GetReadDirRBufferSize(void) +{ + return -1; +} + +int32_t SystemNative_ReadDirR(DIR* dir, uint8_t* buffer, int32_t bufferSize, DirectoryEntry* outputEntry) +{ + return -1; +} + +DIR* SystemNative_OpenDir(const char* path) +{ + return NULL; +} + +int32_t SystemNative_CloseDir(DIR* dir) +{ + return -1; +} + +int32_t SystemNative_Pipe(int32_t pipeFds[2], int32_t flags) +{ + return -1; +} + +int32_t SystemNative_FcntlSetFD(intptr_t fd, int32_t flags) +{ + return -1; +} + +int32_t SystemNative_FcntlGetFD(intptr_t fd) +{ + return -1; +} + +int32_t SystemNative_FcntlCanGetSetPipeSz(void) +{ + return -1; +} + +int32_t SystemNative_FcntlGetPipeSz(intptr_t fd) +{ + return -1; +} + +int32_t SystemNative_FcntlSetPipeSz(intptr_t fd, int32_t size) +{ + return -1; +} + +int32_t SystemNative_FcntlSetIsNonBlocking(intptr_t fd, int32_t isNonBlocking) +{ + return -1; +} + +int32_t SystemNative_FcntlGetIsNonBlocking(intptr_t fd, int32_t* isNonBlocking) +{ + return -1; +} + +int32_t SystemNative_MkDir(const char* path, int32_t mode) +{ + return -1; +} + +int32_t SystemNative_ChMod(const char* path, int32_t mode) +{ + return -1; +} + +int32_t SystemNative_FChMod(intptr_t fd, int32_t mode) +{ + return -1; +} + +int32_t SystemNative_FSync(intptr_t fd) +{ + return -1; +} + +int32_t SystemNative_FLock(intptr_t fd, int32_t operation) +{ + return -1; +} + +int32_t SystemNative_ChDir(const char* path) +{ + return -1; +} + +int32_t SystemNative_Access(const char* path, int32_t mode) +{ + return -1; +} + +int64_t SystemNative_LSeek(intptr_t fd, int64_t offset, int32_t whence) +{ + return -1; +} + +int32_t SystemNative_SymLink(const char* target, const char* linkPath) +{ + return -1; +} + +void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber) +{ +} + +int32_t SystemNative_MkNod(const char* pathName, uint32_t mode, uint32_t major, uint32_t minor) +{ + return -1; +} + +int32_t SystemNative_MkFifo(const char* pathName, uint32_t mode) +{ + return -1; +} + +char* SystemNative_MkdTemp(char* pathTemplate) +{ + return NULL; +} + +intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) +{ + return -1; +} + +void* SystemNative_MMap(void* address, + uint64_t length, + int32_t protection, // bitwise OR of PAL_PROT_* + int32_t flags, // bitwise OR of PAL_MAP_*, but PRIVATE and SHARED are mutually exclusive. + intptr_t fd, + int64_t offset) +{ + return NULL; +} + +int32_t SystemNative_MUnmap(void* address, uint64_t length) +{ + return -1; +} + +int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice) +{ + return -1; +} + +int32_t SystemNative_MSync(void* address, uint64_t length, int32_t flags) +{ + return -1; +} + +int64_t SystemNative_SysConf(int32_t name) +{ + return -1; +} + +int32_t SystemNative_FTruncate(intptr_t fd, int64_t length) +{ + return -1; +} + +int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t milliseconds, uint32_t* triggered) +{ + return -1; +} + +int32_t SystemNative_PosixFAdvise(intptr_t fd, int64_t offset, int64_t length, int32_t advice) +{ + return -1; +} + +int32_t SystemNative_FAllocate(intptr_t fd, int64_t offset, int64_t length) +{ + return -1; +} + +int32_t SystemNative_Read(intptr_t fd, void* buffer, int32_t bufferSize) +{ + return -1; +} + +int32_t SystemNative_ReadLink(const char* path, char* buffer, int32_t bufferSize) +{ + return -1; +} + +int32_t SystemNative_Rename(const char* oldPath, const char* newPath) +{ + return -1; +} + +int32_t SystemNative_RmDir(const char* path) +{ + return -1; +} + +void SystemNative_Sync(void) +{ +} + +int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize) +{ + return -1; +} + +int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t sourceLength) +{ + return -1; +} + +intptr_t SystemNative_INotifyInit(void) +{ + return -1; +} + +int32_t SystemNative_INotifyAddWatch(intptr_t fd, const char* pathName, uint32_t mask) +{ + return -1; +} + +int32_t SystemNative_INotifyRemoveWatch(intptr_t fd, int32_t wd) +{ + return -1; +} + +int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid) +{ + return -1; +} + +char* SystemNative_RealPath(const char* path) +{ + return NULL; +} + +uint32_t SystemNative_GetFileSystemType(intptr_t fd) +{ + return 0xFFFFFFFF; +} + +int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType) +{ + return -1; +} + +int32_t SystemNative_LChflags(const char* path, uint32_t flags) +{ + return -1; +} + +int32_t SystemNative_FChflags(intptr_t fd, uint32_t flags) +{ + return -1; +} + +int32_t SystemNative_LChflagsCanSetHiddenFlag(void) +{ + return false; +} + +int32_t SystemNative_CanGetHiddenFlag(void) +{ + return false; +} + +int32_t SystemNative_ReadProcessStatusInfo(pid_t pid, ProcessStatus* processStatus) +{ + return -1; +} + +int32_t SystemNative_PRead(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) +{ + return -1; +} + +int32_t SystemNative_PWrite(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) +{ + return -1; +} + +int64_t SystemNative_PReadV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) +{ + return -1; +} + +int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) +{ + return -1; +} + +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_maphardwaretype.c b/src/native/libs/System.Native/pal_maphardwaretype.c index 064d802e6d6a8..2a37864b1eaaf 100644 --- a/src/native/libs/System.Native/pal_maphardwaretype.c +++ b/src/native/libs/System.Native/pal_maphardwaretype.c @@ -21,6 +21,7 @@ #elif defined(AF_LINK) #include #include +#elif defined(TARGET_WASI) #else #error System must have AF_PACKET or AF_LINK. #endif @@ -112,5 +113,8 @@ uint16_t MapHardwareType(uint16_t nativeType) default: return NetworkInterfaceType_Unknown; } +#elif defined(TARGET_WASI) + // TODOWASI + return NetworkInterfaceType_Unknown; #endif } diff --git a/src/native/libs/System.Native/pal_mount.c b/src/native/libs/System.Native/pal_mount.c index 2453bdfe9ede3..5458cbac49531 100644 --- a/src/native/libs/System.Native/pal_mount.c +++ b/src/native/libs/System.Native/pal_mount.c @@ -10,6 +10,7 @@ #include // Check if we should use getmntinfo or /proc/mounts +#if !defined(TARGET_WASI) #if HAVE_MNTINFO #include #else @@ -17,7 +18,9 @@ #if HAVE_SYS_MNTENT_H #include #include +#if HAVE_SYS_STATVFS_H #include +#endif #else #include #endif @@ -177,3 +180,24 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer return result; } +else /* TARGET_WASI */ +int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) +{ + // TODOWASI + return 0; +} + +int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInformation* mpi) +{ + // TODOWASI + memset(mpi, 0, sizeof(MountPointInformation)); + return -1; +} + +int32_t +SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer, int32_t bufferLength, int64_t* formatType) +{ + // TODOWASI + return -1; +} +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_networkchange.c b/src/native/libs/System.Native/pal_networkchange.c index b4386a762f3f0..56391820123dd 100644 --- a/src/native/libs/System.Native/pal_networkchange.c +++ b/src/native/libs/System.Native/pal_networkchange.c @@ -9,7 +9,9 @@ #include "pal_utilities.h" #include +#if HAVE_NET_IF_H #include +#endif #include #include #include diff --git a/src/native/libs/System.Native/pal_networking.c b/src/native/libs/System.Native/pal_networking.c index f96a8d9672fd5..aac624fc65fc2 100644 --- a/src/native/libs/System.Native/pal_networking.c +++ b/src/native/libs/System.Native/pal_networking.c @@ -10,7 +10,9 @@ #include #include +#if HAVE_PTHREAD_H #include +#endif #include #include #include @@ -30,7 +32,9 @@ #include #include #include +#if HAVE_NET_IF_H #include +#endif #include #include #include @@ -47,7 +51,9 @@ #include #endif #include +#if HAVE_PWD_H #include +#endif #if HAVE_SENDFILE_4 #include #elif HAVE_SENDFILE_6 @@ -112,6 +118,8 @@ static uint16_t GetKeventFlags(uint32_t flags) #endif #endif +#if !defined(TARGET_WASI) + #if !HAVE_IN_PKTINFO // On platforms, such as FreeBSD, where in_pktinfo // is not available, fallback to custom definition @@ -288,19 +296,29 @@ static int32_t ConvertGetAddrInfoAndGetNameInfoErrorsToPal(int32_t error) { case 0: return 0; +#ifdef EAI_AGAIN case EAI_AGAIN: return GetAddrInfoErrorFlags_EAI_AGAIN; +#endif +#ifdef EAI_BADFLAGS case EAI_BADFLAGS: return GetAddrInfoErrorFlags_EAI_BADFLAGS; +#endif #ifdef EAI_FAIL case EAI_FAIL: return GetAddrInfoErrorFlags_EAI_FAIL; #endif +#ifdef EAI_FAMILY case EAI_FAMILY: return GetAddrInfoErrorFlags_EAI_FAMILY; +#endif +#ifdef EAI_MEMORY case EAI_MEMORY: return GetAddrInfoErrorFlags_EAI_MEMORY; +#endif +#ifdef EAI_NONAME case EAI_NONAME: +#endif #ifdef EAI_NODATA case EAI_NODATA: #endif @@ -3266,3 +3284,317 @@ uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) interfaceName++; return if_nametoindex(interfaceName); } +#else /* TARGET_WASI */ + +int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t addressFamily, HostEntry* entry) +{ + return Error_EFAULT; +} + +void SystemNative_FreeHostEntry(HostEntry* entry) +{ + if (entry != NULL) + { + free(entry->CanonicalName); + free(entry->IPAddressList); + + entry->CanonicalName = NULL; + entry->IPAddressList = NULL; + entry->IPAddressCount = 0; + } +} + +int32_t SystemNative_GetNameInfo(const uint8_t* address, + int32_t addressLength, + int8_t isIPv6, + uint8_t* host, + int32_t hostLength, + uint8_t* service, + int32_t serviceLength, + int32_t flags) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetDomainName(uint8_t* name, int32_t nameLength) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetHostName(uint8_t* name, int32_t nameLength) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetIPSocketAddressSizes(int32_t* ipv4SocketAddressSize, int32_t* ipv6SocketAddressSize) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetAddressFamily(const uint8_t* socketAddress, int32_t socketAddressLen, int32_t* addressFamily) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetAddressFamily(uint8_t* socketAddress, int32_t socketAddressLen, int32_t addressFamily) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetPort(const uint8_t* socketAddress, int32_t socketAddressLen, uint16_t* port) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetPort(uint8_t* socketAddress, int32_t socketAddressLen, uint16_t port) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetIPv4Address(const uint8_t* socketAddress, int32_t socketAddressLen, uint32_t* address) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetIPv4Address(uint8_t* socketAddress, int32_t socketAddressLen, uint32_t address) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetIPv6Address( + const uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t* scopeId) +{ + return Error_EFAULT; +} + +int32_t +SystemNative_SetIPv6Address(uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t scopeId) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetControlMessageBufferSize(int32_t isIPv4, int32_t isIPv6) +{ + return Error_EFAULT; +} + +int32_t +SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isIPv4, IPPacketInformation* packetInfo) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetReceiveTimeout(intptr_t socket, int32_t millisecondsTimeout) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetSendTimeout(intptr_t socket, int32_t millisecondsTimeout) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Receive(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* received) +{ + return Error_EFAULT; +} + +int32_t SystemNative_ReceiveMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* received) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* sent) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* sent) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Accept(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen, intptr_t* acceptedSocket) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Bind(intptr_t socket, int32_t protocolType, uint8_t* socketAddress, int32_t socketAddressLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Connect(intptr_t socket, uint8_t* socketAddress, int32_t socketAddressLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Listen(intptr_t socket, int32_t backlog) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Shutdown(intptr_t socket, int32_t socketShutdown) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetSocketErrorOption(intptr_t socket, int32_t* error) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetSockOpt( + intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetRawSockOpt( + intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) +{ + return Error_EFAULT; +} + +int32_t +SystemNative_SetSockOpt(intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_SetRawSockOpt( + intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) +{ + return Error_EFAULT; +} + +int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t protocolType, intptr_t* createdSocket) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int32_t* socketType, int32_t* protocolType, int32_t* isListening) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetAtOutOfBandMark(intptr_t socket, int32_t* atMark) +{ + return Error_EFAULT; +} + +int32_t SystemNative_GetBytesAvailable(intptr_t socket, int32_t* available) +{ + return Error_EFAULT; +} + +int32_t SystemNative_CreateSocketEventPort(intptr_t* port) +{ + return Error_EFAULT; +} + +int32_t SystemNative_CloseSocketEventPort(intptr_t port) +{ + return Error_EFAULT; +} + +int32_t SystemNative_CreateSocketEventBuffer(int32_t count, SocketEvent** buffer) +{ + return Error_EFAULT; +} + +int32_t SystemNative_FreeSocketEventBuffer(SocketEvent* buffer) +{ + free(buffer); + return Error_SUCCESS; +} + +int32_t +SystemNative_TryChangeSocketEventRegistration(intptr_t port, intptr_t socket, int32_t currentEvents, int32_t newEvents, uintptr_t data) +{ + return Error_EFAULT; +} + +int32_t SystemNative_WaitForSocketEvents(intptr_t port, SocketEvent* buffer, int32_t* count) +{ + return Error_EFAULT; +} + +int32_t SystemNative_PlatformSupportsDualModeIPv4PacketInfo(void) +{ + return 0; +} + +char* SystemNative_GetPeerUserName(intptr_t socket) +{ + return NULL; +} + +void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, int32_t* addressSize) +{ + *pathOffset = 0; + *pathSize = 0; + *addressSize = 0; +} + +int32_t SystemNative_GetMaximumAddressSize(void) +{ + return -1; +} + +int32_t SystemNative_Disconnect(intptr_t socket) +{ + return -1; +} + +int32_t SystemNative_SendFile(intptr_t out_fd, intptr_t in_fd, int64_t offset, int64_t count, int64_t* sent) +{ + return -1; +} + +uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) +{ + return 0xFFFFFFFF; +} + +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_networkstatistics.c b/src/native/libs/System.Native/pal_networkstatistics.c index 987a0a80d8159..eeeb8ac802942 100644 --- a/src/native/libs/System.Native/pal_networkstatistics.c +++ b/src/native/libs/System.Native/pal_networkstatistics.c @@ -32,7 +32,9 @@ #else #include #endif +#if HAVE_NET_IF_H #include +#endif #include #include diff --git a/src/native/libs/System.Native/pal_process.c b/src/native/libs/System.Native/pal_process.c index 509049b2fdcd7..324b54bb92cd5 100644 --- a/src/native/libs/System.Native/pal_process.c +++ b/src/native/libs/System.Native/pal_process.c @@ -8,14 +8,20 @@ #include #include +#if HAVE_GETGROUPLIST #include +#endif #include #include #include #include #include +#if HAVE_SYS_WAIT_H #include +#endif +#if HAVE_SYSLOG_H #include +#endif #include #if HAVE_CRT_EXTERNS_H #include @@ -23,7 +29,9 @@ #if HAVE_PIPE2 #include #endif +#if HAVE_PTHREAD_H #include +#endif #if HAVE_SCHED_SETAFFINITY || HAVE_SCHED_GETAFFINITY #include @@ -41,6 +49,7 @@ #include +#if !defined(TARGET_WASI) // Validate that our SysLogPriority values are correct for the platform c_static_assert(PAL_LOG_EMERG == LOG_EMERG); c_static_assert(PAL_LOG_ALERT == LOG_ALERT); @@ -519,10 +528,14 @@ static int32_t ConvertRLimitResourcesPalToPlatform(RLimitResources value) { case PAL_RLIMIT_CPU: return RLIMIT_CPU; +#ifdef RLIMIT_FSIZE case PAL_RLIMIT_FSIZE: return RLIMIT_FSIZE; +#endif +#ifdef RLIMIT_DATA case PAL_RLIMIT_DATA: return RLIMIT_DATA; +#endif case PAL_RLIMIT_STACK: return RLIMIT_STACK; case PAL_RLIMIT_CORE: @@ -878,3 +891,107 @@ char* SystemNative_GetProcessPath(void) { return minipal_getexepath(); } + +#else /* TARGET_WASI */ + + +int32_t SystemNative_ForkAndExecProcess(const char* filename, + char* const argv[], + char* const envp[], + const char* cwd, + int32_t redirectStdin, + int32_t redirectStdout, + int32_t redirectStderr, + int32_t setCredentials, + uint32_t userId, + uint32_t groupId, + uint32_t* groups, + int32_t groupsLength, + int32_t* childPid, + int32_t* stdinFd, + int32_t* stdoutFd, + int32_t* stderrFd) +{ + return -1; +} + +int32_t SystemNative_GetRLimit(RLimitResources resourceType, RLimit* limits) +{ + return -1; +} + +int32_t SystemNative_SetRLimit(RLimitResources resourceType, const RLimit* limits) +{ + return -1; +} + +int32_t SystemNative_Kill(int32_t pid, int32_t signal) +{ + return -1; +} + +int32_t SystemNative_GetPid(void) +{ + return -1; +} + +int32_t SystemNative_GetSid(int32_t pid) +{ + return -1; +} + +void SystemNative_SysLog(SysLogPriority priority, const char* message, const char* arg1) +{ +} + +int32_t SystemNative_WaitIdAnyExitedNoHangNoWait(void) +{ + return -1; +} + +int32_t SystemNative_WaitPidExitedNoHang(int32_t pid, int32_t* exitCode) +{ + return -1; +} + +int64_t SystemNative_PathConf(const char* path, PathConfName name) +{ + return -1; +} + +int32_t SystemNative_GetPriority(PriorityWhich which, int32_t who) +{ + return -1; +} + +int32_t SystemNative_SetPriority(PriorityWhich which, int32_t who, int32_t nice) +{ + return -1; +} + +char* SystemNative_GetCwd(char* buffer, int32_t bufferSize) +{ + return NULL; +} + +int32_t SystemNative_SchedSetAffinity(int32_t pid, intptr_t* mask) +{ + (void)pid; + (void)mask; + errno = ENOTSUP; + return -1; +} + +int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask) +{ + (void)pid; + (void)mask; + errno = ENOTSUP; + return -1; +} + +char* SystemNative_GetProcessPath(void) +{ + return NULL; +} +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_signal.c b/src/native/libs/System.Native/pal_signal.c index 257969dc67a94..ec641e6cbf0c9 100644 --- a/src/native/libs/System.Native/pal_signal.c +++ b/src/native/libs/System.Native/pal_signal.c @@ -9,13 +9,19 @@ #include #include +#if HAVE_PTHREAD_H #include +#endif #include #include #include +#if HAVE_SYS_WAIT_H #include +#endif #include +#if !defined(TARGET_WASI) + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; // Saved signal handlers @@ -718,3 +724,41 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) } #endif + +#else /* TARGET_WASI */ + +int32_t SystemNative_GetPlatformSignalNumber(PosixSignal signal) +{ + return 0; +} + +void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler) +{ +} + +void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode) +{ +} + +void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback) +{ +} + +void SystemNative_RegisterForSigChld(SigChldCallback callback) +{ +} + +void SystemNative_SetDelayedSigChildConsoleConfigurationHandler(void (*callback)(void)) +{ +} + +int32_t SystemNative_EnablePosixSignalHandling(int signalCode) +{ + return 0; +} + +void SystemNative_DisablePosixSignalHandling(int signalCode) +{ +} + +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index b524327ef820b..3414d0061ddc3 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -20,11 +20,14 @@ // So we can use the declaration of pthread_cond_timedwait_relative_np #undef _XOPEN_SOURCE #endif +#if HAVE_PTHREAD_H #include +#endif #if defined(TARGET_OSX) #define _XOPEN_SOURCE #endif +#if !defined(TARGET_WASI) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LowLevelMonitor - Represents a non-recursive mutex and condition @@ -285,3 +288,74 @@ void SystemNative_Abort(void) { abort(); } + +#else /* TARGET_WASI */ +struct LowLevelMonitor +{ + bool IsLocked; + // TODOWASI +}; + +LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void) +{ + // TODOWASI + return NULL; +} + +void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor) +{ + // TODOWASI +} + +void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor) +{ + // TODOWASI +} + +void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor) +{ + // TODOWASI +} + +void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor) +{ + // TODOWASI +} + +int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monitor, int32_t timeoutMilliseconds) +{ + // TODOWASI + return false; +} + +void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor) +{ + // TODOWASI +} + +int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter) +{ + // TODOWASI + return false; +} + +int32_t SystemNative_SchedGetCpu(void) +{ + // TODOWASI + return -1; +} + +__attribute__((noreturn)) +void SystemNative_Exit(int32_t exitCode) +{ + assert(false); + // TODOWASI +} + +__attribute__((noreturn)) +void SystemNative_Abort(void) +{ + assert(false); + // TODOWASI +} +#endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_uid.c b/src/native/libs/System.Native/pal_uid.c index 0f94484cafec4..5a004e6e7bafb 100644 --- a/src/native/libs/System.Native/pal_uid.c +++ b/src/native/libs/System.Native/pal_uid.c @@ -11,8 +11,12 @@ #include #include #include +#if HAVE_GETGROUPLIST #include +#endif +#if HAVE_PWD_H #include +#endif // Linux c-libraries (glibc, musl) provide a thread-safe getgrouplist. // OSX man page mentions explicitly the implementation is not thread safe, @@ -22,8 +26,12 @@ #endif #if defined(USE_GROUPLIST_LOCK) || !HAVE_GETGRGID_R +#if HAVE_PTHREAD_H #include #endif +#endif + +#if !defined(TARGET_WASI) static int32_t ConvertNativePasswdToPalPasswd(int error, struct passwd* nativePwd, struct passwd* result, Passwd* pwd) { @@ -302,3 +310,45 @@ char* SystemNative_GetGroupName(uint32_t gid) return name; #endif } + +#else /* TARGET_WASI */ +int32_t SystemNative_GetPwUidR(uint32_t uid, Passwd* pwd, char* buf, int32_t buflen) +{ + return -1; +} + +int32_t SystemNative_GetPwNamR(const char* name, Passwd* pwd, char* buf, int32_t buflen) +{ + return -1; +} + +uint32_t SystemNative_GetEUid(void) +{ + return 0xFFFFFFFF; +} + +uint32_t SystemNative_GetEGid(void) +{ + return 0xFFFFFFFF; +} + +int32_t SystemNative_SetEUid(uint32_t euid) +{ + return -1; +} + +int32_t SystemNative_GetGroupList(const char* name, uint32_t group, uint32_t* groups, int32_t* ngroups) +{ + return -1; +} + +int32_t SystemNative_GetGroups(int32_t ngroups, uint32_t* groups) +{ + return -1; +} + +char* SystemNative_GetGroupName(uint32_t gid) +{ + return NULL; +} +#endif /* TARGET_WASI */ diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 237c8b16f1978..088aee3396016 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -875,6 +875,38 @@ check_symbol_exists( "unistd.h;grp.h" HAVE_GETGROUPLIST) +check_include_files( + "syslog.h" + HAVE_SYSLOG_H) + +check_include_files( + "pwd.h" + HAVE_PWD_H) + +check_include_files( + "termios.h" + HAVE_TERMIOS_H) + +check_include_files( + "dlfcn.h" + HAVE_DLFCN_H) + +check_include_files( + "sys/wait.h" + HAVE_SYS_WAIT_H) + +check_include_files( + "sys/statvfs.h" + HAVE_SYS_STATVFS_H) + +check_include_files( + "net/if.h" + HAVE_NET_IF_H) + +check_include_files( + "pthread.h" + HAVE_PTHREAD_H) + if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(HAVE_IOS_NET_ROUTE_H 1) set(HAVE_IOS_NET_IFMEDIA_H 1) From f6153183116a1657e888b7c9b7f6798df04cc96a Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 10 Nov 2022 19:58:04 +0100 Subject: [PATCH 026/116] wip --- src/native/libs/System.Native/pal_mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Native/pal_mount.c b/src/native/libs/System.Native/pal_mount.c index 5458cbac49531..c17014256ced4 100644 --- a/src/native/libs/System.Native/pal_mount.c +++ b/src/native/libs/System.Native/pal_mount.c @@ -180,7 +180,7 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer return result; } -else /* TARGET_WASI */ +#else /* TARGET_WASI */ int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) { // TODOWASI From dd570880289c0147c039d7ed87b1d586efa25251 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 10 Nov 2022 19:59:14 +0100 Subject: [PATCH 027/116] wip --- src/native/libs/build-native.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 62387cd15d685..528a3ac3a0e7f 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -52,8 +52,6 @@ if [[ "$__TargetOS" == Browser ]]; then fi fi source "$EMSDK_PATH"/emsdk_env.sh - - echo !!!!!!!!!!!!!!!!! browser-wasm !!!!!!!!!!!!!!!!! export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == Wasi ]]; then if [[ -z "$WASI_SDK_PATH" ]]; then From 98f1822990685b27d038408c394873c3a187908a Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 10 Nov 2022 20:25:54 +0100 Subject: [PATCH 028/116] wip --- src/mono/cmake/config.h.in | 3 +++ src/native/libs/Common/pal_config.h.in | 1 + src/native/libs/System.Native/pal_process.c | 2 +- src/native/libs/System.Native/pal_uid.c | 2 +- src/native/libs/configure.cmake | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 71753f1d47e09..5215c855a6ec0 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -171,6 +171,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_PWD_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GRP_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SELECT_H 1 diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in index 0aee13fe82482..6b5b83d4a191a 100644 --- a/src/native/libs/Common/pal_config.h.in +++ b/src/native/libs/Common/pal_config.h.in @@ -128,6 +128,7 @@ #cmakedefine01 HAVE_GETGROUPLIST #cmakedefine01 HAVE_SYSLOG_H #cmakedefine01 HAVE_PWD_H +#cmakedefine01 HAVE_GRP_H #cmakedefine01 HAVE_TERMIOS_H #cmakedefine01 HAVE_DLFCN_H #cmakedefine01 HAVE_PTHREAD_H diff --git a/src/native/libs/System.Native/pal_process.c b/src/native/libs/System.Native/pal_process.c index 324b54bb92cd5..c5e512239c36a 100644 --- a/src/native/libs/System.Native/pal_process.c +++ b/src/native/libs/System.Native/pal_process.c @@ -8,7 +8,7 @@ #include #include -#if HAVE_GETGROUPLIST +#if HAVE_GRP_H #include #endif #include diff --git a/src/native/libs/System.Native/pal_uid.c b/src/native/libs/System.Native/pal_uid.c index 5a004e6e7bafb..2bad383d6f889 100644 --- a/src/native/libs/System.Native/pal_uid.c +++ b/src/native/libs/System.Native/pal_uid.c @@ -11,7 +11,7 @@ #include #include #include -#if HAVE_GETGROUPLIST +#if HAVE_GRP_H #include #endif #if HAVE_PWD_H diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 088aee3396016..3c29b5ad723c6 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -875,6 +875,10 @@ check_symbol_exists( "unistd.h;grp.h" HAVE_GETGROUPLIST) +check_include_files( + "grp.h" + HAVE_GRP_H) + check_include_files( "syslog.h" HAVE_SYSLOG_H) From 69643bf2cecd01c3a64e0b52bca3fbd3b677b79d Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 15:05:56 +0100 Subject: [PATCH 029/116] wip --- eng/pipelines/common/platform-matrix.yml | 27 ++++++++++++++++--- .../common/templates/wasm-library-tests.yml | 15 ----------- eng/testing/tests.wasm.targets | 12 ++++----- .../src/System.Text.Encodings.Web.csproj | 4 ++- src/mono/CMakeLists.txt | 1 + src/mono/cmake/configure.cmake | 2 +- src/mono/mono.proj | 4 ++- src/mono/mono/mini/CMakeLists.txt | 20 +++++++------- src/mono/mono/utils/CMakeLists.txt | 7 +++-- src/mono/mono/utils/mono-codeman.c | 2 ++ src/mono/wasi/runtime/CMakeLists.txt | 4 +-- src/mono/wasi/runtime/driver.c | 23 ++++++++++++++++ src/mono/wasi/wasi.proj | 9 +++++-- .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 2 +- src/mono/wasm/build/WasmApp.targets | 10 +++---- .../Wasm.Debugger.Tests.csproj | 2 +- .../wasm/debugger/tests/Directory.Build.props | 2 +- .../wasm-test-runner/WasmTestRunner.proj | 2 +- 18 files changed, 94 insertions(+), 54 deletions(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index b3076886cdf57..cccc6c42fa73b 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -374,7 +374,28 @@ jobs: crossBuild: true ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly +# Wasi WebAssembly + +- ${{ if containsValue(parameters.platforms, 'Wasi_wasm') }}: + - template: xplat-setup.yml + parameters: + jobTemplate: ${{ parameters.jobTemplate }} + helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} + variables: ${{ parameters.variables }} + osGroup: Wasi + archType: wasm + targetRid: wasi-wasm + platform: Wasi_wasm + shouldContinueOnError: ${{ parameters.shouldContinueOnError }} + container: Linux_64 + jobParameters: + hostedOs: Linux + runtimeFlavor: ${{ parameters.runtimeFlavor }} + stagedBuild: ${{ parameters.stagedBuild }} + buildConfig: ${{ parameters.buildConfig }} + ${{ insert }}: ${{ parameters.jobParameters }} + +# Browser WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: - template: xplat-setup.yml @@ -395,7 +416,7 @@ jobs: buildConfig: ${{ parameters.buildConfig }} ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly Linux Firefox +# Browser WebAssembly Linux Firefox - ${{ if containsValue(parameters.platforms, 'Browser_wasm_firefox') }}: - template: xplat-setup.yml @@ -416,7 +437,7 @@ jobs: buildConfig: ${{ parameters.buildConfig }} ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly on Windows +# Browser WebAssembly on Windows - ${{ if containsValue(parameters.platforms, 'Browser_wasm_win') }}: - template: xplat-setup.yml diff --git a/eng/pipelines/common/templates/wasm-library-tests.yml b/eng/pipelines/common/templates/wasm-library-tests.yml index 6037b4529ecaa..a05ca0bf16681 100644 --- a/eng/pipelines/common/templates/wasm-library-tests.yml +++ b/eng/pipelines/common/templates/wasm-library-tests.yml @@ -70,18 +70,3 @@ jobs: or( eq(variables['alwaysRunVar'], true), eq(variables['isDefaultPipeline'], variables['shouldRunOnDefaultPipelines'])) - # extra steps, run tests - extraStepsTemplate: /eng/pipelines/common/templates/additional-steps-then-helix.yml - extraStepsParameters: - additionalSteps: - - ${{ if eq(parameters.buildAndRunWasi, true) }}: - - script: >- - make -C src/mono/wasi provision-deps all && - make -C src/mono/wasi/sample/console run - name: build_wasi - displayName: Build Wasi, and run a sample - - creator: dotnet-bot - testRunNamePrefixSuffix: Mono_$(_BuildConfig) - extraHelixArguments: /p:BrowserHost=$(_hostedOs) $(_wasmRunSmokeTestsOnlyArg) ${{ parameters.extraHelixArgs }} - scenarios: ${{ parameters.scenarios }} diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index d1a4c93d0418a..8fb430740b4da 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -1,7 +1,7 @@ - true + true true false $(BundleTestAppTargets);BundleTestWasmApp @@ -40,7 +40,7 @@ + Condition="'$(InstallChromeForTests)' == 'true' and ('$(ContinuousIntegrationBuild)' != 'true' or '$(IsBrowserProject)' != 'true')" /> @@ -138,9 +138,9 @@ Condition="'$(BuildAOTTestsOn)' == 'local'" /> - - WasmTriggerPublishApp - $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix + + WasmTriggerPublishApp + $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix $(WasmAppHostDir)/WasmAppHost - + true diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 510c94c79adaf..b376e90cbbcff 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -4,7 +4,7 @@ true - $(NoWarn);CS3011;CS3019 + $(NoWarn);CS3011;CS3019;CA1418 true Provides types for encoding and escaping strings for use in JavaScript, HyperText Markup Language (HTML), and uniform resource locators (URL). @@ -19,6 +19,8 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER $(DefineConstants);TARGET_WASI + + $(NoWarn);CA1418 diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index bbe2b5e1e0966..af47a1a356688 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -332,6 +332,7 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") endif() elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") set(TARGET_WASI 1) + set(DISABLE_THREADS 1) if (CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-Os) endif() diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index e0952bd5abccd..573f83256a947 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -23,7 +23,7 @@ if(HOST_SOLARIS) endif() if(HOST_WASI) - set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -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") endif() function(ac_check_headers) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index b0aed859e4328..c5baa060131b0 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -379,7 +379,7 @@ <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> - <_MonoCMakeArgs Include="-DENABLE_LLVM_RUNTIME=1"/> + <_MonoCMakeArgs Condition="'$(TargetsWasi)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> <_MonoCMakeArgs Include="-DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm"/> <_MonoCFLAGS Include="-fexceptions"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> @@ -397,6 +397,8 @@ <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'cmake', 'wasi-sdk.cmake'))$(EscapedQuoteW)" /> <_MonoCMakeArgs Include="$(EscapedQuoteW)-DCMAKE_SYSROOT=$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share', 'wasi-sysroot'))$(EscapedQuoteW)" /> <_MonoBuildEnv Include="TARGET_BUILD_ARCH=wasm" /> + sockets,eventpipe + Ninja ? --> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index ed445a1943045..12fa17ef8387c 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -454,16 +454,16 @@ if(NOT DISABLE_SHARED_LIBS) endif() endif() -if(HOST_WASM AND NOT HOST_WASI) -# Add two static libs containing llvm-runtime.cpp compiled for JS based/WASM EH -# This is the only source file which contains a c++ throw or catch -add_library(mono-wasm-eh-js STATIC llvm-runtime.cpp) -target_link_libraries (mono-wasm-eh-js PRIVATE monoapi) -install(TARGETS mono-wasm-eh-js LIBRARY) -add_library(mono-wasm-eh-wasm STATIC llvm-runtime.cpp) -target_link_libraries (mono-wasm-eh-wasm PRIVATE monoapi) -set_target_properties(mono-wasm-eh-wasm PROPERTIES COMPILE_FLAGS "-fwasm-exceptions") -install(TARGETS mono-wasm-eh-wasm LIBRARY) +if(HOST_BROWSER) + # Add two static libs containing llvm-runtime.cpp compiled for JS based/WASM EH + # This is the only source file which contains a c++ throw or catch + add_library(mono-wasm-eh-js STATIC llvm-runtime.cpp) + target_link_libraries (mono-wasm-eh-js PRIVATE monoapi) + install(TARGETS mono-wasm-eh-js LIBRARY) + add_library(mono-wasm-eh-wasm STATIC llvm-runtime.cpp) + target_link_libraries (mono-wasm-eh-wasm PRIVATE monoapi) + set_target_properties(mono-wasm-eh-wasm PROPERTIES COMPILE_FLAGS "-fwasm-exceptions") + install(TARGETS mono-wasm-eh-wasm LIBRARY) endif() find_package(Python3 COMPONENTS Interpreter) diff --git a/src/mono/mono/utils/CMakeLists.txt b/src/mono/mono/utils/CMakeLists.txt index 30c10c7ff986d..191ee54cc332f 100644 --- a/src/mono/mono/utils/CMakeLists.txt +++ b/src/mono/mono/utils/CMakeLists.txt @@ -23,6 +23,8 @@ set(utils_unix_sources if(HOST_WIN32) set(utils_platform_sources ${utils_win32_sources}) +elseif(HOST_WASI) + set(utils_platform_sources os-event-unix.c) else() set(utils_platform_sources ${utils_unix_sources}) endif() @@ -217,11 +219,8 @@ elseif(TARGET_RISCV64) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-riscv.c") elseif(TARGET_S390X) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-s390x.c") -elseif(TARGET_BROWSER) +elseif(TARGET_BROWSER OR TARGET_WASI) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-wasm.c;mono-mmap-wasm.c") -elseif(TARGET_WASI) -#TODOWASI -set(utils_arch_sources "${utils_arch_sources}") elseif(TARGET_POWERPC OR TARGET_POWERPC64) set(utils_arch_sources "${utils_arch_sources};mono-hwcap-ppc.c") else() diff --git a/src/mono/mono/utils/mono-codeman.c b/src/mono/mono/utils/mono-codeman.c index 6e6f36c32d7e0..19597dde494b1 100644 --- a/src/mono/mono/utils/mono-codeman.c +++ b/src/mono/mono/utils/mono-codeman.c @@ -362,6 +362,8 @@ mono_codeman_free (gpointer p) void* const heap = mono_code_manager_heap; g_assert (heap); HeapFree (heap, 0, p); +#elif HOST_WASI + //TODOWASI #else mono_codeman_enable_write (); dlfree (p); diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 53c289c42d0fd..7edab4e22fe0e 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -23,8 +23,8 @@ target_link_libraries(dotnet ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a ${MONO_ARTIFACTS_DIR}/libmono-ilgen.a ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a -#TODOWASI ${NATIVE_BIN_DIR}/libSystem.Native.a -#TODOWASI ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a + ${NATIVE_BIN_DIR}/libSystem.Native.a + ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a ) set_target_properties(dotnet PROPERTIES diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index b7691ab4da50f..a43df080c410a 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -799,3 +799,26 @@ MonoMethod* lookup_dotnet_method(const char* assembly_name, const char* namespac assert (method); return method; } + +int main() { + printf("mono_wasm_load_runtime\n"); + mono_wasm_load_runtime("", 0); + /* + // Assume the runtime pack has been copied into the output directory as 'runtime' + // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment + const char* app_base_dir = "./WasiConsoleApp/bin/Debug/net7.0"; + char* assemblies_path; + asprintf(&assemblies_path, "%s:%s/runtime/native:%s/runtime/lib/net7.0", app_base_dir, app_base_dir, app_base_dir); + + add_assembly(app_base_dir, "WasiConsoleApp.dll"); + mono_set_assemblies_path(assemblies_path); + mono_wasm_load_runtime("", 0); + + MonoAssembly* assembly = mono_wasm_assembly_load ("WasiConsoleApp.dll"); + MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); + MonoObject* out_exc; + MonoObject *exit_code = mono_wasm_invoke_method (entry_method, NULL, NULL, &out_exc); + return mono_unbox_int (exit_code); + */ + return 0; +} diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index f51d66977e04a..bae726e6e0508 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -76,9 +76,11 @@ - + - <_WasiLinkFlags Include="-Wl,--allow-undefined"/> + @@ -98,6 +100,9 @@ <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> + <_WasiLinkFlags Include="-lwasi-emulated-process-clocks"/> + <_WasiLinkFlags Include="-lwasi-emulated-signal"/> + <_WasiLinkFlags Include="-lwasi-emulated-mman"/> diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index a213bd210a98a..e47be6431fba8 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -16,7 +16,7 @@ true - false + false true diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index b4ab2787d2173..e09aff8990502 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -97,7 +97,7 @@ <_BeforeWasmBuildAppDependsOn /> - true + true Build Publish @@ -121,8 +121,8 @@ - - + + @@ -158,7 +158,7 @@ + Condition="'$(IsBrowserProject)' == 'true' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'"> + Condition="'$(IsBrowserProject)' == 'true' and '$(WasmBuildingForNestedPublish)' == '' and '$(WasmBuildOnlyAfterPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'" /> false false false - false + false true true xunit diff --git a/src/mono/wasm/debugger/tests/Directory.Build.props b/src/mono/wasm/debugger/tests/Directory.Build.props index b0249e49bbbf8..cd1f27e2818c0 100644 --- a/src/mono/wasm/debugger/tests/Directory.Build.props +++ b/src/mono/wasm/debugger/tests/Directory.Build.props @@ -4,7 +4,7 @@ $(AspNetCoreAppCurrent) Library - true + true Debug true diff --git a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj index c653f98c47bff..b646a764139bd 100644 --- a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj +++ b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj @@ -12,7 +12,7 @@ $(MSBuildThisFileDirectory)\obj\$(Configuration)\wasm $(TestBinDir)/WasmApp/ 99.0 - true + true true $(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll From c6d99945d65e55a293cb1345622ff66569ba1af0 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 15:42:25 +0100 Subject: [PATCH 030/116] wip --- src/mono/mono.proj | 24 +++++++++++++++++---- src/mono/wasi/README.md | 47 ++--------------------------------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index c5baa060131b0..07a75e0a4de63 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -169,19 +169,20 @@ - + $(ProvisionWasiSdkDir) $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) - wasi-sdk %(_VersionLines.Identity) + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz - @@ -190,6 +191,21 @@ + + + + + + + + + %(_ActualVersionLines.Identity) + %(_ExpectedVersionLines.Identity) + + + + @@ -854,7 +870,7 @@ CheckEnv;GetXcodeDir;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross GenerateRuntimeVersionFile;ProvisionEmscripten;$(MonoDependsOnTargets) - GenerateRuntimeVersionFile;ProvisionWasiSdk;$(MonoDependsOnTargets) + GenerateRuntimeVersionFile;ProvisionWasiSdk;ValidateWasiSdk;$(MonoDependsOnTargets) diff --git a/src/mono/wasi/README.md b/src/mono/wasi/README.md index a44f8d5db9323..b44a2d443d3a3 100644 --- a/src/mono/wasi/README.md +++ b/src/mono/wasi/README.md @@ -8,51 +8,8 @@ The mechanism for executing .NET code in a WASI runtime environment is equivalen ## How to build the runtime -### 1. Build the WASM runtime - -To build the wasi runtime we need the file `wasm_m2n_invoke.g.h` which is generated when compiling wasm runtime - -``` -make -C src/mono/wasm provision-wasm -export EMSDK_PATH=[path_printed_by_provision_wasm] -./build.sh mono+libs -os browser -``` - -### 2. Build the WASI runtime - -Currently this can only be built in Linux or WSL (tested on Windows 11). Simply run `make` in this directory. It will automatically download and use [WASI SDK](https://github.com/WebAssembly/wasi-sdk). - -The resulting libraries are placed in `(repo_root)/artifacts/bin/mono/Wasi.Release`. - -## How to build and run the sample - -### 1. Obtain a WASI runtime - -To run an application in a WASI environment, you need to have a WASI runtime available. For example, download [wasmtime](https://github.com/bytecodealliance/wasmtime/releases) and make sure it's available on `PATH`: - -``` -export PATH=~/wasmtime-v0.31.0-x86_64-linux -wasmtime --version -``` - -Other WASI runtimes also work. Tested: [wamr](https://github.com/bytecodealliance/wasm-micro-runtime), [wasmer](https://wasmer.io/). - -### 2. Obtain a suitable .NET build toolchain - -You also need to have a working installation of .NET 7 including the `browser-wasm` runtime pack. For example, obtain the [.NET SDK daily build](https://github.com/dotnet/installer/blob/main/README.md#installers-and-binaries) (`main` branch), and ensure the `browser-wasm` pack is installed: - -``` -dotnet workload install wasm-tools -s https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json -``` - -To make this available to the build scripts, supply environment variables. Example: - -``` -export DOTNET_ROOT=~/dotnet7 -export BROWSER_WASM_RUNTIME_PATH=$(DOTNET_ROOT)/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/7.0.0-alpha.1.22061.11/runtimes/browser-wasm -``` - -You'll need to update these paths to match the location where you extracted the .NET daily SDK build and the exact version of the `browser-wasm` pack you received. +on Linux: +`./build.sh -bl -os Wasi -subset mono+libs+host+packs -c Debug` ### 3. Run it From ac0d4e4929cbaa4cd74d387ed964be7596ebbb9e Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 15:57:32 +0100 Subject: [PATCH 031/116] wip --- eng/pipelines/runtime-linker-tests.yml | 24 ++++++++++++++++++++++++ eng/pipelines/runtime-official.yml | 1 + 2 files changed, 25 insertions(+) diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 8432999807c57..2ec7c74f1b396 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -104,3 +104,27 @@ extends: extraStepsTemplate: /eng/pipelines/libraries/execute-trimming-tests-steps.yml extraStepsParameters: extraTestArgs: '/p:WasmBuildNative=false' + + # + # Build Release config vertical for Wasi-wasm + # + - template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + buildConfig: release + platforms: + - Wasi_wasm + jobParameters: + testGroup: innerloop + timeoutInMinutes: 120 + nameSuffix: Runtime_Release + buildArgs: -s mono+libs -c $(_BuildConfig) -p:WasmBuildNative=false + condition: + or( + eq(variables['isRollingBuild'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_wasm_libraries.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_wasm.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['DarcDependenciesChanged.Microsoft_NET_ILLink_Tasks'], true)) + extraStepsTemplate: /eng/pipelines/libraries/execute-trimming-tests-steps.yml + extraStepsParameters: + extraTestArgs: '/p:WasmBuildNative=false' diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index c736da33bc164..e52dd99a5ca23 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -127,6 +127,7 @@ extends: - Linux_arm64 - Linux_musl_x64 - Browser_wasm + - Wasi_wasm - Linux_bionic_arm64 - Linux_bionic_x64 # - Linux_musl_arm From 9fb6f4703fa0cc89c3d871f208647e69cae113de Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 16:15:27 +0100 Subject: [PATCH 032/116] wip --- src/mono/CMakeLists.txt | 1 - src/mono/mono/mini/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index af47a1a356688..36e626f7a672e 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -251,7 +251,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") add_definitions(-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) add_definitions(-DNO_GLOBALIZATION_SHIM) add_definitions(-D_THREAD_SAFE) - # add_definitions(-DGEN_PINVOKE) TODOWASI add_definitions(-DDISABLE_SOCKET_TRANSPORT) add_definitions(-DDISABLE_EGD_SOCKET) add_definitions(-DDISABLE_EVENTPIPE) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 12fa17ef8387c..fbccfa2122803 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -325,7 +325,7 @@ else() set(llvm_runtime_sources) endif() -if(HOST_WASM AND MONO_CROSS_COMPILE) +if(HOST_BROWSER AND MONO_CROSS_COMPILE) set(profiler_sources ../profiler/browser.c) else() set(profiler_sources "") From ac080a19a3f560e765f4aae1610f9193079a5c91 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 19:41:09 +0100 Subject: [PATCH 033/116] sample --- src/mono/sample/wasi/CommonAssemblyInfo.cs | 4 ++ src/mono/sample/wasi/Directory.Build.props | 37 ++++++++++++ src/mono/sample/wasi/Directory.Build.targets | 60 +++++++++++++++++++ src/mono/sample/wasi/console/Program.cs | 18 ++++++ .../wasi/console/Wasi.Console.Sample.csproj | 12 ++++ src/mono/wasi/.gitignore | 1 + src/mono/wasi/README.md | 11 +++- src/mono/wasi/build/WasiApp.InTree.props | 2 + src/mono/wasi/build/WasiApp.InTree.targets | 2 + src/mono/wasi/runtime/driver.c | 18 ++---- src/mono/wasi/sample/.gitignore | 1 - src/mono/wasi/sample/Directory.Build.props | 8 --- src/mono/wasi/sample/SampleMakefile.variable | 20 ------- src/mono/wasi/sample/console/Makefile | 28 --------- .../sample/console/WasiConsoleApp/Program.cs | 16 ----- .../WasiConsoleApp/WasiConsoleApp.csproj | 10 ---- src/mono/wasi/sample/console/main.c | 21 ------- src/mono/wasi/wasi.proj | 2 + src/mono/wasi/wasmtime-version.txt | 1 + 19 files changed, 153 insertions(+), 119 deletions(-) create mode 100644 src/mono/sample/wasi/CommonAssemblyInfo.cs create mode 100644 src/mono/sample/wasi/Directory.Build.props create mode 100644 src/mono/sample/wasi/Directory.Build.targets create mode 100644 src/mono/sample/wasi/console/Program.cs create mode 100644 src/mono/sample/wasi/console/Wasi.Console.Sample.csproj create mode 100644 src/mono/wasi/build/WasiApp.InTree.props create mode 100644 src/mono/wasi/build/WasiApp.InTree.targets delete mode 100644 src/mono/wasi/sample/.gitignore delete mode 100644 src/mono/wasi/sample/Directory.Build.props delete mode 100644 src/mono/wasi/sample/SampleMakefile.variable delete mode 100644 src/mono/wasi/sample/console/Makefile delete mode 100644 src/mono/wasi/sample/console/WasiConsoleApp/Program.cs delete mode 100644 src/mono/wasi/sample/console/WasiConsoleApp/WasiConsoleApp.csproj delete mode 100644 src/mono/wasi/sample/console/main.c create mode 100644 src/mono/wasi/wasmtime-version.txt diff --git a/src/mono/sample/wasi/CommonAssemblyInfo.cs b/src/mono/sample/wasi/CommonAssemblyInfo.cs new file mode 100644 index 0000000000000..1e407edc80422 --- /dev/null +++ b/src/mono/sample/wasi/CommonAssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly:System.Runtime.Versioning.SupportedOSPlatform("wasi")] diff --git a/src/mono/sample/wasi/Directory.Build.props b/src/mono/sample/wasi/Directory.Build.props new file mode 100644 index 0000000000000..f2ecb0d30b5db --- /dev/null +++ b/src/mono/sample/wasi/Directory.Build.props @@ -0,0 +1,37 @@ + + + + Exe + wasi + + + + + + + bin + + + false + + + + + false + true + false + false + false + true + + + + + + + + + diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets new file mode 100644 index 0000000000000..92c9d2683527b --- /dev/null +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -0,0 +1,60 @@ + + + + + + true + + + + + + <_ScriptExt Condition="'$(OS)' == 'Windows_NT'">.cmd + <_ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh + <_Dotnet>$(RepoRoot)dotnet$(_ScriptExt) + <_AOTFlag Condition="'$(RunAOTCompilation)' != ''">/p:RunAOTCompilation=$(RunAOTCompilation) + <_WasmMainJSFileName>$([System.IO.Path]::GetFileName('$(WasmMainJSPath)')) + + + + + + + + + + + + + + + + + + %(_VersionLines.Identity) + https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-linux.tar.xz + + + + + + + + + + diff --git a/src/mono/sample/wasi/console/Program.cs b/src/mono/sample/wasi/console/Program.cs new file mode 100644 index 0000000000000..7d959dedae34d --- /dev/null +++ b/src/mono/sample/wasi/console/Program.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Threading.Tasks; + +public class Test +{ + public static async Task Main(string[] args) + { + await Task.Delay(1); + Console.WriteLine("Hello World!"); + for (int i = 0; i < args.Length; i++) { + Console.WriteLine($"args[{i}] = {args[i]}"); + } + return 0; + } +} diff --git a/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj new file mode 100644 index 0000000000000..2cbc92e85f134 --- /dev/null +++ b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj @@ -0,0 +1,12 @@ + + + $(NetCoreAppCurrent) + + + + <_SampleProject>Wasi.Console.Sample.csproj + <_SampleAssembly>Wasi.Console.Sample.dll + + + + diff --git a/src/mono/wasi/.gitignore b/src/mono/wasi/.gitignore index faf8da9dc8468..c2313f66ee085 100644 --- a/src/mono/wasi/.gitignore +++ b/src/mono/wasi/.gitignore @@ -1 +1,2 @@ wasi-sdk/** +wasmtime/** diff --git a/src/mono/wasi/README.md b/src/mono/wasi/README.md index b44a2d443d3a3..0a5a543d30665 100644 --- a/src/mono/wasi/README.md +++ b/src/mono/wasi/README.md @@ -9,15 +9,20 @@ The mechanism for executing .NET code in a WASI runtime environment is equivalen ## How to build the runtime on Linux: -`./build.sh -bl -os Wasi -subset mono+libs+host+packs -c Debug` +```.sh +./build.sh -bl -os Wasi -subset mono+libs -c Debug +``` +or for just native rebuild +```.sh +./build.sh -bl -os Wasi -subset mono.runtime+libs.native+mono.wasiruntime -c Debug +``` ### 3. Run it Finally, you can build and run the sample: ``` -cd sample/console -make run +./dotnet.sh build /p:TargetOS=Wasi /p:Configuration=Debug /t:RunSample src/mono/sample/wasi/console ``` ### 4. Debug it diff --git a/src/mono/wasi/build/WasiApp.InTree.props b/src/mono/wasi/build/WasiApp.InTree.props new file mode 100644 index 0000000000000..8c119d5413b58 --- /dev/null +++ b/src/mono/wasi/build/WasiApp.InTree.props @@ -0,0 +1,2 @@ + + diff --git a/src/mono/wasi/build/WasiApp.InTree.targets b/src/mono/wasi/build/WasiApp.InTree.targets new file mode 100644 index 0000000000000..8c119d5413b58 --- /dev/null +++ b/src/mono/wasi/build/WasiApp.InTree.targets @@ -0,0 +1,2 @@ + + diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index a43df080c410a..1c3951c24b634 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -801,24 +801,18 @@ MonoMethod* lookup_dotnet_method(const char* assembly_name, const char* namespac } int main() { - printf("mono_wasm_load_runtime\n"); - mono_wasm_load_runtime("", 0); - /* // Assume the runtime pack has been copied into the output directory as 'runtime' // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment - const char* app_base_dir = "./WasiConsoleApp/bin/Debug/net7.0"; - char* assemblies_path; - asprintf(&assemblies_path, "%s:%s/runtime/native:%s/runtime/lib/net7.0", app_base_dir, app_base_dir, app_base_dir); - - add_assembly(app_base_dir, "WasiConsoleApp.dll"); - mono_set_assemblies_path(assemblies_path); + printf("mono_set_assemblies_path\n"); + mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); + printf("mono_wasm_load_runtime\n"); mono_wasm_load_runtime("", 0); - MonoAssembly* assembly = mono_wasm_assembly_load ("WasiConsoleApp.dll"); + printf("mono_wasm_assembly_load\n"); + MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample.dll"); + printf("mono_wasm_assembly_get_entry_point\n"); MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); MonoObject* out_exc; MonoObject *exit_code = mono_wasm_invoke_method (entry_method, NULL, NULL, &out_exc); return mono_unbox_int (exit_code); - */ - return 0; } diff --git a/src/mono/wasi/sample/.gitignore b/src/mono/wasi/sample/.gitignore deleted file mode 100644 index 19e1bced9ad8a..0000000000000 --- a/src/mono/wasi/sample/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.wasm diff --git a/src/mono/wasi/sample/Directory.Build.props b/src/mono/wasi/sample/Directory.Build.props deleted file mode 100644 index 69b70ee868b5a..0000000000000 --- a/src/mono/wasi/sample/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - bin/$(Configuration)/net7.0 - - diff --git a/src/mono/wasi/sample/SampleMakefile.variable b/src/mono/wasi/sample/SampleMakefile.variable deleted file mode 100644 index 99f7e6916e9cd..0000000000000 --- a/src/mono/wasi/sample/SampleMakefile.variable +++ /dev/null @@ -1,20 +0,0 @@ -TOP=$(realpath $(CURDIR)/../../../../..) - -COMPILE_FLAGS=\ - $(WASI_BIN_DIR)/*.a \ - $(BROWSER_WASM_RUNTIME_PATH)/native/libSystem.Native.a \ - --sysroot=$(WASI_SDK_ROOT)/share/wasi-sysroot \ - -I$(TOP)/src/mono -I$(TOP)/src/native/public - -LINK_FLAGS=\ - -Wl,--export=malloc,--export=free,--export=__heap_base,--export=__data_end \ - -Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-mman - -ifndef DOTNET_ROOT -DOTNET_ROOT=$(TOP)/.dotnet -echo "DOTNET_ROOT is undefined. Example: export DOTNET_ROOT=~/dotnet7. Defaulting to $(DOTNET_ROOT) -endif -ifndef BROWSER_WASM_RUNTIME_PATH -BROWSER_WASM_RUNTIME_PATH=$(TOP)/artifacts/bin/microsoft.netcore.app.runtime.browser-wasm/$(CONFIG)/runtimes/browser-wasm -echo "BROWSER_WASM_RUNTIME_PATH is undefined. Example: export BROWSER_WASM_RUNTIME_PATH=$(DOTNET_ROOT)/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/7.0.0-alpha.1.22061.11/runtimes/browser-wasm). Defaulting to $(BROWSER_WASM_RUNTIME_PATH)" -endif diff --git a/src/mono/wasi/sample/console/Makefile b/src/mono/wasi/sample/console/Makefile deleted file mode 100644 index b4d731f9d3f37..0000000000000 --- a/src/mono/wasi/sample/console/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -include ../../Makefile.variable -include ../SampleMakefile.variable - -BIN_DIR=WasiConsoleApp/bin/Debug/net7.0 - -all: console.wasm $(BIN_DIR)/WasiConsoleApp.dll - -run: all - @(which wasmtime || PATH=$(WASMTIME_DIR):${PATH} which wasmtime); \ - test "$$?" -ne 0 \ - && echo "wasmtime not found. Either install that yourself, or use 'make provision-deps' to install one." \ - || PATH=$(WASMTIME_DIR):${PATH} wasmtime --dir=. console.wasm - -run-wasmer: all - wasmer --dir=. console.wasm - -console.wasm: main.c - $(WASI_SDK_CLANG) main.c -o console.wasm $(COMPILE_FLAGS) $(LINK_FLAGS) - -$(BIN_DIR)/WasiConsoleApp.dll: WasiConsoleApp/*.csproj WasiConsoleApp/*.cs - find $(BROWSER_WASM_RUNTIME_PATH) -type f - cd WasiConsoleApp && $(DOTNET_ROOT)/dotnet build -c Debug - touch $(BIN_DIR)/*.dll - cp -R $(BROWSER_WASM_RUNTIME_PATH) $(BIN_DIR)/runtime - -debug: all -#wasmtime has a bug when passing --tcplisten and --dir, to make it work we should use this PR https://github.com/bytecodealliance/wasmtime/pull/3995 and then the fd of the socket will be 4. - PATH=$(WASMTIME_DIR):${PATH} wasmtime --tcplisten localhost:64000 --dir=. console.wasm --env DEBUGGER_FD=4 diff --git a/src/mono/wasi/sample/console/WasiConsoleApp/Program.cs b/src/mono/wasi/sample/console/WasiConsoleApp/Program.cs deleted file mode 100644 index 83a7facbcf64d..0000000000000 --- a/src/mono/wasi/sample/console/WasiConsoleApp/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace WasiConsoleApp -{ - public class Program - { - public static int Main() - { - Console.WriteLine($"Hello from .NET at {DateTime.Now.ToLongTimeString()}"); - return 0; - } - } -} diff --git a/src/mono/wasi/sample/console/WasiConsoleApp/WasiConsoleApp.csproj b/src/mono/wasi/sample/console/WasiConsoleApp/WasiConsoleApp.csproj deleted file mode 100644 index 2e577472d6860..0000000000000 --- a/src/mono/wasi/sample/console/WasiConsoleApp/WasiConsoleApp.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net7.0 - true - embedded - - - diff --git a/src/mono/wasi/sample/console/main.c b/src/mono/wasi/sample/console/main.c deleted file mode 100644 index 251d88342e449..0000000000000 --- a/src/mono/wasi/sample/console/main.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "../../runtime/driver.h" - -int main() { - // Assume the runtime pack has been copied into the output directory as 'runtime' - // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment - const char* app_base_dir = "./WasiConsoleApp/bin/Debug/net7.0"; - char* assemblies_path; - asprintf(&assemblies_path, "%s:%s/runtime/native:%s/runtime/lib/net7.0", app_base_dir, app_base_dir, app_base_dir); - - add_assembly(app_base_dir, "WasiConsoleApp.dll"); - mono_set_assemblies_path(assemblies_path); - - mono_wasm_load_runtime("", 0); - - MonoAssembly* assembly = mono_wasm_assembly_load ("WasiConsoleApp.dll"); - MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); - MonoObject* out_exc; - MonoObject *exit_code = mono_wasm_invoke_method (entry_method, NULL, NULL, &out_exc); - return mono_unbox_int (exit_code); -} diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index bae726e6e0508..a86869d18d64f 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -80,6 +80,8 @@ diff --git a/src/mono/wasi/wasmtime-version.txt b/src/mono/wasi/wasmtime-version.txt new file mode 100644 index 0000000000000..f93ea0ca33305 --- /dev/null +++ b/src/mono/wasi/wasmtime-version.txt @@ -0,0 +1 @@ +2.0.2 \ No newline at end of file From 6c84aa58eb9f5324334a142569050b1015f1e453 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 20:14:52 +0100 Subject: [PATCH 034/116] wip --- src/mono/wasi/mono-include/driver.h | 1 - src/mono/wasi/runtime/driver.c | 29 +++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mono/wasi/mono-include/driver.h b/src/mono/wasi/mono-include/driver.h index a27f2b8480614..664680e137c23 100644 --- a/src/mono/wasi/mono-include/driver.h +++ b/src/mono/wasi/mono-include/driver.h @@ -13,7 +13,6 @@ MonoClass* mono_wasm_assembly_find_class (MonoAssembly *assembly, const char *na MonoMethod* mono_wasm_assembly_find_method (MonoClass *klass, const char *name, int arguments); MonoObject* mono_wasm_invoke_method (MonoMethod *method, MonoObject *this_arg, void *params[], MonoObject **out_exc); int mono_unbox_int (MonoObject *obj); -void mono_wasm_setenv (const char *name, const char *value); void add_assembly(const char* base_dir, const char *name); MonoArray* mono_wasm_obj_array_new (int size); diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 1c3951c24b634..f6658bc6df280 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -160,10 +160,6 @@ char* gai_strerror(int code) { return result; } -int32_t dotnet_browser_entropy(uint8_t* buffer, int32_t bufferLength) { - return getentropy (buffer, bufferLength); -} - void mono_wasm_add_satellite_assembly (const char *name, const char *culture, const unsigned char *data, unsigned int size) { @@ -174,12 +170,6 @@ mono_wasm_add_satellite_assembly (const char *name, const char *culture, const u ++satellite_assembly_count; } -void -mono_wasm_setenv (const char *name, const char *value) -{ - monoeg_g_setenv (strdup (name), strdup (value), 1); -} - static void *sysglobal_native_handle; int32_t SystemNative_LChflagsCanSetHiddenFlag(void); char* SystemNative_GetEnv(char* name); @@ -328,6 +318,7 @@ static PinvokeImport SystemGlobalizationNativeImports [] = { static void* wasm_dl_load (const char *name, int flags, char **err, void *user_data) { + printf("In wasm_dl_load for name %s\n", name); if (!strcmp (name, "libSystem.Native")) return SystemNativeImports; if (!strcmp (name, "libSystem.Globalization.Native")) @@ -429,6 +420,8 @@ mono_wasm_load_runtime (const char *argv, int debug_level) // corlib assemblies. monoeg_g_setenv ("COMPlus_DebugWriteToStdErr", "1", 0); #endif + +#if TODOWASI char* debugger_fd = monoeg_g_getenv ("DEBUGGER_FD"); if (debugger_fd != 0) { @@ -449,8 +442,7 @@ mono_wasm_load_runtime (const char *argv, int debug_level) const char *appctx_values[2]; appctx_values [0] = "/"; - appctx_values [1] = "browser-wasm"; - + appctx_values [1] = "wasi-wasm"; const char *file_name = RUNTIMECONFIG_BIN_FILE; int str_len = strlen (file_name) + 1; // +1 is for the "/" char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character @@ -467,10 +459,14 @@ mono_wasm_load_runtime (const char *argv, int debug_level) } else { free (file_path); } - monovm_initialize (2, appctx_keys, appctx_values); +#else + monovm_initialize (0, NULL, NULL); +#endif /* TODOWASI */ +#if TODOWASI mini_parse_debug_option ("top-runtime-invoke-unhandled"); +#endif /* TODOWASI */ mono_dl_fallback_register (wasm_dl_load, wasm_dl_symbol, NULL, NULL); mono_wasm_install_get_native_to_interp_tramp (get_native_to_interp); @@ -801,10 +797,15 @@ MonoMethod* lookup_dotnet_method(const char* assembly_name, const char* namespac } int main() { + printf("monoeg_g_setenv\n"); + monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0); + monoeg_g_setenv ("MONO_LOG_MASK", "all", 0); + + printf("mono_set_assemblies_path\n"); // Assume the runtime pack has been copied into the output directory as 'runtime' // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment - printf("mono_set_assemblies_path\n"); mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); + printf("mono_wasm_load_runtime\n"); mono_wasm_load_runtime("", 0); From c5689145b7f8f8665815692a2fa784cc0c848202 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 20:24:39 +0100 Subject: [PATCH 035/116] wip --- src/mono/wasi/runtime/driver.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index f6658bc6df280..382ccd73762c3 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -414,7 +414,7 @@ mono_wasm_load_runtime (const char *argv, int debug_level) #ifdef DEBUG monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0); - monoeg_g_setenv ("MONO_LOG_MASK", "gc", 0); + monoeg_g_setenv ("MONO_LOG_MASK", "all", 0); // Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this // output will be sent to the console. Right now this is the only way to emit debug logging from // corlib assemblies. @@ -797,11 +797,6 @@ MonoMethod* lookup_dotnet_method(const char* assembly_name, const char* namespac } int main() { - printf("monoeg_g_setenv\n"); - monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0); - monoeg_g_setenv ("MONO_LOG_MASK", "all", 0); - - printf("mono_set_assemblies_path\n"); // Assume the runtime pack has been copied into the output directory as 'runtime' // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); From 59097074cc941890880b8a719b799b4580ad8b81 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 21:29:02 +0100 Subject: [PATCH 036/116] wip --- .../common/templates/wasi-build-only.yml | 49 ++++++++++++++ eng/pipelines/runtime.yml | 8 +++ src/mono/wasi/runtime/CMakeLists.txt | 2 +- src/mono/wasi/runtime/driver.c | 14 ++++ src/mono/wasi/runtime/pinvoke.c | 64 +++++++++++++++++++ 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 eng/pipelines/common/templates/wasi-build-only.yml create mode 100644 src/mono/wasi/runtime/pinvoke.c diff --git a/eng/pipelines/common/templates/wasi-build-only.yml b/eng/pipelines/common/templates/wasi-build-only.yml new file mode 100644 index 0000000000000..2edf9f3f9d214 --- /dev/null +++ b/eng/pipelines/common/templates/wasi-build-only.yml @@ -0,0 +1,49 @@ +parameters: + alwaysRun: false + extraBuildArgs: '' + isExtraPlatformsBuild: false + nameSuffix: '' + platforms: [] + +jobs: + +# +# Build for Wasi/wasm and test it +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml + buildConfig: Release + runtimeFlavor: mono + platforms: ${{ parameters.platforms }} + variables: + # map dependencies variables to local variables + - name: alwaysRunVar + value: ${{ parameters.alwaysRun }} + - name: shouldRunOnDefaultPipelines + value: $[ + or( + eq(variables['wasmDarcDependenciesChanged'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true), + and( + eq(dependencies.evaluate_paths.outputs['SetPathVars_wasm.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_non_runtimetests.containsChange'], true)), + eq(dependencies.evaluate_paths.outputs['SetPathVars_wasm_libraries.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_mono_excluding_wasm.containsChange'], true)) + ] + jobParameters: + isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }} + testGroup: innerloop + nameSuffix: ${{ parameters.nameSuffix }}_BuildOnly + buildArgs: -s mono+libs+host -c $(_BuildConfig) /p:ArchiveTests=true ${{ parameters.extraBuildArgs }} + timeoutInMinutes: 240 + # if !alwaysRun, then: + # if this is runtime-wasm (isWasmOnlyBuild): + # - then run only if it would not have run on default pipelines (based + # on path changes) + # - else run based on path changes + condition: >- + or( + eq(variables['alwaysRunVar'], true), + eq(variables['isDefaultPipeline'], variables['shouldRunOnDefaultPipelines'])) diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 261f3058a297e..f4d3c2472b916 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -454,6 +454,14 @@ extends: extraBuildArgs: /p:WasmEnablePerfTracing=true alwaysRun: ${{ variables.isRollingBuild }} + # BUILD ONLY - Wasi/Wasm + - template: /eng/pipelines/common/templates/wasi-build-only.yml + parameters: + platforms: + - Wasi_wasm + extraBuildArgs: /p:WasmEnableThreads=true + alwaysRun: ${{ variables.isRollingBuild }} + # # iOS/tvOS devices - Full AOT + AggressiveTrimming to reduce size # Build the whole product using Mono and run libraries tests diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 7edab4e22fe0e..4264565cdc5e6 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -6,7 +6,7 @@ option(DISABLE_THREADS "defined if the build does NOT support multithreading" ON option(DISABLE_WASM_USER_THREADS "defined if the build does not allow user threads to be created in a multithreaded build" OFF) set(CMAKE_EXECUTABLE_SUFFIX ".wasm") -add_executable(dotnet driver.c stubs.c synthetic-pthread.c) +add_executable(dotnet driver.c pinvoke.c stubs.c synthetic-pthread.c) target_include_directories(dotnet PUBLIC ${MONO_INCLUDES} ${MONO_OBJ_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/include/wasm) target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${NATIVE_BIN_DIR}/src/wasi-compile.rsp -DCORE_BINDINGS -DGEN_PINVOKE=1) diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 382ccd73762c3..7d5b25a652b56 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -39,6 +39,14 @@ #include "wasm_m2n_invoke.g.h" #endif +#if !defined(ENABLE_AOT) || defined(EE_MODE_LLVMONLY_INTERP) +#define NEED_INTERP 1 +#ifndef LINK_ICALLS +// FIXME: llvm+interp mode needs this to call icalls +#define NEED_NORMAL_ICALL_TABLES 1 +#endif +#endif + void mono_wasm_enable_debugging (int); int mono_wasm_register_root (char *start, size_t size, const char *name); @@ -477,6 +485,12 @@ mono_wasm_load_runtime (const char *argv, int debug_level) mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY); +#ifdef LINK_ICALLS + #error /* TODOWASI */ +#endif +#ifdef NEED_NORMAL_ICALL_TABLES + mono_icall_table_init (); +#endif mono_ee_interp_init (interp_opts); mono_marshal_ilgen_init (); mono_method_builder_ilgen_init (); diff --git a/src/mono/wasi/runtime/pinvoke.c b/src/mono/wasi/runtime/pinvoke.c new file mode 100644 index 0000000000000..0655b256f034d --- /dev/null +++ b/src/mono/wasi/runtime/pinvoke.c @@ -0,0 +1,64 @@ +// TODOWASI deduplicate src/mono/wasm/runtime/pinvoke.c +#include "wasm-config.h" +#include "pinvoke.h" + +#include +#include + +/* + * The table header contain autogenerated function declarations, so avoid including standard headers + * to avoid incompatible declarations. + */ +#define NULL ((void*)0) +int strcmp (const char *s1, const char *s2); +void mono_wasm_printerr (const char *s); + +#ifdef GEN_PINVOKE +#include "pinvoke-table.h" +#else +#include "pinvoke-tables-default.h" +#endif + +void +mono_wasm_pinvoke_vararg_stub (void) +{ + /* This is just a stub used to mark vararg pinvokes */ +} + +void* +wasm_dl_lookup_pinvoke_table (const char *name) +{ + for (int i = 0; i < sizeof (pinvoke_tables) / sizeof (void*); ++i) { + if (!strcmp (name, pinvoke_names [i])) + return pinvoke_tables [i]; + } + return NULL; +} + +int +wasm_dl_is_pinvoke_table (void *handle) +{ + for (int i = 0; i < sizeof (pinvoke_tables) / sizeof (void*); ++i) { + if (pinvoke_tables [i] == handle) { + return 1; + } + } + return 0; +} + +void* +wasm_dl_get_native_to_interp (const char *key, void *extra_arg) +{ +#ifdef GEN_PINVOKE + for (int i = 0; i < sizeof (wasm_native_to_interp_map) / sizeof (void*); ++i) { + if (!strcmp (wasm_native_to_interp_map [i], key)) { + void *addr = wasm_native_to_interp_funcs [i]; + wasm_native_to_interp_ftndescs [i] = *(InterpFtnDesc*)extra_arg; + return addr; + } + } + return NULL; +#else + return NULL; +#endif +} From 71bbaed058af1b696b02204d568f1387850ccf59 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 11 Nov 2022 21:31:32 +0100 Subject: [PATCH 037/116] wip --- eng/pipelines/common/platform-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index cccc6c42fa73b..a7a12c1a9d060 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -387,7 +387,7 @@ jobs: targetRid: wasi-wasm platform: Wasi_wasm shouldContinueOnError: ${{ parameters.shouldContinueOnError }} - container: Linux_64 + container: Linux_x64 jobParameters: hostedOs: Linux runtimeFlavor: ${{ parameters.runtimeFlavor }} From fc47c6110c910ddaa41a42493805af6633ebf1a7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 14 Nov 2022 17:03:46 +0100 Subject: [PATCH 038/116] Added WasmtimeURL for macos and updated WasiSdkUrl --- src/mono/mono.proj | 2 +- src/mono/sample/wasi/Directory.Build.targets | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e97f125443272..6d760bb391257 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -178,7 +178,7 @@ $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) %(_VersionLines.Identity) https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 92c9d2683527b..96c11d48de1ba 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -46,6 +46,7 @@ %(_VersionLines.Identity) https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-linux.tar.xz + https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-macos.tar.xz From 260e801117ed0f4a68de39095b37ba40be5f546a Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 17:24:26 +0100 Subject: [PATCH 039/116] wip --- src/mono/wasi/runtime/CMakeLists.txt | 4 +- src/mono/wasi/runtime/driver.c | 167 +++---------------------- src/mono/wasi/wasi.proj | 2 + src/native/libs/System.Native/pal_io.c | 5 + 4 files changed, 26 insertions(+), 152 deletions(-) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 4264565cdc5e6..2019a462421b9 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -14,8 +14,8 @@ target_compile_options(dotnet PUBLIC @${NATIVE_BIN_DIR}/src/wasi-default.rsp @${ set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLAGS}) target_link_libraries(dotnet - ${ICU_LIB_DIR}/libicuuc.a - ${ICU_LIB_DIR}/libicui18n.a + #TODOWASI ${ICU_LIB_DIR}/libicuuc.a + #TODOWASI ${ICU_LIB_DIR}/libicui18n.a ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a ${MONO_ARTIFACTS_DIR}/libmono-component-debugger-static.a ${MONO_ARTIFACTS_DIR}/libmono-component-diagnostics_tracing-stub-static.a diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 7d5b25a652b56..f25b15998aa30 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -179,161 +179,22 @@ mono_wasm_add_satellite_assembly (const char *name, const char *culture, const u } static void *sysglobal_native_handle; -int32_t SystemNative_LChflagsCanSetHiddenFlag(void); -char* SystemNative_GetEnv(char* name); -char* SystemNative_GetEnviron(char* name); -void SystemNative_FreeEnviron(char* name); -intptr_t SystemNative_Dup(intptr_t oldfd); -int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize); -int64_t SystemNative_GetSystemTimeAsTicks(); -int32_t SystemNative_Stat(const char* path, void* output); -int32_t SystemNative_LStat(const char* path, void* output); -int32_t SystemNative_ConvertErrorPlatformToPal(int32_t platformErrno); -void* SystemNative_LowLevelMonitor_Create(); -void SystemNative_LowLevelMonitor_Acquire(void* monitor); -void SystemNative_LowLevelMonitor_Release(void* monitor); -int32_t SystemNative_LowLevelMonitor_TimedWait(void *monitor, int32_t timeoutMilliseconds); -void SystemNative_LowLevelMonitor_Wait(void* monitor); -int SystemNative_GetErrNo(); -void SystemNative_SetErrNo(int value); -char* SystemNative_GetCwd(); -void SystemNative_GetNonCryptographicallySecureRandomBytes(); -void SystemNative_GetCryptographicallySecureRandomBytes(); -int32_t SystemNative_Open(const char* path, int x, int y); -void SystemNative_ConvertErrorPalToPlatform(); -void SystemNative_StrErrorR(); -void SystemNative_Close(); -void SystemNative_FStat(); -void SystemNative_LSeek(); -void SystemNative_PRead(); -void SystemNative_CanGetHiddenFlag(); -int32_t SystemNative_Access(const char* path, int32_t mode); -void SystemNative_Malloc(); -void SystemNative_Free(); -void SystemNative_SysLog(); - -#define PAL_O_RDONLY 0x0000 -#define PAL_O_WRONLY 0x0001 -#define PAL_O_RDWR 0x0002 -#define PAL_O_ACCESS_MODE_MASK 0x000F - -int32_t SystemNative_Open2(const char* path, int flags, int mode) { - //printf ("In SystemNative_Open2 for %s\n", path); - // The implementation in libSystemNative tries to use PAL_O_CLOEXEC, which isn't supported here, so override it - if ((flags & PAL_O_ACCESS_MODE_MASK) == PAL_O_RDONLY) { - flags = O_RDONLY; - } else if ((flags & PAL_O_ACCESS_MODE_MASK) == PAL_O_RDWR) { - flags = O_RDWR; - } else if ((flags & PAL_O_ACCESS_MODE_MASK) == PAL_O_WRONLY) { - flags = O_WRONLY; - } - - int result; - while ((result = open(path, flags, (mode_t)mode)) < 0 && errno == EINTR); - return result; -} - -int32_t SystemNative_Stat2(const char* path, FileStatus* output) -{ - // For some reason the libSystemNative SystemNative_Stat doesn't seem to work. Maybe I did something wrong elsewhere, - // or maybe it's hardcoded to something specific to browser wasm - struct stat stat_result; - int ret; - while ((ret = stat(path, &stat_result)) < 0 && errno == EINTR); - - output->Size = stat_result.st_size; - output->ATime = stat_result.st_atime; - output->MTime = stat_result.st_mtime; - output->CTime = stat_result.st_ctime; - output->Mode = S_ISDIR (stat_result.st_mode) - ? 0x4000 // Dir - : 0x8000; // File - - // Never fail when looking for the root directory. Even if the WASI host isn't giving us filesystem access - // (which is the default), we need the root directory to appear to exist, otherwise things like ASP.NET Core - // will fail by default, whether or not it needs to read anything from the filesystem. - if (ret != 0 && path[0] == '/' && path[1] == 0) { - output->Mode = 0x4000; // Dir - return 0; - } - - //printf("SystemNative_Stat2 for %s has ISDIR=%i and will return mode %i; ret=%i\n", path, S_ISDIR (stat_result.st_mode), output->Mode, ret); - - return ret; -} - -int32_t SystemNative_Write2(intptr_t fd, const void* buffer, int32_t bufferSize) { - // Not sure why, but am getting fd=-1 when trying to write to stdout (which fails), so here's a workaround - return SystemNative_Write((int)fd == -1 ? 1: fd, buffer, bufferSize); -} - -int64_t SystemNative_GetTimestamp2() { - // libSystemNative's implementation of SystemNative_GetTimestamp causes the process to exit. It probably - // relies on calling into JS. - struct timeval time; - return (gettimeofday(&time, NULL) == 0) - ? (int64_t)(time.tv_sec) * 1000000000 + (time.tv_usec * 1000) - : 0; -} - -// TODOWASI replace with native libs -static PinvokeImport SystemNativeImports [] = { - {"SystemNative_GetEnv", SystemNative_GetEnv }, - {"SystemNative_GetEnviron", SystemNative_GetEnviron }, - {"SystemNative_FreeEnviron", SystemNative_FreeEnviron }, - {"SystemNative_LChflagsCanSetHiddenFlag", SystemNative_LChflagsCanSetHiddenFlag }, - {"SystemNative_Dup", SystemNative_Dup}, - {"SystemNative_Write", SystemNative_Write2}, - {"SystemNative_GetSystemTimeAsTicks", SystemNative_GetSystemTimeAsTicks}, - {"SystemNative_LStat", SystemNative_Stat2}, - {"SystemNative_FStat", SystemNative_FStat}, - {"SystemNative_LSeek", SystemNative_LSeek}, - {"SystemNative_ConvertErrorPlatformToPal", SystemNative_ConvertErrorPlatformToPal}, - {"SystemNative_LowLevelMonitor_Create", SystemNative_LowLevelMonitor_Create}, - {"SystemNative_LowLevelMonitor_Acquire", SystemNative_LowLevelMonitor_Acquire}, - {"SystemNative_LowLevelMonitor_Release", SystemNative_LowLevelMonitor_Release}, - {"SystemNative_LowLevelMonitor_TimedWait", SystemNative_LowLevelMonitor_TimedWait}, - {"SystemNative_LowLevelMonitor_Wait", SystemNative_LowLevelMonitor_Wait}, - {"SystemNative_GetErrNo", SystemNative_GetErrNo}, - {"SystemNative_SetErrNo", SystemNative_SetErrNo}, - {"SystemNative_GetCwd", SystemNative_GetCwd}, - {"SystemNative_GetNonCryptographicallySecureRandomBytes", SystemNative_GetNonCryptographicallySecureRandomBytes}, - {"SystemNative_GetCryptographicallySecureRandomBytes", SystemNative_GetCryptographicallySecureRandomBytes}, - {"SystemNative_Stat", SystemNative_Stat2}, - {"SystemNative_Open", SystemNative_Open2}, - {"SystemNative_Close", SystemNative_Close}, - {"SystemNative_ConvertErrorPalToPlatform", SystemNative_ConvertErrorPalToPlatform}, - {"SystemNative_StrErrorR", SystemNative_StrErrorR}, - {"SystemNative_PRead", SystemNative_PRead}, - {"SystemNative_CanGetHiddenFlag", SystemNative_CanGetHiddenFlag}, - {"SystemNative_GetTimestamp", SystemNative_GetTimestamp2}, - {"SystemNative_Access", SystemNative_Access}, - {"SystemNative_Malloc", SystemNative_Malloc}, - {"SystemNative_Free", SystemNative_Free}, - {"SystemNative_SysLog", SystemNative_SysLog}, - {NULL, NULL} -}; - -void GlobalizationNative_LoadICU() { - assert(0); -} - -static PinvokeImport SystemGlobalizationNativeImports [] = { - {"GlobalizationNative_LoadICU", GlobalizationNative_LoadICU }, - {NULL, NULL} -}; static void* wasm_dl_load (const char *name, int flags, char **err, void *user_data) { - printf("In wasm_dl_load for name %s\n", name); - if (!strcmp (name, "libSystem.Native")) - return SystemNativeImports; - if (!strcmp (name, "libSystem.Globalization.Native")) - return SystemGlobalizationNativeImports; + void* handle = wasm_dl_lookup_pinvoke_table (name); + if (handle) + return handle; + + if (!strcmp (name, "System.Globalization.Native")) + return sysglobal_native_handle; - //printf("In wasm_dl_load for name %s but treating as NOT FOUND\n", name); - return 0; +#if WASM_SUPPORTS_DLOPEN + return dlopen(name, flags); +#endif + + return NULL; } static void* @@ -342,6 +203,12 @@ wasm_dl_symbol (void *handle, const char *name, char **err, void *user_data) if (handle == sysglobal_native_handle) assert (0); +#if WASM_SUPPORTS_DLOPEN + if (!wasm_dl_is_pinvoke_tables (handle)) { + return dlsym (handle, name); + } +#endif + PinvokeImport *table = (PinvokeImport*)handle; for (int i = 0; table [i].name; ++i) { if (!strcmp (table [i].name, name)) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index a86869d18d64f..23a46e16bdf12 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -52,7 +52,9 @@ + diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index b2b9bab549dc1..cfb30073cf10e 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -1867,6 +1867,11 @@ int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount #else /* TARGET_WASI */ +int32_t SystemNative_Link(const char* source, const char* linkTarget) +{ + return -1; +} + int32_t SystemNative_Stat(const char* path, FileStatus* output) { return -1; From 888e89994e0b0b58cefd34fe616708b8c4f45c17 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 18:18:14 +0100 Subject: [PATCH 040/116] wip --- src/native/libs/System.Native/pal_console.c | 13 ++++ .../libs/System.Native/pal_dynamicload.c | 16 +++-- src/native/libs/System.Native/pal_io.c | 67 +++++++++++++++++++ src/native/libs/System.Native/pal_mount.c | 6 +- .../libs/System.Native/pal_networking.c | 57 ++++++++++++++++ src/native/libs/System.Native/pal_process.c | 16 +++++ src/native/libs/System.Native/pal_signal.c | 8 +++ src/native/libs/System.Native/pal_threading.c | 25 +++---- src/native/libs/System.Native/pal_uid.c | 8 +++ 9 files changed, 196 insertions(+), 20 deletions(-) diff --git a/src/native/libs/System.Native/pal_console.c b/src/native/libs/System.Native/pal_console.c index e876256d2e328..89fc6719d86f8 100644 --- a/src/native/libs/System.Native/pal_console.c +++ b/src/native/libs/System.Native/pal_console.c @@ -495,6 +495,7 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) int32_t SystemNative_GetWindowSize(WinSize* windowSize) { + printf ("TODOWASI %s\n", __FUNCTION__); memset(windowSize, 0, sizeof(WinSize)); // managed out param must be initialized errno = ENOTSUP; return -1; @@ -502,59 +503,71 @@ int32_t SystemNative_GetWindowSize(WinSize* windowSize) int32_t SystemNative_SetWindowSize(WinSize* windowSize) { + printf ("TODOWASI %s\n", __FUNCTION__); errno = ENOTSUP; return -1; } int32_t SystemNative_IsATty(intptr_t fd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } void SystemNative_SetKeypadXmit(const char* terminfoString) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_InitializeConsoleBeforeRead(uint8_t minChars, uint8_t decisecondsTimeout) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_UninitializeConsoleAfterRead(void) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_ConfigureTerminalForChildProcess(int32_t childUsesTerminal) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_GetControlCharacters( int32_t* controlCharacterNames, uint8_t* controlCharacterValues, int32_t controlCharacterLength, uint8_t* posixDisableValue) { + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_StdinReady(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ReadStdin(void* buffer, int32_t bufferSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetSignalForBreak(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_SetSignalForBreak(int32_t signalForBreak) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_InitializeTerminalAndSignalHandling(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } diff --git a/src/native/libs/System.Native/pal_dynamicload.c b/src/native/libs/System.Native/pal_dynamicload.c index c389f757ff02e..56de3a266ecdc 100644 --- a/src/native/libs/System.Native/pal_dynamicload.c +++ b/src/native/libs/System.Native/pal_dynamicload.c @@ -61,33 +61,39 @@ void SystemNative_FreeLibrary(void* handle) #else /* TARGET_WASI */ void* SystemNative_LoadLibrary(const char* filename) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } void* SystemNative_GetLoadLibraryError(void) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } void* SystemNative_GetProcAddress(void* handle, const char* symbol) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } void SystemNative_FreeLibrary(void* handle) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } #endif /* TARGET_WASI */ -#if defined TARGET_ANDROID || defined TARGET_WASI +#if defined TARGET_ANDROID void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) { return NULL; } +#elif defined TARGET_WASI +void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) +{ + printf ("TODOWASI %s\n", __FUNCTION__); + return NULL; +} #else static void* volatile g_defaultSearchOrderPseudoHandle = NULL; void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index cfb30073cf10e..2e9ba125bbd1e 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -1869,165 +1869,198 @@ int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount int32_t SystemNative_Link(const char* source, const char* linkTarget) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Stat(const char* path, FileStatus* output) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FStat(intptr_t fd, FileStatus* output) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_LStat(const char* path, FileStatus* output) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } intptr_t SystemNative_Open(const char* path, int32_t flags, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Close(intptr_t fd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } intptr_t SystemNative_Dup(intptr_t oldfd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Unlink(const char* path) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } intptr_t SystemNative_ShmOpen(const char* name, int32_t flags, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ShmUnlink(const char* name) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetReadDirRBufferSize(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ReadDirR(DIR* dir, uint8_t* buffer, int32_t bufferSize, DirectoryEntry* outputEntry) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } DIR* SystemNative_OpenDir(const char* path) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } int32_t SystemNative_CloseDir(DIR* dir) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Pipe(int32_t pipeFds[2], int32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlSetFD(intptr_t fd, int32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlGetFD(intptr_t fd) { + printf("TODOSystemNative_FcntlGetFDWASI\n"); return -1; } int32_t SystemNative_FcntlCanGetSetPipeSz(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlGetPipeSz(intptr_t fd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlSetPipeSz(intptr_t fd, int32_t size) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlSetIsNonBlocking(intptr_t fd, int32_t isNonBlocking) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FcntlGetIsNonBlocking(intptr_t fd, int32_t* isNonBlocking) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_MkDir(const char* path, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ChMod(const char* path, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FChMod(intptr_t fd, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FSync(intptr_t fd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FLock(intptr_t fd, int32_t operation) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ChDir(const char* path) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Access(const char* path, int32_t mode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int64_t SystemNative_LSeek(intptr_t fd, int64_t offset, int32_t whence) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_SymLink(const char* target, const char* linkPath) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber) { + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_MkNod(const char* pathName, uint32_t mode, uint32_t major, uint32_t minor) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } @@ -2038,11 +2071,13 @@ int32_t SystemNative_MkFifo(const char* pathName, uint32_t mode) char* SystemNative_MkdTemp(char* pathTemplate) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } @@ -2053,160 +2088,192 @@ void* SystemNative_MMap(void* address, intptr_t fd, int64_t offset) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } int32_t SystemNative_MUnmap(void* address, uint64_t length) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_MSync(void* address, uint64_t length, int32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int64_t SystemNative_SysConf(int32_t name) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FTruncate(intptr_t fd, int64_t length) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t milliseconds, uint32_t* triggered) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_PosixFAdvise(intptr_t fd, int64_t offset, int64_t length, int32_t advice) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FAllocate(intptr_t fd, int64_t offset, int64_t length) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Read(intptr_t fd, void* buffer, int32_t bufferSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_ReadLink(const char* path, char* buffer, int32_t bufferSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Rename(const char* oldPath, const char* newPath) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_RmDir(const char* path) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } void SystemNative_Sync(void) { + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t sourceLength) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } intptr_t SystemNative_INotifyInit(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_INotifyAddWatch(intptr_t fd, const char* pathName, uint32_t mask) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_INotifyRemoveWatch(intptr_t fd, int32_t wd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } char* SystemNative_RealPath(const char* path) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } uint32_t SystemNative_GetFileSystemType(intptr_t fd) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0xFFFFFFFF; } int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_LChflags(const char* path, uint32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_FChflags(intptr_t fd, uint32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_LChflagsCanSetHiddenFlag(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return false; } int32_t SystemNative_CanGetHiddenFlag(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return false; } int32_t SystemNative_ReadProcessStatusInfo(pid_t pid, ProcessStatus* processStatus) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_PRead(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_PWrite(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int64_t SystemNative_PReadV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } diff --git a/src/native/libs/System.Native/pal_mount.c b/src/native/libs/System.Native/pal_mount.c index c17014256ced4..34c63b6d6a292 100644 --- a/src/native/libs/System.Native/pal_mount.c +++ b/src/native/libs/System.Native/pal_mount.c @@ -183,13 +183,13 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer #else /* TARGET_WASI */ int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return 0; } int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInformation* mpi) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); memset(mpi, 0, sizeof(MountPointInformation)); return -1; } @@ -197,7 +197,7 @@ int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInfor int32_t SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer, int32_t bufferLength, int64_t* formatType) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } #endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_networking.c b/src/native/libs/System.Native/pal_networking.c index aac624fc65fc2..b8e986e14ad80 100644 --- a/src/native/libs/System.Native/pal_networking.c +++ b/src/native/libs/System.Native/pal_networking.c @@ -3288,11 +3288,13 @@ uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t addressFamily, HostEntry* entry) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } void SystemNative_FreeHostEntry(HostEntry* entry) { + printf ("TODOWASI %s\n", __FUNCTION__); if (entry != NULL) { free(entry->CanonicalName); @@ -3313,238 +3315,284 @@ int32_t SystemNative_GetNameInfo(const uint8_t* address, int32_t serviceLength, int32_t flags) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetDomainName(uint8_t* name, int32_t nameLength) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetHostName(uint8_t* name, int32_t nameLength) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetIPSocketAddressSizes(int32_t* ipv4SocketAddressSize, int32_t* ipv6SocketAddressSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetAddressFamily(const uint8_t* socketAddress, int32_t socketAddressLen, int32_t* addressFamily) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetAddressFamily(uint8_t* socketAddress, int32_t socketAddressLen, int32_t addressFamily) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetPort(const uint8_t* socketAddress, int32_t socketAddressLen, uint16_t* port) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetPort(uint8_t* socketAddress, int32_t socketAddressLen, uint16_t port) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetIPv4Address(const uint8_t* socketAddress, int32_t socketAddressLen, uint32_t* address) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetIPv4Address(uint8_t* socketAddress, int32_t socketAddressLen, uint32_t address) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetIPv6Address( const uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t* scopeId) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetIPv6Address(uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t scopeId) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetControlMessageBufferSize(int32_t isIPv4, int32_t isIPv6) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isIPv4, IPPacketInformation* packetInfo) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetReceiveTimeout(intptr_t socket, int32_t millisecondsTimeout) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetSendTimeout(intptr_t socket, int32_t millisecondsTimeout) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Receive(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* received) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_ReceiveMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* received) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* sent) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* sent) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Accept(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen, intptr_t* acceptedSocket) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Bind(intptr_t socket, int32_t protocolType, uint8_t* socketAddress, int32_t socketAddressLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Connect(intptr_t socket, uint8_t* socketAddress, int32_t socketAddressLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Listen(intptr_t socket, int32_t backlog) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Shutdown(intptr_t socket, int32_t socketShutdown) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetSocketErrorOption(intptr_t socket, int32_t* error) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetSockOpt( intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetRawSockOpt( intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetSockOpt(intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_SetRawSockOpt( intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t protocolType, intptr_t* createdSocket) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int32_t* socketType, int32_t* protocolType, int32_t* isListening) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetAtOutOfBandMark(intptr_t socket, int32_t* atMark) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_GetBytesAvailable(intptr_t socket, int32_t* available) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_CreateSocketEventPort(intptr_t* port) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_CloseSocketEventPort(intptr_t port) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_CreateSocketEventBuffer(int32_t count, SocketEvent** buffer) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_FreeSocketEventBuffer(SocketEvent* buffer) { + printf ("TODOWASI %s\n", __FUNCTION__); free(buffer); return Error_SUCCESS; } @@ -3552,26 +3600,31 @@ int32_t SystemNative_FreeSocketEventBuffer(SocketEvent* buffer) int32_t SystemNative_TryChangeSocketEventRegistration(intptr_t port, intptr_t socket, int32_t currentEvents, int32_t newEvents, uintptr_t data) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_WaitForSocketEvents(intptr_t port, SocketEvent* buffer, int32_t* count) { + printf ("TODOWASI %s\n", __FUNCTION__); return Error_EFAULT; } int32_t SystemNative_PlatformSupportsDualModeIPv4PacketInfo(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0; } char* SystemNative_GetPeerUserName(intptr_t socket) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, int32_t* addressSize) { + printf ("TODOWASI %s\n", __FUNCTION__); *pathOffset = 0; *pathSize = 0; *addressSize = 0; @@ -3579,21 +3632,25 @@ void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, i int32_t SystemNative_GetMaximumAddressSize(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Disconnect(intptr_t socket) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_SendFile(intptr_t out_fd, intptr_t in_fd, int64_t offset, int64_t count, int64_t* sent) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0xFFFFFFFF; } diff --git a/src/native/libs/System.Native/pal_process.c b/src/native/libs/System.Native/pal_process.c index c5e512239c36a..92548fc021a99 100644 --- a/src/native/libs/System.Native/pal_process.c +++ b/src/native/libs/System.Native/pal_process.c @@ -912,70 +912,84 @@ int32_t SystemNative_ForkAndExecProcess(const char* filename, int32_t* stdoutFd, int32_t* stderrFd) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetRLimit(RLimitResources resourceType, RLimit* limits) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_SetRLimit(RLimitResources resourceType, const RLimit* limits) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_Kill(int32_t pid, int32_t signal) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetPid(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetSid(int32_t pid) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } void SystemNative_SysLog(SysLogPriority priority, const char* message, const char* arg1) { + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_WaitIdAnyExitedNoHangNoWait(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_WaitPidExitedNoHang(int32_t pid, int32_t* exitCode) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int64_t SystemNative_PathConf(const char* path, PathConfName name) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetPriority(PriorityWhich which, int32_t who) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_SetPriority(PriorityWhich which, int32_t who, int32_t nice) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } char* SystemNative_GetCwd(char* buffer, int32_t bufferSize) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } int32_t SystemNative_SchedSetAffinity(int32_t pid, intptr_t* mask) { + printf ("TODOWASI %s\n", __FUNCTION__); (void)pid; (void)mask; errno = ENOTSUP; @@ -984,6 +998,7 @@ int32_t SystemNative_SchedSetAffinity(int32_t pid, intptr_t* mask) int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask) { + printf ("TODOWASI %s\n", __FUNCTION__); (void)pid; (void)mask; errno = ENOTSUP; @@ -992,6 +1007,7 @@ int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask) char* SystemNative_GetProcessPath(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } #endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_signal.c b/src/native/libs/System.Native/pal_signal.c index ec641e6cbf0c9..fc4bf78368f6a 100644 --- a/src/native/libs/System.Native/pal_signal.c +++ b/src/native/libs/System.Native/pal_signal.c @@ -729,36 +729,44 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) int32_t SystemNative_GetPlatformSignalNumber(PosixSignal signal) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0; } void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_RegisterForSigChld(SigChldCallback callback) { + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_SetDelayedSigChildConsoleConfigurationHandler(void (*callback)(void)) { + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_EnablePosixSignalHandling(int signalCode) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0; } void SystemNative_DisablePosixSignalHandling(int signalCode) { + printf ("TODOWASI %s\n", __FUNCTION__); } #endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index 3414d0061ddc3..bcad49dd825db 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -4,6 +4,7 @@ #include "pal_config.h" #include "pal_threading.h" +#include #include #include #include @@ -292,70 +293,70 @@ void SystemNative_Abort(void) #else /* TARGET_WASI */ struct LowLevelMonitor { + // TARGET_WASI bool IsLocked; - // TODOWASI }; LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monitor, int32_t timeoutMilliseconds) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return false; } void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); } int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return false; } int32_t SystemNative_SchedGetCpu(void) { - // TODOWASI + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } __attribute__((noreturn)) void SystemNative_Exit(int32_t exitCode) { + printf ("TODOWASI %s\n", __FUNCTION__); assert(false); - // TODOWASI } __attribute__((noreturn)) void SystemNative_Abort(void) { + printf ("TODOWASI %s\n", __FUNCTION__); assert(false); - // TODOWASI } #endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_uid.c b/src/native/libs/System.Native/pal_uid.c index 2bad383d6f889..83a497691b652 100644 --- a/src/native/libs/System.Native/pal_uid.c +++ b/src/native/libs/System.Native/pal_uid.c @@ -314,41 +314,49 @@ char* SystemNative_GetGroupName(uint32_t gid) #else /* TARGET_WASI */ int32_t SystemNative_GetPwUidR(uint32_t uid, Passwd* pwd, char* buf, int32_t buflen) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetPwNamR(const char* name, Passwd* pwd, char* buf, int32_t buflen) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } uint32_t SystemNative_GetEUid(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0xFFFFFFFF; } uint32_t SystemNative_GetEGid(void) { + printf ("TODOWASI %s\n", __FUNCTION__); return 0xFFFFFFFF; } int32_t SystemNative_SetEUid(uint32_t euid) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetGroupList(const char* name, uint32_t group, uint32_t* groups, int32_t* ngroups) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } int32_t SystemNative_GetGroups(int32_t ngroups, uint32_t* groups) { + printf ("TODOWASI %s\n", __FUNCTION__); return -1; } char* SystemNative_GetGroupName(uint32_t gid) { + printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } #endif /* TARGET_WASI */ From 9e23285b982e24800daae669dd60cc70b6cbc129 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 18:46:22 +0100 Subject: [PATCH 041/116] wip --- src/mono/wasi/runtime/driver.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index f25b15998aa30..78ed7ad9ac391 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -81,11 +81,15 @@ static MonoDomain *root_domain; #define RUNTIMECONFIG_BIN_FILE "runtimeconfig.bin" static void -wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) +wasi_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) { - printf("[wasm_trace_logger] %s\n", message); - if (fatal) - exit (1); + printf("[wasi_trace_logger] %s\n", message); + if (fatal) { + // make it trap so we could see the stack trace + // (*(int*)(void*)-1)++; + exit(1); + } + } typedef uint32_t target_mword; @@ -377,7 +381,7 @@ mono_wasm_load_runtime (const char *argv, int debug_level) mono_wasm_register_bundled_satellite_assemblies (); mono_trace_init (); - mono_trace_set_log_handler (wasm_trace_logger, NULL); + mono_trace_set_log_handler (wasi_trace_logger, NULL); root_domain = mono_jit_init_version ("mono", NULL); mono_thread_set_main (mono_thread_current ()); @@ -686,8 +690,8 @@ int main() { mono_wasm_load_runtime("", 0); printf("mono_wasm_assembly_load\n"); - MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample.dll"); - printf("mono_wasm_assembly_get_entry_point\n"); + MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample"); + printf("mono_wasm_assembly_get_entry_point %d\n", (int)assembly); MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); MonoObject* out_exc; MonoObject *exit_code = mono_wasm_invoke_method (entry_method, NULL, NULL, &out_exc); From c43a183b89b9db1c1c90e29b26627f2e90957e83 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 19:12:11 +0100 Subject: [PATCH 042/116] iwp --- src/mono/sample/wasi/console/Program.cs | 17 +++++++----- src/mono/wasi/runtime/driver.c | 36 +++++++++---------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/mono/sample/wasi/console/Program.cs b/src/mono/sample/wasi/console/Program.cs index 7d959dedae34d..47b5c3a3e0218 100644 --- a/src/mono/sample/wasi/console/Program.cs +++ b/src/mono/sample/wasi/console/Program.cs @@ -6,13 +6,18 @@ public class Test { - public static async Task Main(string[] args) + public static int Main(string[] args) { - await Task.Delay(1); - Console.WriteLine("Hello World!"); - for (int i = 0; i < args.Length; i++) { - Console.WriteLine($"args[{i}] = {args[i]}"); + try{ + Console.WriteLine("Hello World!"); + for (int i = 0; i < args.Length; i++) { + Console.WriteLine($"args[{i}] = {args[i]}"); + } + return 0; + } + catch(Exception){ + //TODOWASI + return 2; } - return 0; } } diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 78ed7ad9ac391..ef6d57f7a25a6 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -465,24 +465,6 @@ mono_wasm_invoke_method_ref (MonoMethod *method, MonoObject **this_arg_in, void } } -// deprecated -MonoObject* -mono_wasm_invoke_method (MonoMethod *method, MonoObject *this_arg, void *params[], MonoObject **out_exc) -{ - MonoObject* result = NULL; - mono_wasm_invoke_method_ref (method, &this_arg, params, out_exc, &result); - - MonoMethodSignature *sig = mono_method_signature (method); - MonoType *type = mono_signature_get_return_type (sig); - // If the method return type is void return null - // This gets around a memory access crash when the result return a value when - // a void method is invoked. - if (mono_type_get_type (type) == MONO_TYPE_VOID) - return NULL; - - return result; -} - MonoMethod* mono_wasm_assembly_get_entry_point (MonoAssembly *assembly) { @@ -685,15 +667,21 @@ int main() { // Assume the runtime pack has been copied into the output directory as 'runtime' // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); - - printf("mono_wasm_load_runtime\n"); mono_wasm_load_runtime("", 0); - printf("mono_wasm_assembly_load\n"); MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample"); - printf("mono_wasm_assembly_get_entry_point %d\n", (int)assembly); MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); MonoObject* out_exc; - MonoObject *exit_code = mono_wasm_invoke_method (entry_method, NULL, NULL, &out_exc); - return mono_unbox_int (exit_code); + MonoObject* out_res; + mono_wasm_invoke_method_ref (entry_method, NULL, NULL, &out_exc, &out_res); + if (out_exc) + { + char* message = mono_wasm_string_get_utf8((MonoString*)out_res); + printf("%s\n", message); + free(message); + exit(1); + } + if(out_res) + return mono_unbox_int (out_res); + return 0; } From 1a4e2087ff7efb19601cbfd7e79d805886e79dd0 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 22:03:28 +0100 Subject: [PATCH 043/116] wip --- src/mono/sample/wasi/Directory.Build.targets | 3 +++ src/mono/wasi/runtime/driver.c | 4 +--- src/mono/wasi/wasi.proj | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 96c11d48de1ba..af2168b3e3693 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -53,6 +53,9 @@ + diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index ef6d57f7a25a6..96406b980480a 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -676,9 +676,7 @@ int main() { mono_wasm_invoke_method_ref (entry_method, NULL, NULL, &out_exc, &out_res); if (out_exc) { - char* message = mono_wasm_string_get_utf8((MonoString*)out_res); - printf("%s\n", message); - free(message); + mono_print_unhandled_exception(out_exc); exit(1); } if(out_res) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 23a46e16bdf12..6ea90f29e2e29 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -83,7 +83,7 @@ @@ -104,9 +104,7 @@ <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> - <_WasiLinkFlags Include="-lwasi-emulated-process-clocks"/> - <_WasiLinkFlags Include="-lwasi-emulated-signal"/> - <_WasiLinkFlags Include="-lwasi-emulated-mman"/> + <_WasiLinkFlags Include="-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> From 307c7a7982299b8105dd71f25d82081c283828e2 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 22:20:04 +0100 Subject: [PATCH 044/116] wip --- src/mono/sample/wasi/console/Program.cs | 15 +++------------ src/mono/wasi/runtime/driver.c | 8 +++++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/mono/sample/wasi/console/Program.cs b/src/mono/sample/wasi/console/Program.cs index 47b5c3a3e0218..ba9120658bab8 100644 --- a/src/mono/sample/wasi/console/Program.cs +++ b/src/mono/sample/wasi/console/Program.cs @@ -6,18 +6,9 @@ public class Test { - public static int Main(string[] args) + public static int Main() { - try{ - Console.WriteLine("Hello World!"); - for (int i = 0; i < args.Length; i++) { - Console.WriteLine($"args[{i}] = {args[i]}"); - } - return 0; - } - catch(Exception){ - //TODOWASI - return 2; - } + Console.WriteLine("Hello World!"); + return 0; } } diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 96406b980480a..34322517f273a 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -677,9 +677,15 @@ int main() { if (out_exc) { mono_print_unhandled_exception(out_exc); + printf("Fail"); exit(1); } if(out_res) - return mono_unbox_int (out_res); + { + int r= mono_unbox_int (out_res); + printf("OK %d", r); + return r; + } + printf("OK void"); return 0; } From d9f2dd2f1c9c3dcb513ca448c43769db2f681445 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 14 Nov 2022 23:05:38 +0100 Subject: [PATCH 045/116] hello world --- src/mono/sample/wasi/console/Program.cs | 2 ++ src/mono/wasi/runtime/driver.c | 3 --- src/native/libs/Common/pal_utilities.h | 2 ++ src/native/libs/System.Native/pal_console.c | 8 ++++---- src/native/libs/System.Native/pal_io.c | 18 ++++++++++++------ 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/mono/sample/wasi/console/Program.cs b/src/mono/sample/wasi/console/Program.cs index ba9120658bab8..c65033a418ebb 100644 --- a/src/mono/sample/wasi/console/Program.cs +++ b/src/mono/sample/wasi/console/Program.cs @@ -8,7 +8,9 @@ public class Test { public static int Main() { + Console.WriteLine(""); Console.WriteLine("Hello World!"); + Console.WriteLine(""); return 0; } } diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index 34322517f273a..c5a386bbe19b6 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -677,15 +677,12 @@ int main() { if (out_exc) { mono_print_unhandled_exception(out_exc); - printf("Fail"); exit(1); } if(out_res) { int r= mono_unbox_int (out_res); - printf("OK %d", r); return r; } - printf("OK void"); return 0; } diff --git a/src/native/libs/Common/pal_utilities.h b/src/native/libs/Common/pal_utilities.h index d517974c9fcf3..5f4725dfefc65 100644 --- a/src/native/libs/Common/pal_utilities.h +++ b/src/native/libs/Common/pal_utilities.h @@ -83,7 +83,9 @@ inline static int ToFileDescriptorUnchecked(intptr_t fd) */ inline static int ToFileDescriptor(intptr_t fd) { +#if !TARGET_WASI assert(0 <= fd && fd < sysconf(_SC_OPEN_MAX)); +#endif return ToFileDescriptorUnchecked(fd); } diff --git a/src/native/libs/System.Native/pal_console.c b/src/native/libs/System.Native/pal_console.c index 89fc6719d86f8..613a2dd8b4501 100644 --- a/src/native/libs/System.Native/pal_console.c +++ b/src/native/libs/System.Native/pal_console.c @@ -510,8 +510,8 @@ int32_t SystemNative_SetWindowSize(WinSize* windowSize) int32_t SystemNative_IsATty(intptr_t fd) { - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; + // the same + return isatty(ToFileDescriptor(fd)); } void SystemNative_SetKeypadXmit(const char* terminfoString) @@ -567,8 +567,8 @@ int32_t SystemNative_SetSignalForBreak(int32_t signalForBreak) int32_t SystemNative_InitializeTerminalAndSignalHandling(void) { - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; + // No termios and signals on WASI + return 1; } #endif /* TARGET_WASI */ diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 2e9ba125bbd1e..ffc4965b43a86 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -1905,8 +1905,8 @@ int32_t SystemNative_Close(intptr_t fd) intptr_t SystemNative_Dup(intptr_t oldfd) { - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; + // https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-dup + return oldfd; } int32_t SystemNative_Unlink(const char* path) @@ -2171,8 +2171,8 @@ void SystemNative_Sync(void) int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize) { - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; + // the same + return Common_Write(fd, buffer, bufferSize); } int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t sourceLength) @@ -2237,14 +2237,20 @@ int32_t SystemNative_FChflags(intptr_t fd, uint32_t flags) int32_t SystemNative_LChflagsCanSetHiddenFlag(void) { - printf ("TODOWASI %s\n", __FUNCTION__); +#if HAVE_LCHFLAGS + return SystemNative_CanGetHiddenFlag(); +#else return false; +#endif } int32_t SystemNative_CanGetHiddenFlag(void) { - printf ("TODOWASI %s\n", __FUNCTION__); +#if HAVE_STAT_FLAGS && defined(UF_HIDDEN) + return true; +#else return false; +#endif } int32_t SystemNative_ReadProcessStatusInfo(pid_t pid, ProcessStatus* processStatus) From 76efd0f29f890e453c4c021aa98f464d46d8705d Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 09:12:59 +0100 Subject: [PATCH 046/116] fix --- src/native/libs/Common/pal_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/Common/pal_utilities.h b/src/native/libs/Common/pal_utilities.h index 5f4725dfefc65..babb42bc4cecc 100644 --- a/src/native/libs/Common/pal_utilities.h +++ b/src/native/libs/Common/pal_utilities.h @@ -83,7 +83,7 @@ inline static int ToFileDescriptorUnchecked(intptr_t fd) */ inline static int ToFileDescriptor(intptr_t fd) { -#if !TARGET_WASI +#ifndef TARGET_WASI assert(0 <= fd && fd < sysconf(_SC_OPEN_MAX)); #endif From 7bbd5eee5f34406cd0ddbba96e96ae6fa6252696 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 10:58:18 +0100 Subject: [PATCH 047/116] new RID: wasi-wasm - msbuild: TargetsWasi, mono.wasiruntime subset - differentiate wasm on Browser from wasm on Wasi, renamed IsBrowserProject - build shell files - initial CMake files - CI pipeline platform Wasi_wasm - OperatingSystem.OSPlatformName ="Wasi" - OperatingSystem.IsWasi() --- Directory.Build.props | 4 +++- eng/Subsets.props | 10 ++++++++-- eng/build.ps1 | 16 +++++++++++++-- eng/build.sh | 10 ++++++++-- eng/native/build-commons.sh | 2 +- eng/native/configurecompiler.cmake | 6 +++++- eng/native/configureplatform.cmake | 11 ++++++++++ eng/native/gen-buildsys.sh | 4 +++- eng/native/init-distro-rid.sh | 11 ++++++++-- eng/pipelines/common/platform-matrix.yml | 6 +++--- .../libraries/helix-queues-setup.yml | 6 +++--- eng/pipelines/mono/templates/build-job.yml | 5 +++++ eng/pipelines/runtime-official.yml | 1 + eng/testing/tests.wasm.targets | 12 +++++------ eng/versioning.targets | 1 + .../src/System/Environment.NativeAot.cs | 2 +- src/coreclr/scripts/coreclr_arguments.py | 2 +- .../src/runtime.compatibility.json | 11 ++++++++++ .../src/runtime.json | 10 ++++++++++ .../src/runtimeGroups.props | 5 +++++ src/libraries/OSGroups.json | 2 ++ .../System.Private.CoreLib.Shared.projitems | 1 + .../src/System/OperatingSystem.cs | 13 ++++++++++++ .../System.Runtime/ref/System.Runtime.cs | 1 + src/mono/CMakeLists.txt | 5 +++++ .../System.Private.CoreLib.csproj | 6 +++++- src/mono/mono/component/debugger-agent.c | 2 +- src/mono/mono/component/debugger.c | 2 +- src/mono/mono/metadata/profiler.c | 4 ++-- src/mono/mono/mini/CMakeLists.txt | 20 +++++++++---------- src/mono/mono/profiler/CMakeLists.txt | 2 +- src/mono/mono/profiler/browser.c | 4 ++-- src/mono/wasi/wasi.proj | 2 ++ .../Wasm.Build.Tests/Wasm.Build.Tests.csproj | 2 +- src/mono/wasm/build/WasmApp.targets | 10 +++++----- .../Wasm.Debugger.Tests.csproj | 2 +- .../wasm/debugger/tests/Directory.Build.props | 2 +- src/native/libs/build-native.cmd | 3 ++- src/native/libs/build-native.sh | 11 ++++++---- .../XUnitWrapperGenerator/TestPlatforms.cs | 3 ++- .../XUnitWrapperGenerator.cs | 1 + .../wasm-test-runner/WasmTestRunner.proj | 2 +- src/tests/build.sh | 2 +- 43 files changed, 177 insertions(+), 60 deletions(-) create mode 100644 src/mono/wasi/wasi.proj diff --git a/Directory.Build.props b/Directory.Build.props index 35e506f1ebaa5..1e62178294698 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -157,6 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser + <_portableOS Condition="'$(_runtimeOS)' == 'Wasi'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -217,6 +218,7 @@ true true true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index 9e666f71fe0a6..ed775e3daf0dd 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,6 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -139,7 +140,8 @@ - + + @@ -343,7 +345,7 @@ - + @@ -412,6 +414,10 @@ + + + + diff --git a/eng/build.ps1 b/eng/build.ps1 index e7ab6609e8e75..88b2067126513 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","Wasi")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, Wasi or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,24 @@ if ($os -eq "Browser") { } } +if ($os -eq "Wasi") { + # override default arch for Wasi, we only support wasm + $arch = "wasm" + + if ($msbuild -eq $True) { + Write-Error "Using the -msbuild option isn't supported when building for Wasi on Windows, we need need ninja for WASI-SDK." + exit 1 + } +} + foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" + } elseif ($os -eq "Wasi") { + $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" } diff --git a/eng/build.sh b/eng/build.sh index 97fee9151c3e4..2033865d3dcb0 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -280,13 +280,15 @@ while [[ $# > 0 ]]; do os="Android" ;; browser) os="Browser" ;; + wasi) + os="Wasi" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." exit 1 ;; esac @@ -505,6 +507,10 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi +if [[ "$os" == "Wasi" && "$arch" != "wasm" ]]; then + # override default arch for Browser, we only support wasm + arch=wasm +fi initDistroRid $os $arch $crossBuild $portableBuild diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index ae0761c84a1af..fc4bfd4a727a2 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -163,7 +163,7 @@ build_native() popd else cmake_command=cmake - if [[ "$build_arch" == "wasm" ]]; then + if [[ "$build_arch" == "wasm" && "$__TargetOS" == "Browser" ]]; then cmake_command="emcmake cmake" echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c7cb47bfcbb56..27a5ea048cdc3 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -543,7 +543,11 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_ILLUMOS>) endif() endif() -else(CLR_CMAKE_TARGET_UNIX) +elseif(CLR_CMAKE_TARGET_WASI) + add_compile_definitions($<$>>:TARGET_WASI>) +elseif(CLR_CMAKE_TARGET_BROWSER) + add_compile_definitions($<$>>:TARGET_BROWSER>) +else() add_compile_definitions($<$>>:TARGET_WINDOWS>) endif(CLR_CMAKE_TARGET_UNIX) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 506211704068a..c849c592174af 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -214,6 +214,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten) set(CLR_CMAKE_HOST_BROWSER 1) endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_HOST_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + #-------------------------------------------- # This repo builds two set of binaries # 1. binaries which execute on target arch machine @@ -263,6 +267,9 @@ elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) elseif(CLR_CMAKE_HOST_BROWSER) set(CLR_CMAKE_HOST_ARCH_WASM 1) set(CLR_CMAKE_HOST_ARCH "wasm") +elseif(CLR_CMAKE_HOST_WASI) + set(CLR_CMAKE_HOST_ARCH_WASM 1) + set(CLR_CMAKE_HOST_ARCH "wasm") elseif(CLR_CMAKE_HOST_UNIX_MIPS64) set(CLR_CMAKE_HOST_ARCH_MIPS64 1) set(CLR_CMAKE_HOST_ARCH "mips64") @@ -410,6 +417,10 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) set(CLR_CMAKE_TARGET_BROWSER 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) +if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + set(CLR_CMAKE_TARGET_WASI 1) +endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) + if(CLR_CMAKE_TARGET_UNIX) if(CLR_CMAKE_TARGET_ARCH STREQUAL x64) set(CLR_CMAKE_TARGET_UNIX_AMD64 1) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index c3bf9adbbef53..9f371a68f0bae 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -92,8 +92,10 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then cmake_command="$SCAN_BUILD_COMMAND $cmake_command" fi -if [[ "$host_arch" == "wasm" ]]; then +if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" +elif [[ "$host_arch" == "wasm" && "$2" =~ "-Wasi-" ]]; then + true fi # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 75012240633da..ab5d9c2ff6561 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -148,8 +148,13 @@ initDistroRidGlobal() initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}" if [ "$buildArch" = "wasm" ]; then - __DistroRid=browser-wasm - export __DistroRid + if [ "$targetOs" = "Browser" ]; then + __DistroRid=browser-wasm + export __DistroRid + elif [ "$targetOs" = "Wasi" ]; then + __DistroRid=wasi-wasm + export __DistroRid + fi fi if [ -z "${__DistroRid}" ]; then @@ -186,6 +191,8 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" + elif [ "$targetOs" = "Wasi" ]; then + distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" elif [ "$targetOs" = "illumos" ]; then diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index b3076886cdf57..bafab38c125d6 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -374,7 +374,7 @@ jobs: crossBuild: true ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly +# Browser WebAssembly - ${{ if containsValue(parameters.platforms, 'Browser_wasm') }}: - template: xplat-setup.yml @@ -395,7 +395,7 @@ jobs: buildConfig: ${{ parameters.buildConfig }} ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly Linux Firefox +# Browser WebAssembly Linux Firefox - ${{ if containsValue(parameters.platforms, 'Browser_wasm_firefox') }}: - template: xplat-setup.yml @@ -416,7 +416,7 @@ jobs: buildConfig: ${{ parameters.buildConfig }} ${{ insert }}: ${{ parameters.jobParameters }} -# WebAssembly on Windows +# Browser WebAssembly on Windows - ${{ if containsValue(parameters.platforms, 'Browser_wasm_win') }}: - template: xplat-setup.yml diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index 38170d7dc9fd1..2253a0bb55d3a 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -189,15 +189,15 @@ jobs: # TODO: Uncomment once there is HW deployed to service Win11 ARM64 queue # - Windows.11.Arm64.Open - # WebAssembly + # Browser WebAssembly - ${{ if eq(parameters.platform, 'Browser_wasm') }}: - Ubuntu.1804.Amd64.Open - # WebAssembly Firefox + # Browser WebAssembly Firefox - ${{ if eq(parameters.platform, 'Browser_wasm_firefox') }}: - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly - # WebAssembly windows + # Browser WebAssembly windows - ${{ if eq(parameters.platform, 'Browser_wasm_win') }}: - (Windows.Amd64.Server2022.Open)windows.amd64.server2022.open@mcr.microsoft.com/dotnet-buildtools/prereqs:windowsservercore-ltsc2022-helix-webassembly diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index 63d439c436ebc..67cae820fcef8 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -101,6 +101,11 @@ jobs: value: wasm - name: osOverride value: '-os Browser' + - ${{ if eq(parameters.osGroup, 'Wasi') }}: + - name: archType + value: wasm + - name: osOverride + value: '-os Wasi' - ${{ if and(eq(parameters.osGroup, 'Linux'), not(eq(parameters.archType, 'x64'))) }}: name: llvmCxxAbi value: /p:MonoLLVMUseCxx11Abi=true diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index c736da33bc164..e52dd99a5ca23 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -127,6 +127,7 @@ extends: - Linux_arm64 - Linux_musl_x64 - Browser_wasm + - Wasi_wasm - Linux_bionic_arm64 - Linux_bionic_x64 # - Linux_musl_arm diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index d1a4c93d0418a..8fb430740b4da 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -1,7 +1,7 @@ - true + true true false $(BundleTestAppTargets);BundleTestWasmApp @@ -40,7 +40,7 @@ + Condition="'$(InstallChromeForTests)' == 'true' and ('$(ContinuousIntegrationBuild)' != 'true' or '$(IsBrowserProject)' != 'true')" /> @@ -138,9 +138,9 @@ Condition="'$(BuildAOTTestsOn)' == 'local'" /> - - WasmTriggerPublishApp - $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix + + WasmTriggerPublishApp + $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix $(WasmAppHostDir)/WasmAppHost - + true diff --git a/eng/versioning.targets b/eng/versioning.targets index fb3e315a6935c..fa1b63973d005 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,6 +86,7 @@ diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs index 81bb1f8231af6..56b2268504193 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs @@ -58,7 +58,7 @@ internal static void FailFast(string message, Exception exception, string _ /*er internal static void ShutdownCore() { -#if !TARGET_WASM // WASMTODO Be careful what happens here as if the code has called emscripten_set_main_loop then the main loop method will normally be called repeatedly after this method +#if !TARGET_BROWSER // WASMTODO Be careful what happens here as if the code has called emscripten_set_main_loop then the main loop method will normally be called repeatedly after this method AppContext.OnProcessExit(); #endif } diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py index a568bc9e78e71..db8fdb1d132ba 100644 --- a/src/coreclr/scripts/coreclr_arguments.py +++ b/src/coreclr/scripts/coreclr_arguments.py @@ -65,7 +65,7 @@ def __init__(self, self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "wasm"] self.valid_build_types = ["Debug", "Checked", "Release"] - self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android"] + self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "Wasi"] self.__initialize__(args) diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json index aae2543ec5ead..a1b755d470d6b 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.compatibility.json @@ -3835,6 +3835,17 @@ "any", "base" ], + "wasi": [ + "wasi", + "any", + "base" + ], + "wasi-wasm": [ + "wasi-wasm", + "wasi", + "any", + "base" + ], "centos": [ "centos", "rhel", diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json index 0e981e704bc1f..928498570017e 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json @@ -1022,6 +1022,16 @@ "browser" ] }, + "wasi": { + "#import": [ + "any" + ] + }, + "wasi-wasm": { + "#import": [ + "wasi" + ] + }, "centos": { "#import": [ "rhel" diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props index 3a0135e7cc15a..912fe7693c438 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props +++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtimeGroups.props @@ -45,6 +45,11 @@ wasm + + any + wasm + + ios x64;arm64 diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index df367e07b744e..6bff22611c456 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,6 +4,8 @@ }, "Browser" : { }, + "Wasi" : { + }, "Linux": { "#import": [ "Unix" diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index b368c8675292c..f1070474198a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -37,6 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index deb0b107eb5cf..6fc2f2257fe7b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -12,6 +12,8 @@ public sealed class OperatingSystem : ISerializable, ICloneable private const string OSPlatformName = #if TARGET_BROWSER "BROWSER" +#elif TARGET_WASI + "WASI" #elif TARGET_WINDOWS "WINDOWS" #elif TARGET_OSX @@ -148,6 +150,17 @@ public static bool IsBrowser() => false; #endif + /// + /// Indicates whether the current application is running as WASI. + /// + [NonVersionable] + public static bool IsWasi() => +#if TARGET_WASI + true; +#else + false; +#endif + /// /// Indicates whether the current application is running on Linux. /// diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index c26b436f41097..0a3275c5ea4ad 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,6 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } + public static bool IsWasi() { throw null; } public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 90bfcd924a494..3854e1a28186d 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -358,6 +358,11 @@ if(NOT "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") endif() +if(HOST_BROWSER OR HOST_WASI) + # CMAKE_SYSTEM_PROCESSOR is set to x86 by emscripten + set(CMAKE_SYSTEM_PROCESSOR "wasm") +endif() + # Unify naming if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARMV7") set(CMAKE_SYSTEM_PROCESSOR "arm") diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index e1a6a89baec33..b748e2c49351e 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -85,7 +85,11 @@ AnyCPU - $(DefineConstants);TARGET_WASM + $(DefineConstants);TARGET_BROWSER + + + AnyCPU + $(DefineConstants);TARGET_WASI diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 0d155aed44e2c..4a80ea28abe99 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -7306,7 +7306,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) g_free (req); return err; } -#if defined(TARGET_WASM) && !defined(HOST_WASI) +#if defined(HOST_BROWSER) int isBPOnManagedCode = 0; SingleStepReq *ss_req = req->info; if (ss_req && ss_req->bps) { diff --git a/src/mono/mono/component/debugger.c b/src/mono/mono/component/debugger.c index f6255d4c85d9a..9f4931b031c2e 100644 --- a/src/mono/mono/component/debugger.c +++ b/src/mono/mono/component/debugger.c @@ -28,7 +28,7 @@ MonoComponentDebugger * mono_component_debugger_init (void) { debugger_agent_add_function_pointers (&fn_table); -#if defined(TARGET_WASM) && !defined(HOST_WASI) +#if defined(HOST_BROWSER) mini_wasm_debugger_add_function_pointers (&fn_table); #endif #if defined(HOST_WASI) diff --git a/src/mono/mono/metadata/profiler.c b/src/mono/mono/metadata/profiler.c index d632fc3b6f62e..0a76a5dace43e 100644 --- a/src/mono/mono/metadata/profiler.c +++ b/src/mono/mono/metadata/profiler.c @@ -22,7 +22,7 @@ typedef void (*MonoProfilerInitializer) (const char *); #define OLD_INITIALIZER_NAME "mono_profiler_startup" #define NEW_INITIALIZER_NAME "mono_profiler_init" -#if defined(TARGET_WASM) && defined(MONO_CROSS_COMPILE) +#if defined(TARGET_BROWSER) && defined(MONO_CROSS_COMPILE) MONO_API void mono_profiler_init_browser (const char *desc); #endif @@ -178,7 +178,7 @@ mono_profiler_load (const char *desc) mname = g_strdup (desc); } -#if defined(TARGET_WASM) && defined(MONO_CROSS_COMPILE) +#if defined(TARGET_BROWSER) && defined(MONO_CROSS_COMPILE) // this code could be running as part of mono-aot-cross.exe // in case of WASM we staticaly link in the browser.c profiler plugin if(strcmp (mname, "browser") == 0) { diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index c68af8beb34ca..fb45b60ed6f42 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -454,16 +454,16 @@ if(NOT DISABLE_SHARED_LIBS) endif() endif() -if(HOST_WASM AND NOT HOST_WASI) -# Add two static libs containing llvm-runtime.cpp compiled for JS based/WASM EH -# This is the only source file which contains a c++ throw or catch -add_library(mono-wasm-eh-js STATIC llvm-runtime.cpp) -target_link_libraries (mono-wasm-eh-js PRIVATE monoapi) -install(TARGETS mono-wasm-eh-js LIBRARY) -add_library(mono-wasm-eh-wasm STATIC llvm-runtime.cpp) -target_link_libraries (mono-wasm-eh-wasm PRIVATE monoapi) -set_target_properties(mono-wasm-eh-wasm PROPERTIES COMPILE_FLAGS "-fwasm-exceptions") -install(TARGETS mono-wasm-eh-wasm LIBRARY) +if(HOST_BROWSER) + # Add two static libs containing llvm-runtime.cpp compiled for JS based/WASM EH + # This is the only source file which contains a c++ throw or catch + add_library(mono-wasm-eh-js STATIC llvm-runtime.cpp) + target_link_libraries (mono-wasm-eh-js PRIVATE monoapi) + install(TARGETS mono-wasm-eh-js LIBRARY) + add_library(mono-wasm-eh-wasm STATIC llvm-runtime.cpp) + target_link_libraries (mono-wasm-eh-wasm PRIVATE monoapi) + set_target_properties(mono-wasm-eh-wasm PROPERTIES COMPILE_FLAGS "-fwasm-exceptions") + install(TARGETS mono-wasm-eh-wasm LIBRARY) endif() find_package(Python3 COMPONENTS Interpreter) diff --git a/src/mono/mono/profiler/CMakeLists.txt b/src/mono/mono/profiler/CMakeLists.txt index cd5bf36dfa67d..58589a2b307c7 100644 --- a/src/mono/mono/profiler/CMakeLists.txt +++ b/src/mono/mono/profiler/CMakeLists.txt @@ -36,7 +36,7 @@ if(NOT DISABLE_LIBS) install(TARGETS mono-profiler-aot-static LIBRARY) endif() - if(HOST_WASM) + if(HOST_BROWSER) add_library(mono-profiler-browser-static STATIC browser.c) target_link_libraries(mono-profiler-browser-static monoapi) set_target_properties(mono-profiler-browser-static PROPERTIES OUTPUT_NAME mono-profiler-browser) diff --git a/src/mono/mono/profiler/browser.c b/src/mono/mono/profiler/browser.c index 8140b03b535d8..d25f0ecc4c9fa 100644 --- a/src/mono/mono/profiler/browser.c +++ b/src/mono/mono/profiler/browser.c @@ -7,7 +7,7 @@ #include -#ifdef TARGET_WASM +#ifdef HOST_BROWSER #include #include @@ -104,4 +104,4 @@ mono_profiler_init_browser (const char *desc) #endif /* HOST_WASM */ } -#endif /* TARGET_WASM */ +#endif /* HOST_BROWSER */ diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj new file mode 100644 index 0000000000000..7053b6b952e0e --- /dev/null +++ b/src/mono/wasi/wasi.proj @@ -0,0 +1,2 @@ + + diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index a213bd210a98a..e47be6431fba8 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -16,7 +16,7 @@ true - false + false true diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index b4ab2787d2173..e09aff8990502 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -97,7 +97,7 @@ <_BeforeWasmBuildAppDependsOn /> - true + true Build Publish @@ -121,8 +121,8 @@ - - + + @@ -158,7 +158,7 @@ + Condition="'$(IsBrowserProject)' == 'true' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'"> + Condition="'$(IsBrowserProject)' == 'true' and '$(WasmBuildingForNestedPublish)' == '' and '$(WasmBuildOnlyAfterPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'" /> false false false - false + false true true xunit diff --git a/src/mono/wasm/debugger/tests/Directory.Build.props b/src/mono/wasm/debugger/tests/Directory.Build.props index b0249e49bbbf8..cd1f27e2818c0 100644 --- a/src/mono/wasm/debugger/tests/Directory.Build.props +++ b/src/mono/wasm/debugger/tests/Directory.Build.props @@ -4,7 +4,7 @@ $(AspNetCoreAppCurrent) Library - true + true Debug true diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index ae97ff4e3262f..7d564314d777e 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,6 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) +if /i [%1] == [Wasi] ( set __TargetOS=Wasi&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) @@ -94,7 +95,7 @@ popd set __generatorArgs= if [%__Ninja%] == [1] ( set __generatorArgs= -) else if [%__BuildArch%] == [wasm] ( +) else if [%__TargetOS%] == [Browser] ( set __generatorArgs= ) else ( set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065 diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index f896736cfd7b1..add5288fbeabf 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -42,11 +42,14 @@ __VerboseBuild=false source "$__RepoRootDir"/eng/native/build-commons.sh # Set cross build - -if [[ "$__TargetArch" == wasm ]]; then +if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then - echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." - exit 1 + if [[ -d "$__RepoRootDir"/src/mono/wasm/emsdk/ ]]; then + export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + else + echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." + exit 1 + fi fi source "$EMSDK_PATH"/emsdk_env.sh diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index a4f11204e48ba..f6f0c00812f42 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,7 +20,8 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser, + Wasi = 2048, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | Wasi, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index adcfa65fabe09..a76025db7d727 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -709,6 +709,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, + "wasi" => Xunit.TestPlatforms.Wasi, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, diff --git a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj index c653f98c47bff..b646a764139bd 100644 --- a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj +++ b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj @@ -12,7 +12,7 @@ $(MSBuildThisFileDirectory)\obj\$(Configuration)\wasm $(TestBinDir)/WasmApp/ 99.0 - true + true true $(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll diff --git a/src/tests/build.sh b/src/tests/build.sh index c6f30ccf3670c..319b5958a99ca 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "Wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From 9f673b5da13152204366548a02911f46efcee10f Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 12:54:34 +0100 Subject: [PATCH 048/116] fix --- src/mono/mono/mini/CMakeLists.txt | 2 +- src/mono/mono/profiler/browser.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index fb45b60ed6f42..9d2c9aefdd3a1 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -325,7 +325,7 @@ else() set(llvm_runtime_sources) endif() -if(TARGET_WASM AND MONO_CROSS_COMPILE) +if(TARGET_BROWSER AND MONO_CROSS_COMPILE) set(profiler_sources ../profiler/browser.c) else() set(profiler_sources "") diff --git a/src/mono/mono/profiler/browser.c b/src/mono/mono/profiler/browser.c index d25f0ecc4c9fa..2882f0188ba59 100644 --- a/src/mono/mono/profiler/browser.c +++ b/src/mono/mono/profiler/browser.c @@ -7,8 +7,6 @@ #include -#ifdef HOST_BROWSER - #include #include #include @@ -103,5 +101,3 @@ mono_profiler_init_browser (const char *desc) mono_profiler_set_method_exception_leave_callback (handle, method_exc_leave); #endif /* HOST_WASM */ } - -#endif /* HOST_BROWSER */ From be7d9d1969827068c2264daca2d5269d5e5d07de Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 13:12:18 +0100 Subject: [PATCH 049/116] feedback --- src/mono/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 3854e1a28186d..85a0f819da4d1 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -358,7 +358,7 @@ if(NOT "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") endif() -if(HOST_BROWSER OR HOST_WASI) +if(HOST_BROWSER) # CMAKE_SYSTEM_PROCESSOR is set to x86 by emscripten set(CMAKE_SYSTEM_PROCESSOR "wasm") endif() From db527c5d2c24da10bbcabbcf03fd5055e9c8013d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 13:36:12 +0100 Subject: [PATCH 050/116] uper case WASI feedback --- Directory.Build.props | 6 +++--- eng/Subsets.props | 6 +++--- eng/build.ps1 | 12 ++++++------ eng/build.sh | 8 ++++---- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 4 ++-- .../common/templates/wasm-library-tests.yml | 2 +- eng/pipelines/mono/templates/build-job.yml | 4 ++-- eng/pipelines/runtime-official.yml | 2 +- eng/versioning.targets | 2 +- src/libraries/OSGroups.json | 2 +- .../src/System.Private.CoreLib.Shared.projitems | 2 +- .../src/System/OperatingSystem.cs | 2 +- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- .../System.Private.CoreLib.csproj | 2 +- src/native/libs/build-native.cmd | 2 +- .../Common/XUnitWrapperGenerator/TestPlatforms.cs | 4 ++-- .../XUnitWrapperGenerator/XUnitWrapperGenerator.cs | 2 +- src/tests/build.sh | 2 +- 19 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1e62178294698..3efb7dff91299 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -157,7 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser - <_portableOS Condition="'$(_runtimeOS)' == 'Wasi'">wasi + <_portableOS Condition="'$(_runtimeOS)' == 'WASI'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -218,7 +218,7 @@ true true true - true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index ed775e3daf0dd..eba026e7fc935 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,7 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ - $(DefaultMonoSubsets)mono.wasiruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -141,7 +141,7 @@ - + @@ -345,7 +345,7 @@ - + diff --git a/eng/build.ps1 b/eng/build.ps1 index 88b2067126513..63e4039dec58d 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser","Wasi")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","WASI")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android, Wasi or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, WASI or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,12 @@ if ($os -eq "Browser") { } } -if ($os -eq "Wasi") { - # override default arch for Wasi, we only support wasm +if ($os -eq "WASI") { + # override default arch for WASI, we only support wasm $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for Wasi on Windows, we need need ninja for WASI-SDK." + Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need need ninja for WASI-SDK." exit 1 } } @@ -299,7 +299,7 @@ foreach ($config in $configuration) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" - } elseif ($os -eq "Wasi") { + } elseif ($os -eq "WASI") { $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" diff --git a/eng/build.sh b/eng/build.sh index 2033865d3dcb0..4a69651731035 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -281,14 +281,14 @@ while [[ $# > 0 ]]; do browser) os="Browser" ;; wasi) - os="Wasi" ;; + os="WASI" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, illumos and Solaris." exit 1 ;; esac @@ -507,7 +507,7 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi -if [[ "$os" == "Wasi" && "$arch" != "wasm" ]]; then +if [[ "$os" == "WASI" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 9f371a68f0bae..16c487760902b 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -94,7 +94,7 @@ fi if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" -elif [[ "$host_arch" == "wasm" && "$2" =~ "-Wasi-" ]]; then +elif [[ "$host_arch" == "wasm" && "$2" =~ "-WASI-" ]]; then true fi diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index ab5d9c2ff6561..18f2a714e57f1 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -151,7 +151,7 @@ initDistroRidGlobal() if [ "$targetOs" = "Browser" ]; then __DistroRid=browser-wasm export __DistroRid - elif [ "$targetOs" = "Wasi" ]; then + elif [ "$targetOs" = "WASI" ]; then __DistroRid=wasi-wasm export __DistroRid fi @@ -191,7 +191,7 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" - elif [ "$targetOs" = "Wasi" ]; then + elif [ "$targetOs" = "WASI" ]; then distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" diff --git a/eng/pipelines/common/templates/wasm-library-tests.yml b/eng/pipelines/common/templates/wasm-library-tests.yml index 6037b4529ecaa..caf4a09b31eb1 100644 --- a/eng/pipelines/common/templates/wasm-library-tests.yml +++ b/eng/pipelines/common/templates/wasm-library-tests.yml @@ -79,7 +79,7 @@ jobs: make -C src/mono/wasi provision-deps all && make -C src/mono/wasi/sample/console run name: build_wasi - displayName: Build Wasi, and run a sample + displayName: Build WASI, and run a sample creator: dotnet-bot testRunNamePrefixSuffix: Mono_$(_BuildConfig) diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index 67cae820fcef8..305e8f55d9e55 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -101,11 +101,11 @@ jobs: value: wasm - name: osOverride value: '-os Browser' - - ${{ if eq(parameters.osGroup, 'Wasi') }}: + - ${{ if eq(parameters.osGroup, 'WASI') }}: - name: archType value: wasm - name: osOverride - value: '-os Wasi' + value: '-os WASI' - ${{ if and(eq(parameters.osGroup, 'Linux'), not(eq(parameters.archType, 'x64'))) }}: name: llvmCxxAbi value: /p:MonoLLVMUseCxx11Abi=true diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index e52dd99a5ca23..69b40175f77f5 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -127,7 +127,7 @@ extends: - Linux_arm64 - Linux_musl_x64 - Browser_wasm - - Wasi_wasm + - WASI_wasm - Linux_bionic_arm64 - Linux_bionic_x64 # - Linux_musl_arm diff --git a/eng/versioning.targets b/eng/versioning.targets index fa1b63973d005..7189f4c9c7e40 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,7 +86,7 @@ diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index 6bff22611c456..df35243993b40 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,7 +4,7 @@ }, "Browser" : { }, - "Wasi" : { + "WASI" : { }, "Linux": { "#import": [ diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index f1070474198a3..dfcd339f290a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -37,7 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 6fc2f2257fe7b..41318e5c71391 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -154,7 +154,7 @@ public static bool IsBrowser() => /// Indicates whether the current application is running as WASI. /// [NonVersionable] - public static bool IsWasi() => + public static bool IsWASI() => #if TARGET_WASI true; #else diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 0a3275c5ea4ad..e460cf4f2f090 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,7 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } - public static bool IsWasi() { throw null; } + public static bool IsWASI() { throw null; } public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index b748e2c49351e..23beee5417b57 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -87,7 +87,7 @@ AnyCPU $(DefineConstants);TARGET_BROWSER - + AnyCPU $(DefineConstants);TARGET_WASI diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index 7d564314d777e..5b28c787df3f9 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,7 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) -if /i [%1] == [Wasi] ( set __TargetOS=Wasi&&shift&goto Arg_Loop) +if /i [%1] == [WASI] ( set __TargetOS=WASI&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index f6f0c00812f42..6727b69fbad16 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,8 +20,8 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - Wasi = 2048, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | Wasi, + WASI = 2048, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | WASI, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index a76025db7d727..fb76e32d82daf 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -709,7 +709,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, - "wasi" => Xunit.TestPlatforms.Wasi, + "wasi" => Xunit.TestPlatforms.WASI, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, diff --git a/src/tests/build.sh b/src/tests/build.sh index 319b5958a99ca..266b2fe7c4415 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "Wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "WASI" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From a79a071d80a9861484fe5364a98664db5408c494 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 13:54:27 +0100 Subject: [PATCH 051/116] uper case WASI --- Directory.Build.props | 6 +- eng/Subsets.props | 6 +- eng/build.ps1 | 12 +-- eng/build.sh | 8 +- eng/native/configureplatform.cmake | 8 +- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 4 +- eng/pipelines/common/platform-matrix.yml | 8 +- .../common/templates/wasi-build-only.yml | 2 +- .../common/templates/wasm-library-tests.yml | 2 +- eng/pipelines/runtime-linker-tests.yml | 4 +- eng/pipelines/runtime-official.yml | 2 +- eng/pipelines/runtime.yml | 6 +- eng/versioning.targets | 2 +- src/libraries/OSGroups.json | 2 +- .../System.Console/src/System.Console.csproj | 8 +- .../src/System.IO.Compression.csproj | 4 +- .../src/System.IO.MemoryMappedFiles.csproj | 4 +- .../System.Linq/src/System.Linq.csproj | 4 +- .../src/System.Net.Http.csproj | 14 ++-- .../src/System.Net.Mail.csproj | 6 +- .../src/System.Net.NameResolution.csproj | 8 +- .../src/System.Net.Primitives.csproj | 6 +- .../src/System.Net.WebClient.csproj | 6 +- .../src/System.Net.WebProxy.csproj | 6 +- .../src/System.Net.WebSockets.Client.csproj | 4 +- .../src/System.Net.WebSockets.csproj | 4 +- .../System.Private.CoreLib.Shared.projitems | 22 +++--- .../src/System/OperatingSystem.cs | 2 +- ...em.Runtime.Serialization.Formatters.csproj | 2 +- .../System.Runtime/ref/System.Runtime.cs | 2 +- .../src/System.Security.Cryptography.csproj | 6 +- .../src/System.Text.Encodings.Web.csproj | 6 +- src/libraries/pretest.proj | 4 +- src/mono/CMakeLists.txt | 2 +- src/mono/Directory.Build.props | 10 +-- .../System.Private.CoreLib.csproj | 20 ++--- src/mono/mono.proj | 74 +++++++++---------- src/mono/sample/wasi/Directory.Build.props | 4 +- src/mono/sample/wasi/Directory.Build.targets | 10 +-- .../wasi/console/Wasi.Console.Sample.csproj | 4 +- src/mono/wasi/README.md | 6 +- src/mono/wasi/runtime/driver.c | 2 +- src/mono/wasi/wasi.proj | 68 ++++++++--------- src/native/libs/Common/pal_error_common.h | 14 ++-- src/native/libs/Common/pal_io_common.h | 4 +- src/native/libs/build-native.cmd | 2 +- src/native/libs/build-native.sh | 4 +- .../XUnitWrapperGenerator/TestPlatforms.cs | 4 +- .../XUnitWrapperGenerator.cs | 2 +- src/tests/build.sh | 2 +- 51 files changed, 212 insertions(+), 212 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1e62178294698..3efb7dff91299 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -157,7 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser - <_portableOS Condition="'$(_runtimeOS)' == 'Wasi'">wasi + <_portableOS Condition="'$(_runtimeOS)' == 'WASI'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -218,7 +218,7 @@ true true true - true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index ed775e3daf0dd..40c5e08b5e0ad 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,7 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ - $(DefaultMonoSubsets)mono.wasiruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -141,7 +141,7 @@ - + @@ -345,7 +345,7 @@ - + diff --git a/eng/build.ps1 b/eng/build.ps1 index 88b2067126513..63e4039dec58d 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser","Wasi")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","WASI")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android, Wasi or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, WASI or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,12 @@ if ($os -eq "Browser") { } } -if ($os -eq "Wasi") { - # override default arch for Wasi, we only support wasm +if ($os -eq "WASI") { + # override default arch for WASI, we only support wasm $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for Wasi on Windows, we need need ninja for WASI-SDK." + Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need need ninja for WASI-SDK." exit 1 } } @@ -299,7 +299,7 @@ foreach ($config in $configuration) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" - } elseif ($os -eq "Wasi") { + } elseif ($os -eq "WASI") { $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" diff --git a/eng/build.sh b/eng/build.sh index 2033865d3dcb0..4a69651731035 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -281,14 +281,14 @@ while [[ $# > 0 ]]; do browser) os="Browser" ;; wasi) - os="Wasi" ;; + os="WASI" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, illumos and Solaris." exit 1 ;; esac @@ -507,7 +507,7 @@ if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi -if [[ "$os" == "Wasi" && "$arch" != "wasm" ]]; then +if [[ "$os" == "WASI" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 2e10489fb370d..b064079402eb4 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -214,9 +214,9 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten) set(CLR_CMAKE_HOST_BROWSER 1) endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten) -if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +if(CLR_CMAKE_TARGET_OS STREQUAL WASI) set(CLR_CMAKE_HOST_WASI 1) -endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +endif(CLR_CMAKE_TARGET_OS STREQUAL WASI) #-------------------------------------------- # This repo builds two set of binaries @@ -417,9 +417,9 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) set(CLR_CMAKE_TARGET_BROWSER 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) -if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +if(CLR_CMAKE_TARGET_OS STREQUAL WASI) set(CLR_CMAKE_TARGET_WASI 1) -endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +endif(CLR_CMAKE_TARGET_OS STREQUAL WASI) if(CLR_CMAKE_TARGET_UNIX) if(CLR_CMAKE_TARGET_ARCH STREQUAL x64) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 9f371a68f0bae..16c487760902b 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -94,7 +94,7 @@ fi if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then cmake_command="emcmake $cmake_command" -elif [[ "$host_arch" == "wasm" && "$2" =~ "-Wasi-" ]]; then +elif [[ "$host_arch" == "wasm" && "$2" =~ "-WASI-" ]]; then true fi diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index ab5d9c2ff6561..18f2a714e57f1 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -151,7 +151,7 @@ initDistroRidGlobal() if [ "$targetOs" = "Browser" ]; then __DistroRid=browser-wasm export __DistroRid - elif [ "$targetOs" = "Wasi" ]; then + elif [ "$targetOs" = "WASI" ]; then __DistroRid=wasi-wasm export __DistroRid fi @@ -191,7 +191,7 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" - elif [ "$targetOs" = "Wasi" ]; then + elif [ "$targetOs" = "WASI" ]; then distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index a7a12c1a9d060..84c9036566d20 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -374,18 +374,18 @@ jobs: crossBuild: true ${{ insert }}: ${{ parameters.jobParameters }} -# Wasi WebAssembly +# WASI WebAssembly -- ${{ if containsValue(parameters.platforms, 'Wasi_wasm') }}: +- ${{ if containsValue(parameters.platforms, 'WASI_wasm') }}: - template: xplat-setup.yml parameters: jobTemplate: ${{ parameters.jobTemplate }} helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} variables: ${{ parameters.variables }} - osGroup: Wasi + osGroup: WASI archType: wasm targetRid: wasi-wasm - platform: Wasi_wasm + platform: WASI_wasm shouldContinueOnError: ${{ parameters.shouldContinueOnError }} container: Linux_x64 jobParameters: diff --git a/eng/pipelines/common/templates/wasi-build-only.yml b/eng/pipelines/common/templates/wasi-build-only.yml index 2edf9f3f9d214..e161b02b1270c 100644 --- a/eng/pipelines/common/templates/wasi-build-only.yml +++ b/eng/pipelines/common/templates/wasi-build-only.yml @@ -8,7 +8,7 @@ parameters: jobs: # -# Build for Wasi/wasm and test it +# Build for WASI/wasm and test it # - template: /eng/pipelines/common/platform-matrix.yml parameters: diff --git a/eng/pipelines/common/templates/wasm-library-tests.yml b/eng/pipelines/common/templates/wasm-library-tests.yml index a05ca0bf16681..8a00f96810962 100644 --- a/eng/pipelines/common/templates/wasm-library-tests.yml +++ b/eng/pipelines/common/templates/wasm-library-tests.yml @@ -1,6 +1,6 @@ parameters: alwaysRun: false - buildAndRunWasi: false + buildAndRunWASI: false extraBuildArgs: '' extraHelixArgs: '' isExtraPlatformsBuild: false diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 2ec7c74f1b396..249b3d184277b 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -106,14 +106,14 @@ extends: extraTestArgs: '/p:WasmBuildNative=false' # - # Build Release config vertical for Wasi-wasm + # Build Release config vertical for WASI-wasm # - template: /eng/pipelines/common/platform-matrix.yml parameters: jobTemplate: /eng/pipelines/common/global-build-job.yml buildConfig: release platforms: - - Wasi_wasm + - WASI_wasm jobParameters: testGroup: innerloop timeoutInMinutes: 120 diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index e52dd99a5ca23..69b40175f77f5 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -127,7 +127,7 @@ extends: - Linux_arm64 - Linux_musl_x64 - Browser_wasm - - Wasi_wasm + - WASI_wasm - Linux_bionic_arm64 - Linux_bionic_x64 # - Linux_musl_arm diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index f4d3c2472b916..31b055e810656 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -371,7 +371,7 @@ extends: parameters: platforms: - Browser_wasm - buildAndRunWasi: true + buildAndRunWASI: true alwaysRun: ${{ variables.isRollingBuild }} scenarios: - normal @@ -454,11 +454,11 @@ extends: extraBuildArgs: /p:WasmEnablePerfTracing=true alwaysRun: ${{ variables.isRollingBuild }} - # BUILD ONLY - Wasi/Wasm + # BUILD ONLY - WASI/Wasm - template: /eng/pipelines/common/templates/wasi-build-only.yml parameters: platforms: - - Wasi_wasm + - WASI_wasm extraBuildArgs: /p:WasmEnableThreads=true alwaysRun: ${{ variables.isRollingBuild }} diff --git a/eng/versioning.targets b/eng/versioning.targets index fa1b63973d005..7189f4c9c7e40 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,7 +86,7 @@ diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index 6bff22611c456..df35243993b40 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,7 +4,7 @@ }, "Browser" : { }, - "Wasi" : { + "WASI" : { }, "Linux": { "#import": [ diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 68ba75d4e5fbe..315ef75439537 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -1,14 +1,14 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole - + $(DefineConstants);TARGET_WASI @@ -159,7 +159,7 @@ Link="Common\System\IO\Win32Marshal.cs" /> - + diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 35d81f1850284..e0e9e1311419e 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) @@ -50,7 +50,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) @@ -80,7 +80,7 @@ - + - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true + true diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 780a473f282e4..e7e2f42090d56 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -20,7 +20,7 @@ $(DefineConstants);TARGET_MACCATALYST $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI $(MSBuildThisFileDirectory)ILLink\ @@ -28,7 +28,7 @@ - + @@ -160,7 +160,7 @@ Link="Common\System\Text\ValueStringBuilder.AppendSpanFormattable.cs" /> - + @@ -308,12 +308,12 @@ - + - + @@ -389,7 +389,7 @@ - + - + diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 12dc021efc05a..7d08f1051f61b 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -1,7 +1,7 @@  true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) @@ -78,12 +78,12 @@ Link="Common\System\HexConverter.cs" /> - + - + diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 1e567b1ec0934..9d2911cfca351 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Browser.txt + SR.SystemNetNameResolution_PlatformNotSupported + ExcludeApiList.PNSE.Browser.txt @@ -100,7 +100,7 @@ - + diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 0484a5a990bbd..5d281add66bf0 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -2,7 +2,7 @@ true false - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL @@ -113,7 +113,7 @@ - + @@ -144,7 +144,7 @@ - + true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetWebClient_PlatformNotSupported + SR.SystemNetWebClient_PlatformNotSupported - + diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index 7fd1104f3a853..a94f7720533a6 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -1,13 +1,13 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI - - + + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index 67e8c09e735c5..aa79943082caf 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -1,13 +1,13 @@ True - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER - + $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index 2e8b009d92d09..3cc29b0501e45 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -1,7 +1,7 @@ True - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) @@ -40,7 +40,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 7252f1f4260e0..03e331b07e095 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -12,7 +12,7 @@ enable true true - true + true true true true @@ -20,7 +20,7 @@ $(MSBuildThisFileDirectory)ILLink\ true true - true + true $(DefineConstants);BIGENDIAN @@ -37,7 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD @@ -2020,7 +2020,7 @@ - + Common\Interop\Unix\Interop.Errors.cs @@ -2269,7 +2269,7 @@ - + @@ -2278,7 +2278,7 @@ - + @@ -2312,7 +2312,7 @@ - + @@ -2416,7 +2416,7 @@ - + @@ -2429,11 +2429,11 @@ - + - + @@ -2451,7 +2451,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 6fc2f2257fe7b..41318e5c71391 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -154,7 +154,7 @@ public static bool IsBrowser() => /// Indicates whether the current application is running as WASI. /// [NonVersionable] - public static bool IsWasi() => + public static bool IsWASI() => #if TARGET_WASI true; #else diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index 84b937bfd1311..2744dbc8ca4c3 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android $(MSBuildThisFileDirectory)ILLink\ true diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 0a3275c5ea4ad..e460cf4f2f090 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,7 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } - public static bool IsWasi() { throw null; } + public static bool IsWASI() { throw null; } public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index 2fd07ad6d5311..f524328b7a1ee 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -2,7 +2,7 @@ true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) $(NoWarn);CA5350;CA5351;CA5379;CA5384;SYSLIB0026 $(NoWarn);CS0809 @@ -549,7 +549,7 @@ System\Security\Cryptography\X509Certificates\Asn1\PolicyInformationAsn.xml - + @@ -1836,7 +1836,7 @@ - + diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index b376e90cbbcff..18a26fa1e68b7 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Wasi;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-Wasi;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-WASI;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true @@ -18,9 +18,9 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI - $(NoWarn);CA1418 + $(NoWarn);CA1418 diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 8a2e1240c1449..b9ae3d483788a 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -26,14 +26,14 @@ - + + Condition="'$(TargetOS)' == 'WASI' and '$(ContinuousIntegrationBuild)' == 'true'" /> diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 36e626f7a672e..46e13cc954a93 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -743,7 +743,7 @@ elseif(GC_SUSPEND STREQUAL "default") # use preemptive elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") # use preemptive - elseif(TARGET_SYSTEM_NAME STREQUAL "Wasi") + elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") # use preemptive else() set(ENABLE_HYBRID_SUSPEND 1) diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index ef74df52c446a..404fa0ad70d6a 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -45,10 +45,10 @@ - - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) - $(ProvisionWasiSdkDir.Replace('\', '/')) - true + + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) + $(ProvisionWASISdkDir.Replace('\', '/')) + true @@ -60,7 +60,7 @@ true true true <_MonoUseLLVMPackage Condition="'$(MonoLLVMDir)' == '' and '$(MonoEnableLLVM)' == 'true'">true diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 91cc8204c03bc..3ff6a3964c00a 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -87,7 +87,7 @@ AnyCPU $(DefineConstants);TARGET_WASM - + AnyCPU $(DefineConstants);TARGET_WASI @@ -129,13 +129,13 @@ $(DefineConstants);MONO_FEATURE_SRE true - true - true + true + true true true - true - true - true + true + true + true true @@ -282,16 +282,16 @@ - + - + - + - + diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 6d760bb391257..8fec0470deb46 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -28,7 +28,7 @@ $(CoreClrLibName) $(LibPrefix)$(MonoSharedLibName)$(LibSuffix) $(LibPrefix)$(MonoLibName)$(StaticLibSuffix) - $(MonoStaticLibFileName) + $(MonoStaticLibFileName) $(MonoSharedLibFileName) mono-aot-cross$(ExeSuffix) mono-aot-cross.pdb @@ -43,13 +43,13 @@ true true true $([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross')) $([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'config.h')) true - true + true $(Compiler) clang <_CompilerTargetArch Condition="'$(RealTargetArchitecture)' == ''">$(Platform) @@ -65,7 +65,7 @@ coop - preemptive + preemptive hybrid @@ -73,7 +73,7 @@ true - true + true true true false @@ -84,12 +84,12 @@ true - + - + <_MonoCMakeArgs Include="-DENABLE_WERROR=1"/> @@ -102,7 +102,7 @@ - + @@ -167,31 +167,31 @@ - + - $(ProvisionWasiSdkDir) - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) - %(_VersionLines.Identity) - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz + $(ProvisionWASISdkDir) + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) + %(_VersionLines.Identity) + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASISdkVersion)/wasi-sdk-$(WASISdkVersion).0-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASISdkVersion)/wasi-sdk-$(WASISdkVersion).0-macos.tar.gz - - + - + @@ -199,11 +199,11 @@ - %(_ActualVersionLines.Identity) - %(_ExpectedVersionLines.Identity) + %(_ActualVersionLines.Identity) + %(_ExpectedVersionLines.Identity) + Condition="'$(ActualWASISdkVersion)' != '$(ExpectedWASISdkVersion)'" /> @@ -383,19 +383,19 @@ <_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" /> - + <_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages <_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads <_MonoMinimal Condition="'$(MonoWasmThreadsNoUser)' == 'true'">$(_MonoMinimal),wasm_user_threads - + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/> <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> - <_MonoCMakeArgs Condition="'$(TargetsWasi)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> + <_MonoCMakeArgs Condition="'$(TargetsWASI)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> <_MonoCMakeArgs Include="-DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm"/> <_MonoCFLAGS Include="-fexceptions"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> @@ -407,7 +407,7 @@ <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - + @@ -878,7 +878,7 @@ <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true'">$(MonoObjDir)out\bin\$(MonoFileName) <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName) <_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName) - <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true + <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWASI)' == 'true'">true <_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true diff --git a/src/mono/sample/wasi/Directory.Build.props b/src/mono/sample/wasi/Directory.Build.props index f2ecb0d30b5db..8d8abf392eb82 100644 --- a/src/mono/sample/wasi/Directory.Build.props +++ b/src/mono/sample/wasi/Directory.Build.props @@ -15,7 +15,7 @@ bin - false + false @@ -33,5 +33,5 @@ - + diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index af2168b3e3693..1674b52b8262f 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -1,6 +1,6 @@ - + true @@ -25,14 +25,14 @@ <_AOTFlag Condition="'$(RunAOTCompilation)' != ''">/p:RunAOTCompilation=$(RunAOTCompilation) <_WasmMainJSFileName>$([System.IO.Path]::GetFileName('$(WasmMainJSPath)')) - + - + - diff --git a/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj index 2cbc92e85f134..a51b1e5594622 100644 --- a/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj +++ b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj @@ -4,8 +4,8 @@ - <_SampleProject>Wasi.Console.Sample.csproj - <_SampleAssembly>Wasi.Console.Sample.dll + <_SampleProject>WASI.Console.Sample.csproj + <_SampleAssembly>WASI.Console.Sample.dll diff --git a/src/mono/wasi/README.md b/src/mono/wasi/README.md index 0a5a543d30665..8d20546f11da0 100644 --- a/src/mono/wasi/README.md +++ b/src/mono/wasi/README.md @@ -10,11 +10,11 @@ The mechanism for executing .NET code in a WASI runtime environment is equivalen on Linux: ```.sh -./build.sh -bl -os Wasi -subset mono+libs -c Debug +./build.sh -bl -os WASI -subset mono+libs -c Debug ``` or for just native rebuild ```.sh -./build.sh -bl -os Wasi -subset mono.runtime+libs.native+mono.wasiruntime -c Debug +./build.sh -bl -os WASI -subset mono.runtime+libs.native+mono.wasiruntime -c Debug ``` ### 3. Run it @@ -22,7 +22,7 @@ or for just native rebuild Finally, you can build and run the sample: ``` -./dotnet.sh build /p:TargetOS=Wasi /p:Configuration=Debug /t:RunSample src/mono/sample/wasi/console +./dotnet.sh build /p:TargetOS=WASI /p:Configuration=Debug /t:RunSample src/mono/sample/wasi/console ``` ### 4. Debug it diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index c5a386bbe19b6..e04fc11fe1d3e 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -669,7 +669,7 @@ int main() { mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); mono_wasm_load_runtime("", 0); - MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample"); + MonoAssembly* assembly = mono_wasm_assembly_load ("WASI.Console.Sample"); MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); MonoObject* out_exc; MonoObject* out_res; diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 6ea90f29e2e29..92b5b7affce44 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -13,15 +13,15 @@ false false $(ArtifactsObjDir)wasm - <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp - <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp - <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp + <_WASIDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp + <_WASICompileRspPath>$(NativeBinDir)src\wasi-compile.rsp + <_WASILinkRspPath>$(NativeBinDir)src\wasi-link.rsp false - + @@ -76,12 +76,12 @@ - + @@ -92,24 +92,24 @@ - <_WasiFlags Include="@(_WasiCommonFlags)" /> - - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> - <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> - <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> - <_WasiLinkFlags Include="-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> + <_WASIFlags Include="@(_WASICommonFlags)" /> + + <_WASICompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_WASICompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_WASICompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> + <_WASICompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> + <_WASICompileFlags Include="-D_WASI_EMULATED_MMAN"/> + <_WASILinkFlags Include="-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> <_WasmOptConfigurationFlags>@(WasmOptConfigurationFlags, '%3B ') - <_WasiPropsJson> + <_WASIPropsJson> - + - - - - + DependsOnTargets="GenerateWASIPropsAndRspFiles;GenerateManagedToNative;BundleTimeZones"> -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 - -Oz + -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 + -Oz - $(CMakeConfigurationWasiFlags) + $(CMakeConfigurationWASIFlags) -O2 cmake $(MSBuildThisFileDirectory)runtime @@ -170,7 +170,7 @@ $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" - $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWASIFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" diff --git a/src/native/libs/Common/pal_error_common.h b/src/native/libs/Common/pal_error_common.h index 72ffa90461a5d..e9de2b793e408 100644 --- a/src/native/libs/Common/pal_error_common.h +++ b/src/native/libs/Common/pal_error_common.h @@ -309,15 +309,15 @@ inline static int32_t ConvertErrorPlatformToPal(int32_t platformErrno) case ESOCKTNOSUPPORT: return Error_ESOCKTNOSUPPORT; #endif -#ifdef EPFNOSUPPORT // not available in Wasi +#ifdef EPFNOSUPPORT // not available in WASI case EPFNOSUPPORT: return Error_EPFNOSUPPORT; #endif -#ifdef ESHUTDOWN // not available in Wasi +#ifdef ESHUTDOWN // not available in WASI case ESHUTDOWN: return Error_ESHUTDOWN; #endif -#ifdef EHOSTDOWN // not available in Wasi +#ifdef EHOSTDOWN // not available in WASI case EHOSTDOWN: return Error_EHOSTDOWN; #endif @@ -501,7 +501,7 @@ inline static int32_t ConvertErrorPalToPlatform(int32_t error) return ETXTBSY; case Error_EXDEV: return EXDEV; -#ifdef EPFNOSUPPORT // not available in Wasi +#ifdef EPFNOSUPPORT // not available in WASI case Error_EPFNOSUPPORT: return EPFNOSUPPORT; #endif @@ -509,11 +509,11 @@ inline static int32_t ConvertErrorPalToPlatform(int32_t error) case Error_ESOCKTNOSUPPORT: return ESOCKTNOSUPPORT; #endif -#ifdef ESHUTDOWN // not available in Wasi +#ifdef ESHUTDOWN // not available in WASI case Error_ESHUTDOWN: return ESHUTDOWN; #endif -#ifdef EHOSTDOWN // not available in Wasi +#ifdef EHOSTDOWN // not available in WASI case Error_EHOSTDOWN: return EHOSTDOWN; #endif @@ -549,7 +549,7 @@ static bool TryConvertErrorToGai(int32_t error, int32_t* gaiError) switch (error) { -#ifdef EAI_NONAME // not available in Wasi +#ifdef EAI_NONAME // not available in WASI case EHOSTNOTFOUND: *gaiError = EAI_NONAME; return true; diff --git a/src/native/libs/Common/pal_io_common.h b/src/native/libs/Common/pal_io_common.h index 00806145bf942..75c73b6ef6813 100644 --- a/src/native/libs/Common/pal_io_common.h +++ b/src/native/libs/Common/pal_io_common.h @@ -109,7 +109,7 @@ inline static int32_t Common_Poll(PollEvent* pollEvents, uint32_t eventCount, in case PAL_POLLIN: pollfds[i].events = POLLIN; break; -#ifdef POLLPRI // not available in Wasi +#ifdef POLLPRI // not available in WASI case PAL_POLLPRI: pollfds[i].events = POLLPRI; break; @@ -159,7 +159,7 @@ inline static int32_t Common_Poll(PollEvent* pollEvents, uint32_t eventCount, in case POLLIN: pollEvents[i].TriggeredEvents = PAL_POLLIN; break; -#ifdef POLLPRI // not available in Wasi +#ifdef POLLPRI // not available in WASI case POLLPRI: pollEvents[i].TriggeredEvents = PAL_POLLPRI; break; diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index 3de7efd78bb84..346f8630d4a6e 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,7 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) -if /i [%1] == [Wasi] ( set __TargetOS=Wasi&&shift&goto Arg_Loop) +if /i [%1] == [WASI] ( set __TargetOS=WASI&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 528a3ac3a0e7f..c50ea552d114a 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -53,7 +53,7 @@ if [[ "$__TargetOS" == Browser ]]; then fi source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) -elif [[ "$__TargetOS" == Wasi ]]; then +elif [[ "$__TargetOS" == WASI ]]; then if [[ -z "$WASI_SDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk/ ]]; then export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasi/wasi-sdk/ @@ -65,7 +65,7 @@ elif [[ "$__TargetOS" == Wasi ]]; then export CLR_CC="$WASI_SDK_PATH"bin/clang export TARGET_BUILD_ARCH=wasm - __CMakeArgs="-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.cmake" + __CMakeArgs="-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.cmake" elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index f6f0c00812f42..6727b69fbad16 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,8 +20,8 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - Wasi = 2048, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | Wasi, + WASI = 2048, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | WASI, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index a76025db7d727..fb76e32d82daf 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -709,7 +709,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, - "wasi" => Xunit.TestPlatforms.Wasi, + "wasi" => Xunit.TestPlatforms.WASI, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, diff --git a/src/tests/build.sh b/src/tests/build.sh index 319b5958a99ca..266b2fe7c4415 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "Wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "WASI" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From 1f7d3e9a1b33ba6956fb572b4af61e61a50a1471 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 16:46:53 +0100 Subject: [PATCH 052/116] Update eng/native/configurecompiler.cmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/native/configurecompiler.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 27a5ea048cdc3..c0c660bda838b 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -547,7 +547,7 @@ elseif(CLR_CMAKE_TARGET_WASI) add_compile_definitions($<$>>:TARGET_WASI>) elseif(CLR_CMAKE_TARGET_BROWSER) add_compile_definitions($<$>>:TARGET_BROWSER>) -else() +else(CLR_CMAKE_TARGET_UNIX)) add_compile_definitions($<$>>:TARGET_WINDOWS>) endif(CLR_CMAKE_TARGET_UNIX) From d2315b31a9588867c6c1fa68f68cf5d2e24e9afb Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 16:50:44 +0100 Subject: [PATCH 053/116] Update src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index 6727b69fbad16..b00ea106fab75 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,7 +20,7 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - WASI = 2048, + WASI = 4096, AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | WASI, Any = ~0 } From cbf8a6cd2782989eef8dfd6e7dc13153e3e686fd Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 17:16:49 +0100 Subject: [PATCH 054/116] feedback --- .../System.Private.CoreLib/src/System/OperatingSystem.cs | 2 ++ src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- src/mono/CMakeLists.txt | 5 ----- .../System.Private.CoreLib/System.Private.CoreLib.csproj | 8 -------- src/native/libs/build-native.cmd | 2 ++ src/native/libs/build-native.sh | 3 +++ src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs | 5 +++-- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 41318e5c71391..07bcba1eef36c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -150,6 +150,7 @@ public static bool IsBrowser() => false; #endif +/* TODO https://github.com/dotnet/runtime/issues/78389 /// /// Indicates whether the current application is running as WASI. /// @@ -160,6 +161,7 @@ public static bool IsWASI() => #else false; #endif +*/ /// /// Indicates whether the current application is running on Linux. diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index e460cf4f2f090..3cf2d2f82ce90 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,7 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } - public static bool IsWASI() { throw null; } + // TODO public static bool IsWASI() { throw null; } see https://github.com/dotnet/runtime/issues/78389 public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 85a0f819da4d1..90bfcd924a494 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -358,11 +358,6 @@ if(NOT "${MSVC_C_ARCHITECTURE_ID}" STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") endif() -if(HOST_BROWSER) - # CMAKE_SYSTEM_PROCESSOR is set to x86 by emscripten - set(CMAKE_SYSTEM_PROCESSOR "wasm") -endif() - # Unify naming if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARMV7") set(CMAKE_SYSTEM_PROCESSOR "arm") diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 23beee5417b57..17a336f423c22 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -83,14 +83,6 @@ AnyCPU $(DefineConstants);TARGET_POWERPC64 - - AnyCPU - $(DefineConstants);TARGET_BROWSER - - - AnyCPU - $(DefineConstants);TARGET_WASI - diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index 5b28c787df3f9..aeaf67f0a1eab 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -97,6 +97,8 @@ if [%__Ninja%] == [1] ( set __generatorArgs= ) else if [%__TargetOS%] == [Browser] ( set __generatorArgs= +) else if [%__TargetOS%] == [WASI] ( + set __generatorArgs= ) else ( set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065 ) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index add5288fbeabf..47600984884f1 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -54,6 +54,9 @@ if [[ "$__TargetOS" == Browser ]]; then source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) +elif [[ "$__TargetOS" == WASI ]]; then + # nothing to do here + true elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then # nothing to do here true diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index b00ea106fab75..4af43130cf359 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -20,8 +20,9 @@ public enum TestPlatforms Android = 512, Browser = 1024, MacCatalyst = 2048, - WASI = 4096, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | WASI, + LinuxBionic = 4096, + WASI = 8192, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | LinuxBionic | WASI, Any = ~0 } } From f137e114d943693777b8ab604648a71acae41768 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 18:10:43 +0100 Subject: [PATCH 055/116] fix --- eng/native/configurecompiler.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c0c660bda838b..2357455f9db67 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -547,7 +547,7 @@ elseif(CLR_CMAKE_TARGET_WASI) add_compile_definitions($<$>>:TARGET_WASI>) elseif(CLR_CMAKE_TARGET_BROWSER) add_compile_definitions($<$>>:TARGET_BROWSER>) -else(CLR_CMAKE_TARGET_UNIX)) +else(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_WINDOWS>) endif(CLR_CMAKE_TARGET_UNIX) From b48bde451e462a3b442457f7d9c8835f8bf13b59 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 18:47:44 +0100 Subject: [PATCH 056/116] feedback --- .../System.Private.CoreLib/src/System/OperatingSystem.cs | 2 +- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 07bcba1eef36c..26fbb1510a0c3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -155,7 +155,7 @@ public static bool IsBrowser() => /// Indicates whether the current application is running as WASI. /// [NonVersionable] - public static bool IsWASI() => + public static bool IsWasi() => #if TARGET_WASI true; #else diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 3cf2d2f82ce90..8406052aab3b5 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4311,7 +4311,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsAndroid() { throw null; } public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsBrowser() { throw null; } - // TODO public static bool IsWASI() { throw null; } see https://github.com/dotnet/runtime/issues/78389 + // TODO public static bool IsWasi() { throw null; } see https://github.com/dotnet/runtime/issues/78389 public static bool IsFreeBSD() { throw null; } public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } [System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")] From 99daf3fa600c4e11542523626cd44e9587d8c9c8 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 19:16:21 +0100 Subject: [PATCH 057/116] script feedback --- eng/native/build-commons.sh | 2 +- eng/native/gen-buildsys.cmd | 35 +++++++++++++++++++++----------- eng/native/gen-buildsys.sh | 20 +++++++++++------- src/native/corehost/build.cmd | 5 +++-- src/native/libs/build-native.cmd | 2 +- src/tests/build.cmd | 2 +- 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index fc4bfd4a727a2..c9160b1e4b59a 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -117,7 +117,7 @@ build_native() scan_build=scan-build fi - nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $hostArch $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs" + nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $hostArch $targetOS $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs" echo "Invoking $nextCommand" eval $nextCommand diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 3701e639cee98..6b185cb2b3cc5 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -22,6 +22,7 @@ set __SourceDir=%1 set __IntermediatesDir=%2 set __VSVersion=%3 set __Arch=%4 +set __Os=%5 set __CmakeGenerator=Visual Studio set __UseEmcmake=0 if /i "%__Ninja%" == "1" ( @@ -41,25 +42,35 @@ if /i "%__Ninja%" == "1" ( if /i "%__Arch%" == "wasm" ( - if "%EMSDK_PATH%" == "" ( - if not exist "%__repoRoot%src\mono\wasm\emsdk" ( - echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root. - exit /B 1 + if "%__Os%" == "" ( + echo Error: Please add target OS parameter + exit /B 1 + ) + if "%__Os%" == "Browser" ( + if "%EMSDK_PATH%" == "" ( + if not exist "%__repoRoot%src\mono\wasm\emsdk" ( + echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root. + exit /B 1 + ) + + set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk + set EMSDK_PATH=!EMSDK_PATH:\=/! ) - set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk - set EMSDK_PATH=!EMSDK_PATH:\=/! + set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" + set __UseEmcmake=1 + ) + if "%__Os%" == "WASI" ( + echo Error: WASI build not implemented on Windows yet + exit /B 1 ) - - set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" - set __UseEmcmake=1 ) else ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0" ) :loop -if [%5] == [] goto end_loop -set __ExtraCmakeParams=%__ExtraCmakeParams% %5 +if [%6] == [] goto end_loop +set __ExtraCmakeParams=%__ExtraCmakeParams% %6 shift goto loop :end_loop @@ -98,7 +109,7 @@ exit /B %errorlevel% :USAGE echo "Usage..." - echo "gen-buildsys.cmd " + echo "gen-buildsys.cmd " echo "Specify the path to the top level CMake file - /src/NDP" echo "Specify the VSVersion to be used - VS2017 or VS2019" EXIT /B 1 diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 16c487760902b..0dc934ff1c89d 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -7,7 +7,7 @@ scriptroot="$( cd -P "$( dirname "$0" )" && pwd )" if [[ "$#" -lt 4 ]]; then echo "Usage..." - echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" + echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" echo "Specify the path to the top level CMake file." echo "Specify the path that the build system files are generated in." echo "Specify the host architecture (the architecture the built tools should run on)." @@ -20,7 +20,8 @@ if [[ "$#" -lt 4 ]]; then fi host_arch="$3" -compiler="$4" +target_os="$4" +compiler="$5" if [[ "$compiler" != "default" ]]; then nativescriptroot="$( cd -P "$scriptroot/../common/native" && pwd )" @@ -39,7 +40,7 @@ scan_build=OFF generator="Unix Makefiles" __UnprocessedCMakeArgs="" -for i in "${@:5}"; do +for i in "${@:6}"; do upperI="$(echo "$i" | tr "[:lower:]" "[:upper:]")" case "$upperI" in # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO. @@ -92,10 +93,15 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then cmake_command="$SCAN_BUILD_COMMAND $cmake_command" fi -if [[ "$host_arch" == "wasm" && "$2" =~ "-Browser-" ]]; then - cmake_command="emcmake $cmake_command" -elif [[ "$host_arch" == "wasm" && "$2" =~ "-WASI-" ]]; then - true +if [[ "$host_arch" == "wasm" ]]; then + if [[ "$target_os" == "Browser" ]]; then + cmake_command="emcmake $cmake_command" + elif [[ "$target_os" == "WASI" ]]; then + true + else + echo "target_os was not specified" + exit(1) + fi fi # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 749cba3e2cea9..7a47bb9266de6 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -11,6 +11,7 @@ set __engNativeDir=%__sourceDir%\..\..\..\eng\native set __CMakeBinDir="" set __IntermediatesDir="" set __BuildArch=x64 +set __TargetOS=Windows set CMAKE_BUILD_TYPE=Debug set __PortableBuild=0 set __ConfigureOnly=0 @@ -102,9 +103,9 @@ set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" :: Regenerate the native build files -echo Calling "%__engNativeDir%\gen-buildsys.cmd "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__ExtraCmakeParams%" +echo Calling "%__engNativeDir%\gen-buildsys.cmd "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__TargetOS% %__ExtraCmakeParams%" -call "%__engNativeDir%\gen-buildsys.cmd" "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__ExtraCmakeParams% +call "%__engNativeDir%\gen-buildsys.cmd" "%__sourceDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__TargetOS% %__ExtraCmakeParams% if NOT [%errorlevel%] == [0] goto :Failure popd diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index aeaf67f0a1eab..63651b4d05492 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -86,7 +86,7 @@ echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Bu :: Regenerate the VS solution pushd "%__IntermediatesDir%" -call "%__repoRoot%\eng\native\gen-buildsys.cmd" "%__sourceRootDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__ExtraCmakeParams% +call "%__repoRoot%\eng\native\gen-buildsys.cmd" "%__sourceRootDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__TargetOS% %__ExtraCmakeParams% if NOT [%errorlevel%] == [0] goto :Failure popd diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 7c72558ac4b07..57c656ac2789a 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -229,7 +229,7 @@ if %__Ninja% EQU 1 ( ) else ( set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" ) -call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! !__CMakeArgs! +call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% %__TargetOS% !__ExtraCmakeArgs! !__CMakeArgs! if not !errorlevel! == 0 ( echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project! From 029e7fe23f2a8f3471e6cda14bfafb14c4b1f2e7 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 19:17:16 +0100 Subject: [PATCH 058/116] Update eng/build.ps1 Co-authored-by: Ankit Jain --- eng/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 63e4039dec58d..3244d8b32efb8 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -288,7 +288,7 @@ if ($os -eq "WASI") { $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need need ninja for WASI-SDK." + Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need ninja for WASI-SDK." exit 1 } } From 98f827edbb22b111f57e86df9b0cf8834da0831c Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 19:17:35 +0100 Subject: [PATCH 059/116] Update src/coreclr/scripts/coreclr_arguments.py Co-authored-by: Ankit Jain --- src/coreclr/scripts/coreclr_arguments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py index db8fdb1d132ba..92ecc6e8d3930 100644 --- a/src/coreclr/scripts/coreclr_arguments.py +++ b/src/coreclr/scripts/coreclr_arguments.py @@ -65,7 +65,7 @@ def __init__(self, self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "wasm"] self.valid_build_types = ["Debug", "Checked", "Release"] - self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "Wasi"] + self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "WASI"] self.__initialize__(args) From e2bbaf05b010a69ff63272f8a9f97c65c84d8670 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 19:21:28 +0100 Subject: [PATCH 060/116] feedback --- eng/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/build.sh b/eng/build.sh index 4a69651731035..76293cee0c248 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -503,11 +503,11 @@ if [ ${#actInt[@]} -eq 0 ]; then arguments="-restore -build $arguments" fi -if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then +if [[ "$os" == "Browser" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi -if [[ "$os" == "WASI" && "$arch" != "wasm" ]]; then +if [[ "$os" == "WASI" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi From e57f0ad402d99c904ec49b11bab59e12f814b70b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 19:22:35 +0100 Subject: [PATCH 061/116] feedback --- eng/testing/tests.wasm.targets | 12 ++++++------ .../wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj | 2 +- src/mono/wasm/build/WasmApp.targets | 10 +++++----- .../Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj | 2 +- src/mono/wasm/debugger/tests/Directory.Build.props | 2 +- .../Common/wasm-test-runner/WasmTestRunner.proj | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index 8fb430740b4da..f045e427a4607 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -1,7 +1,7 @@ - true + true true false $(BundleTestAppTargets);BundleTestWasmApp @@ -40,7 +40,7 @@ + Condition="'$(InstallChromeForTests)' == 'true' and ('$(ContinuousIntegrationBuild)' != 'true' or '$(IsBrowserWasmProject)' != 'true')" /> @@ -138,9 +138,9 @@ Condition="'$(BuildAOTTestsOn)' == 'local'" /> - - WasmTriggerPublishApp - $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix + + WasmTriggerPublishApp + $(BundleTestWasmAppDependsOn);_BundleAOTTestWasmAppForHelix $(WasmAppHostDir)/WasmAppHost - + true diff --git a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj index e47be6431fba8..cf7a20b562391 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj +++ b/src/mono/wasm/Wasm.Build.Tests/Wasm.Build.Tests.csproj @@ -16,7 +16,7 @@ true - false + false true diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index e09aff8990502..8cfc736c4c252 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -97,7 +97,7 @@ <_BeforeWasmBuildAppDependsOn /> - true + true Build Publish @@ -121,8 +121,8 @@ - - + + @@ -158,7 +158,7 @@ + Condition="'$(IsBrowserWasmProject)' == 'true' and '$(WasmBuildingForNestedPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'"> + Condition="'$(IsBrowserWasmProject)' == 'true' and '$(WasmBuildingForNestedPublish)' == '' and '$(WasmBuildOnlyAfterPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'" /> false false false - false + false true true xunit diff --git a/src/mono/wasm/debugger/tests/Directory.Build.props b/src/mono/wasm/debugger/tests/Directory.Build.props index cd1f27e2818c0..0caa9471918f3 100644 --- a/src/mono/wasm/debugger/tests/Directory.Build.props +++ b/src/mono/wasm/debugger/tests/Directory.Build.props @@ -4,7 +4,7 @@ $(AspNetCoreAppCurrent) Library - true + true Debug true diff --git a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj index b646a764139bd..0dd66155b1d7d 100644 --- a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj +++ b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj @@ -12,7 +12,7 @@ $(MSBuildThisFileDirectory)\obj\$(Configuration)\wasm $(TestBinDir)/WasmApp/ 99.0 - true + true true $(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll From d94b4c3d1e6d265b4ea8cebad887223728389d86 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 19:52:35 +0100 Subject: [PATCH 062/116] fix --- eng/native/gen-buildsys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 0dc934ff1c89d..6e912c66bc8d2 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -100,7 +100,7 @@ if [[ "$host_arch" == "wasm" ]]; then true else echo "target_os was not specified" - exit(1) + exit 1 fi fi From e32f56d8735494b6b0c5ecbe5679906743ad7515 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 15 Nov 2022 20:16:14 +0100 Subject: [PATCH 063/116] wip --- src/mono/sample/wasi/Directory.Build.props | 2 +- src/mono/sample/wasi/Directory.Build.targets | 2 +- .../wasi/console/Wasi.Console.Sample.csproj | 4 +- src/mono/wasi/runtime/driver.c | 408 ++++++++++-------- src/mono/wasm/runtime/gc-common.h | 4 + .../pal_icushim_static.c | 6 +- .../libs/System.Native/pal_dynamicload.c | 1 + 7 files changed, 236 insertions(+), 191 deletions(-) diff --git a/src/mono/sample/wasi/Directory.Build.props b/src/mono/sample/wasi/Directory.Build.props index 8d8abf392eb82..722c684126f17 100644 --- a/src/mono/sample/wasi/Directory.Build.props +++ b/src/mono/sample/wasi/Directory.Build.props @@ -33,5 +33,5 @@ - + diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 1674b52b8262f..5a9f4d3b38f46 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -1,6 +1,6 @@ - + true diff --git a/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj index a51b1e5594622..2cbc92e85f134 100644 --- a/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj +++ b/src/mono/sample/wasi/console/Wasi.Console.Sample.csproj @@ -4,8 +4,8 @@ - <_SampleProject>WASI.Console.Sample.csproj - <_SampleAssembly>WASI.Console.Sample.dll + <_SampleProject>Wasi.Console.Sample.csproj + <_SampleAssembly>Wasi.Console.Sample.dll diff --git a/src/mono/wasi/runtime/driver.c b/src/mono/wasi/runtime/driver.c index e04fc11fe1d3e..ce3388ddf44a6 100644 --- a/src/mono/wasi/runtime/driver.c +++ b/src/mono/wasi/runtime/driver.c @@ -8,22 +8,19 @@ #include #include #include -#include -#include -#include #define INVARIANT_GLOBALIZATION 1 +#include #include +#include #include #include #include -#include #include +#include #include -#include -#include -#include +#include #include #include @@ -38,6 +35,8 @@ #ifdef GEN_PINVOKE #include "wasm_m2n_invoke.g.h" #endif +#include "../../wasm/runtime/gc-common.h" + #if !defined(ENABLE_AOT) || defined(EE_MODE_LLVMONLY_INTERP) #define NEED_INTERP 1 @@ -83,13 +82,13 @@ static MonoDomain *root_domain; static void wasi_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) { - printf("[wasi_trace_logger] %s\n", message); + printf("[wasi_trace_logger] %s\n", message); if (fatal) { // make it trap so we could see the stack trace // (*(int*)(void*)-1)++; exit(1); } - + } typedef uint32_t target_mword; @@ -137,39 +136,10 @@ struct WasmSatelliteAssembly_ { static WasmSatelliteAssembly *satellite_assemblies; static int satellite_assembly_count; -int32_t time(int32_t x) { - // In the current prototype, libSystem.Native.a is built using Emscripten, whereas the WASI-enabled runtime is being built - // using WASI SDK. Emscripten says that time() returns int32, whereas WASI SDK says it returns int64. - // TODO: Build libSystem.Native.a using WASI SDK. - // In the meantime, as a workaround we can define an int32-returning implementation for time() here. - struct timeval time; - return (gettimeofday(&time, NULL) == 0) ? time.tv_sec : 0; -} - -typedef struct -{ - int32_t Flags; // flags for testing if some members are present (see FileStatusFlags) - int32_t Mode; // file mode (see S_I* constants above for bit values) - uint32_t Uid; // user ID of owner - uint32_t Gid; // group ID of owner - int64_t Size; // total size, in bytes - int64_t ATime; // time of last access - int64_t ATimeNsec; // nanosecond part - int64_t MTime; // time of last modification - int64_t MTimeNsec; // nanosecond part - int64_t CTime; // time of last status change - int64_t CTimeNsec; // nanosecond part - int64_t BirthTime; // time the file was created - int64_t BirthTimeNsec; // nanosecond part - int64_t Dev; // ID of the device containing the file - int64_t Ino; // inode number of the file - uint32_t UserFlags; // user defined flags -} FileStatus; - char* gai_strerror(int code) { - char* result = malloc(256); - sprintf(result, "Error code %i", code); - return result; + char* result = malloc(256); + sprintf(result, "Error code %i", code); + return result; } void @@ -221,7 +191,83 @@ wasm_dl_symbol (void *handle, const char *name, char **err, void *user_data) return NULL; } +#if !defined(ENABLE_AOT) || defined(EE_MODE_LLVMONLY_INTERP) #define NEED_INTERP 1 +#ifndef LINK_ICALLS +// FIXME: llvm+interp mode needs this to call icalls +#define NEED_NORMAL_ICALL_TABLES 1 +#endif +#endif + +#ifdef LINK_ICALLS + +#include "icall-table.h" + +static int +compare_int (const void *k1, const void *k2) +{ + return *(int*)k1 - *(int*)k2; +} + +static void* +icall_table_lookup (MonoMethod *method, char *classname, char *methodname, char *sigstart, int32_t *out_flags) +{ + uint32_t token = mono_method_get_token (method); + assert (token); + assert ((token & MONO_TOKEN_METHOD_DEF) == MONO_TOKEN_METHOD_DEF); + uint32_t token_idx = token - MONO_TOKEN_METHOD_DEF; + + int *indexes = NULL; + int indexes_size = 0; + uint8_t *flags = NULL; + void **funcs = NULL; + + *out_flags = 0; + + const char *image_name = mono_image_get_name (mono_class_get_image (mono_method_get_class (method))); + +#if defined(ICALL_TABLE_corlib) + if (!strcmp (image_name, "System.Private.CoreLib")) { + indexes = corlib_icall_indexes; + indexes_size = sizeof (corlib_icall_indexes) / 4; + flags = corlib_icall_flags; + funcs = corlib_icall_funcs; + assert (sizeof (corlib_icall_indexes [0]) == 4); + } +#endif +#ifdef ICALL_TABLE_System + if (!strcmp (image_name, "System")) { + indexes = System_icall_indexes; + indexes_size = sizeof (System_icall_indexes) / 4; + flags = System_icall_flags; + funcs = System_icall_funcs; + } +#endif + assert (indexes); + + void *p = bsearch (&token_idx, indexes, indexes_size, 4, compare_int); + if (!p) { + return NULL; + printf ("wasm: Unable to lookup icall: %s\n", mono_method_get_name (method)); + exit (1); + } + + uint32_t idx = (int*)p - indexes; + *out_flags = flags [idx]; + + //printf ("ICALL: %s %x %d %d\n", methodname, token, idx, (int)(funcs [idx])); + + return funcs [idx]; +} + +static const char* +icall_table_lookup_symbol (void *func) +{ + assert (0); + return NULL; +} + +#endif /* * get_native_to_interp: @@ -233,6 +279,9 @@ wasm_dl_symbol (void *handle, const char *name, char **err, void *user_data) void* get_native_to_interp (MonoMethod *method, void *extra_arg) { + void *addr; + + MONO_ENTER_GC_UNSAFE; MonoClass *klass = mono_method_get_class (method); MonoImage *image = mono_class_get_image (klass); MonoAssembly *assembly = mono_image_get_assembly (image); @@ -251,9 +300,9 @@ get_native_to_interp (MonoMethod *method, void *extra_arg) key [i] = '_'; } - assert(0); return 0; - //void *addr = wasm_dl_get_native_to_interp (key, extra_arg); - //return addr; + addr = wasm_dl_get_native_to_interp (key, extra_arg); + MONO_EXIT_GC_UNSAFE; + return addr; } void @@ -273,6 +322,8 @@ mono_wasm_register_bundled_satellite_assemblies (void) } } +void mono_wasm_link_icu_shim (void); + void cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data) { @@ -281,7 +332,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data) } void -mono_wasm_load_runtime (const char *argv, int debug_level) +mono_wasm_load_runtime (const char *unused, int debug_level) { const char *interp_opts = ""; @@ -294,13 +345,12 @@ mono_wasm_load_runtime (const char *argv, int debug_level) #ifdef DEBUG monoeg_g_setenv ("MONO_LOG_LEVEL", "debug", 0); monoeg_g_setenv ("MONO_LOG_MASK", "all", 0); - // Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this - // output will be sent to the console. Right now this is the only way to emit debug logging from - // corlib assemblies. - monoeg_g_setenv ("COMPlus_DebugWriteToStdErr", "1", 0); + // Setting this env var allows Diagnostic.Debug to write to stderr. In a browser environment this + // output will be sent to the console. Right now this is the only way to emit debug logging from + // corlib assemblies. + // monoeg_g_setenv ("COMPlus_DebugWriteToStdErr", "1", 0); #endif -#if TODOWASI char* debugger_fd = monoeg_g_getenv ("DEBUGGER_FD"); if (debugger_fd != 0) { @@ -322,6 +372,7 @@ mono_wasm_load_runtime (const char *argv, int debug_level) const char *appctx_values[2]; appctx_values [0] = "/"; appctx_values [1] = "wasi-wasm"; + const char *file_name = RUNTIMECONFIG_BIN_FILE; int str_len = strlen (file_name) + 1; // +1 is for the "/" char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character @@ -338,27 +389,57 @@ mono_wasm_load_runtime (const char *argv, int debug_level) } else { free (file_path); } + monovm_initialize (2, appctx_keys, appctx_values); -#else - monovm_initialize (0, NULL, NULL); -#endif /* TODOWASI */ -#if TODOWASI mini_parse_debug_option ("top-runtime-invoke-unhandled"); -#endif /* TODOWASI */ mono_dl_fallback_register (wasm_dl_load, wasm_dl_symbol, NULL, NULL); mono_wasm_install_get_native_to_interp_tramp (get_native_to_interp); - + #ifdef GEN_PINVOKE mono_wasm_install_interp_to_native_callback (mono_wasm_interp_to_native_callback); #endif +#ifdef ENABLE_AOT + monoeg_g_setenv ("MONO_AOT_MODE", "aot", 1); + + // Defined in driver-gen.c + register_aot_modules (); +#ifdef EE_MODE_LLVMONLY_INTERP + mono_jit_set_aot_mode (MONO_AOT_MODE_LLVMONLY_INTERP); +#else + mono_jit_set_aot_mode (MONO_AOT_MODE_LLVMONLY); +#endif +#else mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY); + /* + * debug_level > 0 enables debugging and sets the debug log level to debug_level + * debug_level == 0 disables debugging and enables interpreter optimizations + * debug_level < 0 enabled debugging and disables debug logging. + * + * Note: when debugging is enabled interpreter optimizations are disabled. + */ + if (debug_level) { + // Disable optimizations which interfere with debugging + interp_opts = "-all"; + mono_wasm_enable_debugging (debug_level); + } + +#endif + #ifdef LINK_ICALLS - #error /* TODOWASI */ + /* Link in our own linked icall table */ + static const MonoIcallTableCallbacks mono_icall_table_callbacks = + { + MONO_ICALL_TABLE_CALLBACKS_VERSION, + icall_table_lookup, + icall_table_lookup_symbol + }; + mono_install_icall_table_callbacks (&mono_icall_table_callbacks); #endif + #ifdef NEED_NORMAL_ICALL_TABLES mono_icall_table_init (); #endif @@ -390,10 +471,9 @@ mono_wasm_load_runtime (const char *argv, int debug_level) MonoAssembly* mono_wasm_assembly_load (const char *name) { + assert (name); MonoImageOpenStatus status; MonoAssemblyName* aname = mono_assembly_name_new (name); - if (!name) - return NULL; MonoAssembly *res = mono_assembly_load (aname, NULL, &status); mono_assembly_name_free (aname); @@ -401,68 +481,65 @@ mono_wasm_assembly_load (const char *name) return res; } -MonoClass* -mono_wasm_find_corlib_class (const char *namespace, const char *name) +MonoAssembly* +mono_wasm_get_corlib (const char *namespace, const char *name) { - return mono_class_from_name (mono_get_corlib (), namespace, name); + MonoAssembly* result; + MONO_ENTER_GC_UNSAFE; + result = mono_image_get_assembly (mono_get_corlib()); + MONO_EXIT_GC_UNSAFE; + return result; } MonoClass* mono_wasm_assembly_find_class (MonoAssembly *assembly, const char *namespace, const char *name) { - return mono_class_from_name (mono_assembly_get_image (assembly), namespace, name); + assert (assembly); + MonoClass *result; + MONO_ENTER_GC_UNSAFE; + result = mono_class_from_name (mono_assembly_get_image (assembly), namespace, name); + MONO_EXIT_GC_UNSAFE; + return result; } MonoMethod* mono_wasm_assembly_find_method (MonoClass *klass, const char *name, int arguments) { - return mono_class_get_method_from_name (klass, name, arguments); + assert (klass); + MonoMethod* result; + MONO_ENTER_GC_UNSAFE; + result = mono_class_get_method_from_name (klass, name, arguments); + MONO_EXIT_GC_UNSAFE; + return result; } -MonoMethod* -mono_wasm_get_delegate_invoke (MonoObject *delegate) -{ - return mono_get_delegate_invoke(mono_object_get_class (delegate)); -} - -MonoObject* -mono_wasm_box_primitive (MonoClass *klass, void *value, int value_size) -{ - if (!klass) - return NULL; - - MonoType *type = mono_class_get_type (klass); - int alignment; - if (mono_type_size (type, &alignment) > value_size) - return NULL; - - // TODO: use mono_value_box_checked and propagate error out - return mono_value_box (root_domain, klass, value); -} void -mono_wasm_invoke_method_ref (MonoMethod *method, MonoObject **this_arg_in, void *params[], MonoObject **out_exc, MonoObject **out_result) +mono_wasm_invoke_method_ref (MonoMethod *method, MonoObject **this_arg_in, void *params[], MonoObject **_out_exc, MonoObject **out_result) { - MonoObject* temp_exc = NULL; + PPVOLATILE(MonoObject) out_exc = _out_exc; + PVOLATILE(MonoObject) temp_exc = NULL; if (out_exc) *out_exc = NULL; else out_exc = &temp_exc; + MONO_ENTER_GC_UNSAFE; if (out_result) { *out_result = NULL; - *out_result = mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, out_exc); + PVOLATILE(MonoObject) invoke_result = mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, (MonoObject **)out_exc); + store_volatile(out_result, invoke_result); } else { - mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, out_exc); + mono_runtime_invoke (method, this_arg_in ? *this_arg_in : NULL, params, (MonoObject **)out_exc); } if (*out_exc && out_result) { - MonoObject *exc2 = NULL; - *out_result = (MonoObject*)mono_object_to_string (*out_exc, &exc2); + PVOLATILE(MonoObject) exc2 = NULL; + store_volatile(out_result, (MonoObject*)mono_object_to_string (*out_exc, (MonoObject **)&exc2)); if (exc2) - *out_result = (MonoObject*) mono_string_new (root_domain, "Exception Double Fault"); - return; + store_volatile(out_result, (MonoObject*)mono_string_new (root_domain, "Exception Double Fault")); } + MONO_EXIT_GC_UNSAFE; } MonoMethod* @@ -471,10 +548,11 @@ mono_wasm_assembly_get_entry_point (MonoAssembly *assembly) MonoImage *image; MonoMethod *method; + MONO_ENTER_GC_UNSAFE; image = mono_assembly_get_image (assembly); uint32_t entry = mono_image_get_entry_point (image); if (!entry) - return NULL; + goto end; mono_domain_ensure_entry_assembly (root_domain, assembly); method = mono_get_method (image, entry, NULL); @@ -491,9 +569,10 @@ mono_wasm_assembly_get_entry_point (MonoAssembly *assembly) int name_length = strlen (name); if ((*name != '<') || (name [name_length - 1] != '>')) - return method; + goto end; MonoClass *klass = mono_method_get_class (method); + assert(klass); char *async_name = malloc (name_length + 2); snprintf (async_name, name_length + 2, "%s$", name); @@ -502,7 +581,8 @@ mono_wasm_assembly_get_entry_point (MonoAssembly *assembly) MonoMethod *async_method = mono_class_get_method_from_name (klass, async_name, mono_signature_get_param_count (sig)); if (async_method != NULL) { free (async_name); - return async_method; + method = async_method; + goto end; } // look for "Name" by trimming the first and last character of "" @@ -511,24 +591,12 @@ mono_wasm_assembly_get_entry_point (MonoAssembly *assembly) free (async_name); if (async_method != NULL) - return async_method; + method = async_method; } - return method; -} -char * -mono_wasm_string_get_utf8 (MonoString *str) -{ - return mono_string_to_utf8 (str); //XXX JS is responsible for freeing this -} - -MonoString * -mono_wasm_string_from_js (const char *str) -{ - if (str) - return mono_string_new (root_domain, str); - else - return NULL; + end: + MONO_EXIT_GC_UNSAFE; + return method; } int @@ -556,49 +624,18 @@ mono_unbox_int (MonoObject *obj) return *(unsigned int*)ptr; case MONO_TYPE_CHAR: return *(short*)ptr; - // WASM doesn't support returning longs to JS - // case MONO_TYPE_I8: - // case MONO_TYPE_U8: default: printf ("Invalid type %d to mono_unbox_int\n", mono_type_get_type (type)); return 0; } } -int -mono_wasm_array_length (MonoArray *array) -{ - return mono_array_length (array); -} - -MonoObject* -mono_wasm_array_get (MonoArray *array, int idx) -{ - return mono_array_get (array, MonoObject*, idx); -} - -MonoArray* -mono_wasm_obj_array_new (int size) -{ - return mono_array_new (root_domain, mono_get_object_class (), size); -} - -void -mono_wasm_obj_array_set (MonoArray *array, int idx, MonoObject *obj) -{ - mono_array_setref (array, idx, obj); -} - -MonoArray* -mono_wasm_string_array_new (int size) -{ - return mono_array_new (root_domain, mono_get_string_class (), size); -} void mono_wasm_string_get_data_ref ( MonoString **string, mono_unichar2 **outChars, int *outLengthBytes, int *outIsInterned ) { + MONO_ENTER_GC_UNSAFE; if (!string || !(*string)) { if (outChars) *outChars = 0; @@ -606,16 +643,15 @@ mono_wasm_string_get_data_ref ( *outLengthBytes = 0; if (outIsInterned) *outIsInterned = 1; - return; - } - + } else { if (outChars) *outChars = mono_string_chars (*string); if (outLengthBytes) *outLengthBytes = mono_string_length (*string) * 2; if (outIsInterned) *outIsInterned = mono_string_instance_is_interned (*string); - return; + } + MONO_EXIT_GC_UNSAFE; } void @@ -626,54 +662,54 @@ mono_wasm_string_get_data ( } void add_assembly(const char* base_dir, const char *name) { - FILE *fileptr; - unsigned char *buffer; - long filelen; - char filename[256]; - sprintf(filename, "%s/%s", base_dir, name); - // printf("Loading %s...\n", filename); - - fileptr = fopen(filename, "rb"); - if (fileptr == 0) { - printf("Failed to load %s\n", filename); - fflush(stdout); - } - - fseek(fileptr, 0, SEEK_END); - filelen = ftell(fileptr); - rewind(fileptr); - - buffer = (unsigned char *)malloc(filelen * sizeof(char)); - if(!fread(buffer, filelen, 1, fileptr)) { - printf("Failed to load %s\n", filename); - fflush(stdout); - } - fclose(fileptr); - - assert(mono_wasm_add_assembly(name, buffer, filelen)); + FILE *fileptr; + unsigned char *buffer; + long filelen; + char filename[256]; + sprintf(filename, "%s/%s", base_dir, name); + // printf("Loading %s...\n", filename); + + fileptr = fopen(filename, "rb"); + if (fileptr == 0) { + printf("Failed to load %s\n", filename); + fflush(stdout); + } + + fseek(fileptr, 0, SEEK_END); + filelen = ftell(fileptr); + rewind(fileptr); + + buffer = (unsigned char *)malloc(filelen * sizeof(char)); + if(!fread(buffer, filelen, 1, fileptr)) { + printf("Failed to load %s\n", filename); + fflush(stdout); + } + fclose(fileptr); + + assert(mono_wasm_add_assembly(name, buffer, filelen)); } MonoMethod* lookup_dotnet_method(const char* assembly_name, const char* namespace, const char* type_name, const char* method_name, int num_params) { - MonoAssembly* assembly = mono_wasm_assembly_load (assembly_name); + MonoAssembly* assembly = mono_wasm_assembly_load (assembly_name); assert (assembly); - MonoClass* class = mono_wasm_assembly_find_class (assembly, namespace, type_name); + MonoClass* class = mono_wasm_assembly_find_class (assembly, namespace, type_name); assert (class); - MonoMethod* method = mono_wasm_assembly_find_method (class, method_name, num_params); + MonoMethod* method = mono_wasm_assembly_find_method (class, method_name, num_params); assert (method); return method; } int main() { - // Assume the runtime pack has been copied into the output directory as 'runtime' - // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment - mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); - mono_wasm_load_runtime("", 0); - - MonoAssembly* assembly = mono_wasm_assembly_load ("WASI.Console.Sample"); - MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); - MonoObject* out_exc; - MonoObject* out_res; - mono_wasm_invoke_method_ref (entry_method, NULL, NULL, &out_exc, &out_res); + // Assume the runtime pack has been copied into the output directory as 'runtime' + // Otherwise we have to mount an unrelated part of the filesystem within the WASM environment + mono_set_assemblies_path(".:./runtime/native:./runtime/lib/net7.0"); + mono_wasm_load_runtime("", 0); + + MonoAssembly* assembly = mono_wasm_assembly_load ("Wasi.Console.Sample"); + MonoMethod* entry_method = mono_wasm_assembly_get_entry_point (assembly); + MonoObject* out_exc; + MonoObject* out_res; + mono_wasm_invoke_method_ref (entry_method, NULL, NULL, &out_exc, &out_res); if (out_exc) { mono_print_unhandled_exception(out_exc); @@ -685,4 +721,4 @@ int main() { return r; } return 0; -} +} \ No newline at end of file diff --git a/src/mono/wasm/runtime/gc-common.h b/src/mono/wasm/runtime/gc-common.h index 92789e641a361..a38752ddffc43 100644 --- a/src/mono/wasm/runtime/gc-common.h +++ b/src/mono/wasm/runtime/gc-common.h @@ -1,6 +1,10 @@ #define PVOLATILE(T) T* volatile #define PPVOLATILE(T) T* volatile * +#if !defined(TARGET_BROWSER) +#define EMSCRIPTEN_KEEPALIVE +#endif + #define gpointer void* MONO_API MONO_RT_EXTERNAL_ONLY gpointer diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index cd57172b52329..fd66ea072c94b 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -45,8 +45,12 @@ static void U_CALLCONV icu_trace_data(const void* context, int32_t fnNumber, int printf("[ICUDT] %s: %s\n", utrace_functionName(fnNumber), buf); } +#if defined(TARGET_BROWSER) || defined(TARGET_WASI) #ifdef __EMSCRIPTEN__ #include +#else +#define EMSCRIPTEN_KEEPALIVE +#endif static int32_t load_icu_data(const void* pData); @@ -76,7 +80,7 @@ void mono_wasm_link_icu_shim(void) { } -#endif +#endif /* TARGET_BROWSER || TARGET_WASI */ static int32_t load_icu_data(const void* pData) { diff --git a/src/native/libs/System.Native/pal_dynamicload.c b/src/native/libs/System.Native/pal_dynamicload.c index 56de3a266ecdc..646ec3544f0ba 100644 --- a/src/native/libs/System.Native/pal_dynamicload.c +++ b/src/native/libs/System.Native/pal_dynamicload.c @@ -8,6 +8,7 @@ #include #endif #include +#include #if HAVE_GNU_LIBNAMES_H #include From f8def32850c0e53a80271745145a57284c19132b Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 20:29:05 +0100 Subject: [PATCH 064/116] feedback --- src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs | 4 ++-- .../Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs index 4af43130cf359..21363843ae112 100644 --- a/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs +++ b/src/tests/Common/XUnitWrapperGenerator/TestPlatforms.cs @@ -21,8 +21,8 @@ public enum TestPlatforms Browser = 1024, MacCatalyst = 2048, LinuxBionic = 4096, - WASI = 8192, - AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | LinuxBionic | WASI, + Wasi = 8192, + AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | LinuxBionic | Wasi, Any = ~0 } } diff --git a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs index fb76e32d82daf..a76025db7d727 100644 --- a/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs +++ b/src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs @@ -709,7 +709,7 @@ static Xunit.TestPlatforms GetPlatformForTargetOS(string? targetOS) "tvos" => Xunit.TestPlatforms.tvOS, "maccatalyst" => Xunit.TestPlatforms.MacCatalyst, "browser" => Xunit.TestPlatforms.Browser, - "wasi" => Xunit.TestPlatforms.WASI, + "wasi" => Xunit.TestPlatforms.Wasi, "freebsd" => Xunit.TestPlatforms.FreeBSD, "netbsd" => Xunit.TestPlatforms.NetBSD, null or "" or "anyos" => Xunit.TestPlatforms.Any, From 18b2dfcb4349952678b7a8fe2d0215a37c007936 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 15 Nov 2022 19:40:37 +0000 Subject: [PATCH 065/116] pal_threading.c: Use abort() at end of the function, to silence the compiler complaining about a noreturn function returning --- src/native/libs/System.Native/pal_threading.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index bcad49dd825db..f67c764cdffc0 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -351,6 +351,7 @@ void SystemNative_Exit(int32_t exitCode) { printf ("TODOWASI %s\n", __FUNCTION__); assert(false); + abort(); } __attribute__((noreturn)) @@ -358,5 +359,6 @@ void SystemNative_Abort(void) { printf ("TODOWASI %s\n", __FUNCTION__); assert(false); + abort(); } #endif /* TARGET_WASI */ From c54a0fc94c37d4c7ed0d80c2bf702ed18af39f0d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 15 Nov 2022 20:53:17 +0100 Subject: [PATCH 066/116] fix --- src/coreclr/build-runtime.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 23762de8bd5b8..f4d27eacd79fe 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -354,8 +354,8 @@ if %__BuildNative% EQU 1 ( ) set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% - echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% !__ExtraCmakeArgs! - call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% !__ExtraCmakeArgs! + echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! + call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( echo %__ErrMsgPrefix%%__MsgPrefix%Error: failed to generate native component build project! goto ExitWithError From cfa043716392beae21f20a68ab985a390eec9ca6 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 16 Nov 2022 02:09:20 +0000 Subject: [PATCH 067/116] wip --- Directory.Build.props | 2 ++ eng/build.sh | 8 ++++---- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 4 ++-- src/coreclr/scripts/coreclr_arguments.py | 2 +- .../src/ILLink/ILLink.Substitutions.xml | 10 +++++----- src/libraries/shims/src/System.forwards.cs | 8 ++++---- src/mono/sample/wasi/Directory.Build.targets | 9 +++++++-- src/native/libs/build-native.sh | 2 +- 9 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3efb7dff91299..03de1de9ff53f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -117,6 +117,8 @@ $([MSBuild]::NormalizePath('$(TestExclusionListTasksDir)', 'TestExclusionListTasks.dll')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(TargetOS).$(TargetArchitecture).$(Configuration)')) $(CoreCLRToolPath) + + $([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'wasmtime')) diff --git a/eng/build.sh b/eng/build.sh index 76293cee0c248..7021f659c2f9a 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -281,14 +281,14 @@ while [[ $# > 0 ]]; do browser) os="Browser" ;; wasi) - os="WASI" ;; + os="wasi" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, Wasi, illumos and Solaris." exit 1 ;; esac @@ -507,7 +507,7 @@ if [[ "$os" == "Browser" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi -if [[ "$os" == "WASI" ]]; then +if [[ "$os" == "wasi" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 6e912c66bc8d2..9f5b777b04b3e 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -96,7 +96,7 @@ fi if [[ "$host_arch" == "wasm" ]]; then if [[ "$target_os" == "Browser" ]]; then cmake_command="emcmake $cmake_command" - elif [[ "$target_os" == "WASI" ]]; then + elif [[ "$target_os" == "wasi" ]]; then true else echo "target_os was not specified" diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 18f2a714e57f1..309f6970a0f0f 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -151,7 +151,7 @@ initDistroRidGlobal() if [ "$targetOs" = "Browser" ]; then __DistroRid=browser-wasm export __DistroRid - elif [ "$targetOs" = "WASI" ]; then + elif [ "$targetOs" = "wasi" ]; then __DistroRid=wasi-wasm export __DistroRid fi @@ -191,7 +191,7 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" - elif [ "$targetOs" = "WASI" ]; then + elif [ "$targetOs" = "wasi" ]; then distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py index 92ecc6e8d3930..4f3f8abe56df2 100644 --- a/src/coreclr/scripts/coreclr_arguments.py +++ b/src/coreclr/scripts/coreclr_arguments.py @@ -65,7 +65,7 @@ def __init__(self, self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "wasm"] self.valid_build_types = ["Debug", "Checked", "Release"] - self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "WASI"] + self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "wasi"] self.__initialize__(args) diff --git a/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.xml index 5e70f6fbb5d7d..57af1e08afa78 100644 --- a/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.xml +++ b/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.xml @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/src/libraries/shims/src/System.forwards.cs b/src/libraries/shims/src/System.forwards.cs index 19fac75cffcfc..baf0b46a673e1 100644 --- a/src/libraries/shims/src/System.forwards.cs +++ b/src/libraries/shims/src/System.forwards.cs @@ -4,7 +4,7 @@ // Add any internal types that we need to forward from System. // These types are required for Desktop to Core serialization as they are not covered by GenFacades because they are marked as internal. -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] +//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] +//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] +//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] +//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 5a9f4d3b38f46..3557395678266 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -3,7 +3,7 @@ - true + true @@ -49,7 +49,12 @@ https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-macos.tar.xz - + + + + + + diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index c50ea552d114a..dc42d0d265a65 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -53,7 +53,7 @@ if [[ "$__TargetOS" == Browser ]]; then fi source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) -elif [[ "$__TargetOS" == WASI ]]; then +elif [[ "$__TargetOS" == wasi ]]; then if [[ -z "$WASI_SDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk/ ]]; then export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasi/wasi-sdk/ From b5e0ea9152946f2f41e09ff93f6de1fd620f501e Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 16 Nov 2022 02:40:05 +0000 Subject: [PATCH 068/116] wip --- Directory.Build.props | 1 + src/mono/sample/wasi/Directory.Build.targets | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 03de1de9ff53f..1329207bce2ec 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -36,6 +36,7 @@ s390x ppc64le wasm + wasm x64 x64 $(TargetArchitecture) diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 3557395678266..ad286957bd339 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -53,8 +53,9 @@ - - + + + @@ -63,7 +64,7 @@ --> + Command="$(WasmtimeDir)wasmtime --dir . runtime/native/dotnet.wasm -- $(_SampleAssembly)" IgnoreExitCode="true" /> From d2bc2d5bdd2d9041710097440c463cf115b25a4e Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 16 Nov 2022 03:46:30 +0000 Subject: [PATCH 069/116] wip --- src/libraries/OSGroups.json | 2 +- src/libraries/System.Console/src/System.Console.csproj | 2 +- .../System.IO.Compression/src/System.IO.Compression.csproj | 2 +- .../src/System.IO.MemoryMappedFiles.csproj | 2 +- src/libraries/System.Linq/src/System.Linq.csproj | 2 +- src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 2 +- .../src/System.Net.NameResolution.csproj | 2 +- .../System.Net.Primitives/src/System.Net.Primitives.csproj | 2 +- .../System.Net.WebClient/src/System.Net.WebClient.csproj | 2 +- .../System.Net.WebProxy/src/System.Net.WebProxy.csproj | 2 +- .../src/System.Net.WebSockets.Client.csproj | 2 +- .../System.Net.WebSockets/src/System.Net.WebSockets.csproj | 2 +- .../src/System.Runtime.Serialization.Formatters.csproj | 2 +- .../src/System.Security.Cryptography.csproj | 2 +- .../src/System.Text.Encodings.Web.csproj | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index df35243993b40..2c6aa55fb00e7 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,7 +4,7 @@ }, "Browser" : { }, - "WASI" : { + "wasi" : { }, "Linux": { "#import": [ diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 315ef75439537..6a5d1e9a0ec4f 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index e0e9e1311419e..c0bda04d54b5d 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index 50cfa97484ac2..fd9c6c5c9c4a3 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index c23d5e676ab07..c56806ae42858 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 7d08f1051f61b..295f964742281 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -1,7 +1,7 @@  true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 9d2911cfca351..69b495ad48d95 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 5d281add66bf0..171461684848a 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -2,7 +2,7 @@ true false - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj index 5a7b2fea3d937..5310abadd4d2b 100644 --- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj +++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index a94f7720533a6..f34e25d8f5da9 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index aa79943082caf..022195496cf02 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -1,7 +1,7 @@ True - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index 3cc29b0501e45..5bc522d766f1f 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -1,7 +1,7 @@ True - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index 2744dbc8ca4c3..ebd413ee0fcde 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android $(MSBuildThisFileDirectory)ILLink\ true diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index f524328b7a1ee..a0fed05219f92 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -2,7 +2,7 @@ true $(DefineConstants);INTERNAL_ASYMMETRIC_IMPLEMENTATIONS - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) $(NoWarn);CA5350;CA5351;CA5379;CA5384;SYSLIB0026 $(NoWarn);CS0809 diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 18a26fa1e68b7..5b0ba2ea8a662 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-WASI;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-WASI;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-Browser;$(NetCoreAppMinimum)-wasi;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true From f79c311c1db4c55bb7fcdb38484a3cbc89ff2ca3 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 08:53:32 +0100 Subject: [PATCH 070/116] lower case wasi --- Directory.Build.props | 6 +++--- eng/Subsets.props | 4 ++-- eng/build.ps1 | 12 ++++++------ eng/build.sh | 8 ++++---- eng/native/gen-buildsys.cmd | 2 +- eng/native/gen-buildsys.sh | 2 +- eng/native/init-distro-rid.sh | 4 ++-- eng/pipelines/mono/templates/build-job.yml | 4 ++-- eng/versioning.targets | 2 +- src/libraries/OSGroups.json | 2 +- src/mono/CMakeLists.txt | 4 ++-- src/native/libs/build-native.cmd | 4 ++-- src/native/libs/build-native.sh | 2 +- src/tests/build.sh | 2 +- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3efb7dff91299..e3491661b53a1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ $(_hostOS) browser $(_hostOS) - true + true true @@ -157,7 +157,7 @@ <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos <_portableOS Condition="'$(_runtimeOS)' == 'Solaris' or '$(TargetOS)' == 'Solaris'">solaris <_portableOS Condition="'$(_runtimeOS)' == 'Browser'">browser - <_portableOS Condition="'$(_runtimeOS)' == 'WASI'">wasi + <_portableOS Condition="'$(_runtimeOS)' == 'wasi'">wasi <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios <_portableOS Condition="'$(_runtimeOS)' == 'iOSSimulator'">iossimulator @@ -218,7 +218,7 @@ true true true - true + true true true diff --git a/eng/Subsets.props b/eng/Subsets.props index eba026e7fc935..ebbed3a291fc5 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -61,7 +61,7 @@ mono.llvm+ mono.llvm+ $(DefaultMonoSubsets)mono.wasmruntime+ - $(DefaultMonoSubsets)mono.wasiruntime+ + $(DefaultMonoSubsets)mono.wasiruntime+ $(DefaultMonoSubsets)mono.aotcross+ $(DefaultMonoSubsets)mono.runtime+mono.corelib+mono.packages+ $(DefaultMonoSubsets)mono.tools+ @@ -345,7 +345,7 @@ - + diff --git a/eng/build.ps1 b/eng/build.ps1 index 3244d8b32efb8..88a48512983b6 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -6,7 +6,7 @@ Param( [string][Alias('f')]$framework, [string]$vs, [string][Alias('v')]$verbosity = "minimal", - [ValidateSet("windows","Linux","OSX","Android","Browser","WASI")][string]$os, + [ValidateSet("windows","Linux","OSX","Android","Browser","wasi")][string]$os, [switch]$allconfigurations, [switch]$coverage, [string]$testscope, @@ -40,7 +40,7 @@ function Get-Help() { Write-Host " [Default: Debug]" Write-Host " -librariesConfiguration (-lc) Libraries build configuration: Debug or Release." Write-Host " [Default: Debug]" - Write-Host " -os Target operating system: windows, Linux, OSX, Android, WASI or Browser." + Write-Host " -os Target operating system: windows, Linux, OSX, Android, wasi or Browser." Write-Host " [Default: Your machine's OS.]" Write-Host " -runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." Write-Host " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -283,12 +283,12 @@ if ($os -eq "Browser") { } } -if ($os -eq "WASI") { - # override default arch for WASI, we only support wasm +if ($os -eq "wasi") { + # override default arch for wasi, we only support wasm $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need ninja for WASI-SDK." + Write-Error "Using the -msbuild option isn't supported when building for wasi on Windows, we need ninja for wasi-SDK." exit 1 } } @@ -299,7 +299,7 @@ foreach ($config in $configuration) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig if ($os -eq "Browser") { $env:__DistroRid="browser-$singleArch" - } elseif ($os -eq "WASI") { + } elseif ($os -eq "wasi") { $env:__DistroRid="wasi-$singleArch" } else { $env:__DistroRid="win-$singleArch" diff --git a/eng/build.sh b/eng/build.sh index 76293cee0c248..27b37a1dadd65 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,7 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," - echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, NetBSD, illumos or Solaris." + echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, wasi, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -281,14 +281,14 @@ while [[ $# > 0 ]]; do browser) os="Browser" ;; wasi) - os="WASI" ;; + os="wasi" ;; illumos) os="illumos" ;; solaris) os="Solaris" ;; *) echo "Unsupported target OS '$2'." - echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, WASI, illumos and Solaris." + echo "The allowed values are windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS, tvOSSimulator, iOS, iOSSimulator, Android, Browser, wasi, illumos and Solaris." exit 1 ;; esac @@ -507,7 +507,7 @@ if [[ "$os" == "Browser" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi -if [[ "$os" == "WASI" ]]; then +if [[ "$os" == "wasi" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 6b185cb2b3cc5..0a4fb1ee19a01 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -60,7 +60,7 @@ if /i "%__Arch%" == "wasm" ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" set __UseEmcmake=1 ) - if "%__Os%" == "WASI" ( + if "%__Os%" == "wasi" ( echo Error: WASI build not implemented on Windows yet exit /B 1 ) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 6e912c66bc8d2..9f5b777b04b3e 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -96,7 +96,7 @@ fi if [[ "$host_arch" == "wasm" ]]; then if [[ "$target_os" == "Browser" ]]; then cmake_command="emcmake $cmake_command" - elif [[ "$target_os" == "WASI" ]]; then + elif [[ "$target_os" == "wasi" ]]; then true else echo "target_os was not specified" diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 18f2a714e57f1..309f6970a0f0f 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -151,7 +151,7 @@ initDistroRidGlobal() if [ "$targetOs" = "Browser" ]; then __DistroRid=browser-wasm export __DistroRid - elif [ "$targetOs" = "WASI" ]; then + elif [ "$targetOs" = "wasi" ]; then __DistroRid=wasi-wasm export __DistroRid fi @@ -191,7 +191,7 @@ initDistroRidGlobal() distroRid="android-$buildArch" elif [ "$targetOs" = "Browser" ]; then distroRid="browser-$buildArch" - elif [ "$targetOs" = "WASI" ]; then + elif [ "$targetOs" = "wasi" ]; then distroRid="wasi-$buildArch" elif [ "$targetOs" = "FreeBSD" ]; then distroRid="freebsd-$buildArch" diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index 305e8f55d9e55..f683aed31e9e9 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -101,11 +101,11 @@ jobs: value: wasm - name: osOverride value: '-os Browser' - - ${{ if eq(parameters.osGroup, 'WASI') }}: + - ${{ if eq(parameters.osGroup, 'wasi') }}: - name: archType value: wasm - name: osOverride - value: '-os WASI' + value: '-os wasi' - ${{ if and(eq(parameters.osGroup, 'Linux'), not(eq(parameters.archType, 'x64'))) }}: name: llvmCxxAbi value: /p:MonoLLVMUseCxx11Abi=true diff --git a/eng/versioning.targets b/eng/versioning.targets index 7189f4c9c7e40..d519199013599 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -86,7 +86,7 @@ diff --git a/src/libraries/OSGroups.json b/src/libraries/OSGroups.json index df35243993b40..2c6aa55fb00e7 100644 --- a/src/libraries/OSGroups.json +++ b/src/libraries/OSGroups.json @@ -4,7 +4,7 @@ }, "Browser" : { }, - "WASI" : { + "wasi" : { }, "Linux": { "#import": [ diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index d3137f27a8bd2..775cf38a68eb5 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -246,7 +246,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # sys/random.h exists, but its not found set(HAVE_SYS_RANDOM_H 1) set(INTERNAL_ZLIB 1) -elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Wasi") set(HOST_WASI 1) add_definitions(-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) add_definitions(-DNO_GLOBALIZATION_SHIM) @@ -334,7 +334,7 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") if (CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-Os) endif() -elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") +elseif(TARGET_SYSTEM_NAME STREQUAL "Wasi") set(TARGET_WASI 1) elseif(TARGET_SYSTEM_NAME STREQUAL "Windows") set(TARGET_WIN32 1) diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index 63651b4d05492..1244f95b6a7ce 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -33,7 +33,7 @@ if /i [%1] == [wasm] ( set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [outconfig] ( set __outConfig=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) -if /i [%1] == [WASI] ( set __TargetOS=WASI&&shift&goto Arg_Loop) +if /i [%1] == [wasi] ( set __TargetOS=wasi&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) @@ -97,7 +97,7 @@ if [%__Ninja%] == [1] ( set __generatorArgs= ) else if [%__TargetOS%] == [Browser] ( set __generatorArgs= -) else if [%__TargetOS%] == [WASI] ( +) else if [%__TargetOS%] == [wasi] ( set __generatorArgs= ) else ( set __generatorArgs=/p:Platform=%__BuildArch% /p:PlatformToolset="%__PlatformToolset%" -noWarn:MSB8065 diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 47600984884f1..d93bffefbdd9f 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -54,7 +54,7 @@ if [[ "$__TargetOS" == Browser ]]; then source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) -elif [[ "$__TargetOS" == WASI ]]; then +elif [[ "$__TargetOS" == wasi ]]; then # nothing to do here true elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then diff --git a/src/tests/build.sh b/src/tests/build.sh index 266b2fe7c4415..024af2df6ffee 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -60,7 +60,7 @@ build_Tests() export MSBUILDDEBUGPATH if [[ "$__SkipNative" != 1 && "$__BuildTestWrappersOnly" != 1 && "$__GenerateLayoutOnly" != 1 && "$__CopyNativeTestBinaries" != 1 && \ - "$__TargetOS" != "Browser" && "$__TargetOS" != "WASI" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then + "$__TargetOS" != "Browser" && "$__TargetOS" != "wasi" && "$__TargetOS" != "Android" && "$__TargetOS" != "iOS" && "$__TargetOS" != "iOSSimulator" ]]; then build_native "$__TargetOS" "$__TargetArch" "$__TestDir" "$__NativeTestIntermediatesDir" "install" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then From e5c416d05954d27d3b99405113beb86cb3ad8b12 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 09:00:01 +0100 Subject: [PATCH 071/116] case --- eng/build.ps1 | 2 +- eng/pipelines/runtime-official.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 88a48512983b6..9382d460248af 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -288,7 +288,7 @@ if ($os -eq "wasi") { $arch = "wasm" if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for wasi on Windows, we need ninja for wasi-SDK." + Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need ninja for WASI-SDK." exit 1 } } diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index 69b40175f77f5..ad8d96e6305d0 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -127,7 +127,7 @@ extends: - Linux_arm64 - Linux_musl_x64 - Browser_wasm - - WASI_wasm + - wasi_wasm - Linux_bionic_arm64 - Linux_bionic_x64 # - Linux_musl_arm From b64750c7f59c4ebd1dd9bcaeb82f4c4434f92285 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 12:16:38 +0100 Subject: [PATCH 072/116] fix --- src/mono/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 775cf38a68eb5..d3137f27a8bd2 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -246,7 +246,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # sys/random.h exists, but its not found set(HAVE_SYS_RANDOM_H 1) set(INTERNAL_ZLIB 1) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Wasi") +elseif(CMAKE_SYSTEM_NAME STREQUAL "WASI") set(HOST_WASI 1) add_definitions(-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN -DHOST_WASI) add_definitions(-DNO_GLOBALIZATION_SHIM) @@ -334,7 +334,7 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten") if (CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-Os) endif() -elseif(TARGET_SYSTEM_NAME STREQUAL "Wasi") +elseif(TARGET_SYSTEM_NAME STREQUAL "WASI") set(TARGET_WASI 1) elseif(TARGET_SYSTEM_NAME STREQUAL "Windows") set(TARGET_WIN32 1) From bc7f69166c0bb26fe405803d1c2b44d5b3c97df4 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 12:43:44 +0100 Subject: [PATCH 073/116] wip --- eng/Subsets.props | 2 +- eng/native/build-commons.sh | 3 - eng/pipelines/common/platform-matrix.yml | 6 +- .../common/templates/wasm-library-tests.yml | 2 +- eng/pipelines/runtime-linker-tests.yml | 2 +- eng/pipelines/runtime.yml | 4 +- .../System.Console/src/System.Console.csproj | 6 +- .../src/System.IO.Compression.csproj | 2 +- .../src/System.IO.MemoryMappedFiles.csproj | 2 +- .../System.Linq/src/System.Linq.csproj | 2 +- .../src/System.Net.Http.csproj | 14 ++-- .../src/System.Net.Mail.csproj | 4 +- .../src/System.Net.NameResolution.csproj | 6 +- .../src/System.Net.Primitives.csproj | 4 +- .../src/System.Net.WebClient.csproj | 4 +- .../src/System.Net.WebProxy.csproj | 4 +- .../src/System.Net.WebSockets.Client.csproj | 2 +- .../src/System.Net.WebSockets.csproj | 2 +- .../src/System.Security.Cryptography.csproj | 4 +- .../src/System.Text.Encodings.Web.csproj | 4 +- src/libraries/pretest.proj | 4 +- src/libraries/shims/src/System.forwards.cs | 8 +-- src/mono/Directory.Build.props | 6 +- src/mono/mono.proj | 30 ++++---- src/mono/sample/wasi/Directory.Build.props | 2 +- src/mono/sample/wasi/Directory.Build.targets | 8 +-- src/mono/wasi/README.md | 6 +- src/mono/wasi/wasi.proj | 68 +++++++++---------- 28 files changed, 104 insertions(+), 107 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index dd1e95722b8d9..ebbed3a291fc5 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -141,7 +141,7 @@ - + diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index e323d276c636c..c9160b1e4b59a 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -168,9 +168,6 @@ build_native() echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" exit_code="$?" - elif [[ "$build_arch" == "wasm" ]]; then - echo "!!!!!!!!!!!!!!! TODOWASI !!!!!!!!!!!!!!" - exit 1 else # For non-wasm Unix scenarios, we may have to use an old version of CMake that doesn't support # multiple targets. Instead, directly invoke the build tool to build multiple targets in one invocation. diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 84c9036566d20..811313008da47 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -376,16 +376,16 @@ jobs: # WASI WebAssembly -- ${{ if containsValue(parameters.platforms, 'WASI_wasm') }}: +- ${{ if containsValue(parameters.platforms, 'wasi_wasm') }}: - template: xplat-setup.yml parameters: jobTemplate: ${{ parameters.jobTemplate }} helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }} variables: ${{ parameters.variables }} - osGroup: WASI + osGroup: wasi archType: wasm targetRid: wasi-wasm - platform: WASI_wasm + platform: wasi_wasm shouldContinueOnError: ${{ parameters.shouldContinueOnError }} container: Linux_x64 jobParameters: diff --git a/eng/pipelines/common/templates/wasm-library-tests.yml b/eng/pipelines/common/templates/wasm-library-tests.yml index 8a00f96810962..a05ca0bf16681 100644 --- a/eng/pipelines/common/templates/wasm-library-tests.yml +++ b/eng/pipelines/common/templates/wasm-library-tests.yml @@ -1,6 +1,6 @@ parameters: alwaysRun: false - buildAndRunWASI: false + buildAndRunWasi: false extraBuildArgs: '' extraHelixArgs: '' isExtraPlatformsBuild: false diff --git a/eng/pipelines/runtime-linker-tests.yml b/eng/pipelines/runtime-linker-tests.yml index 249b3d184277b..40cf37022e80c 100644 --- a/eng/pipelines/runtime-linker-tests.yml +++ b/eng/pipelines/runtime-linker-tests.yml @@ -113,7 +113,7 @@ extends: jobTemplate: /eng/pipelines/common/global-build-job.yml buildConfig: release platforms: - - WASI_wasm + - wasi_wasm jobParameters: testGroup: innerloop timeoutInMinutes: 120 diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 31b055e810656..5647800ba440a 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -371,7 +371,7 @@ extends: parameters: platforms: - Browser_wasm - buildAndRunWASI: true + buildAndRunWasi: true alwaysRun: ${{ variables.isRollingBuild }} scenarios: - normal @@ -458,7 +458,7 @@ extends: - template: /eng/pipelines/common/templates/wasi-build-only.yml parameters: platforms: - - WASI_wasm + - wasi_wasm extraBuildArgs: /p:WasmEnableThreads=true alwaysRun: ${{ variables.isRollingBuild }} diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 6a5d1e9a0ec4f..43f8f2241e157 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -8,7 +8,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole - + $(DefineConstants);TARGET_WASI @@ -159,7 +159,7 @@ Link="Common\System\IO\Win32Marshal.cs" /> - + diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index c0bda04d54b5d..5179e9a2370ed 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -50,7 +50,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + - + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true + true diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index e7e2f42090d56..71d37b41a3bfb 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -20,7 +20,7 @@ $(DefineConstants);TARGET_MACCATALYST $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI $(MSBuildThisFileDirectory)ILLink\ @@ -28,7 +28,7 @@ - + @@ -160,7 +160,7 @@ Link="Common\System\Text\ValueStringBuilder.AppendSpanFormattable.cs" /> - + @@ -308,12 +308,12 @@ - + - + @@ -389,7 +389,7 @@ - + - + diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 295f964742281..61e9001c00834 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -78,12 +78,12 @@ Link="Common\System\HexConverter.cs" /> - + - + diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 69b495ad48d95..ae1e6fd7053e1 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -6,8 +6,8 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Browser.txt + SR.SystemNetNameResolution_PlatformNotSupported + ExcludeApiList.PNSE.Browser.txt @@ -100,7 +100,7 @@ - + diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 171461684848a..c61e34eda1485 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -113,7 +113,7 @@ - + @@ -144,7 +144,7 @@ - + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetWebClient_PlatformNotSupported + SR.SystemNetWebClient_PlatformNotSupported - + diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index f34e25d8f5da9..498629526d7cf 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index 022195496cf02..21cdaa1f0e5d6 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -7,7 +7,7 @@ $(DefineConstants);TARGET_BROWSER - + $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index 5bc522d766f1f..4133f2e95950c 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -40,7 +40,7 @@ Link="Common\Interop\Windows\Interop.Libraries.cs" /> - + diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index a0fed05219f92..37f3691de7cbd 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -549,7 +549,7 @@ System\Security\Cryptography\X509Certificates\Asn1\PolicyInformationAsn.xml - + @@ -1836,7 +1836,7 @@ - + diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 5b0ba2ea8a662..40cddc0f03c44 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -18,9 +18,9 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI - $(NoWarn);CA1418 + $(NoWarn);CA1418 diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index b9ae3d483788a..335db60ce69fb 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -26,14 +26,14 @@ - + + Condition="'$(TargetOS)' == 'wasi' and '$(ContinuousIntegrationBuild)' == 'true'" /> diff --git a/src/libraries/shims/src/System.forwards.cs b/src/libraries/shims/src/System.forwards.cs index baf0b46a673e1..19fac75cffcfc 100644 --- a/src/libraries/shims/src/System.forwards.cs +++ b/src/libraries/shims/src/System.forwards.cs @@ -4,7 +4,7 @@ // Add any internal types that we need to forward from System. // These types are required for Desktop to Core serialization as they are not covered by GenFacades because they are marked as internal. -//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] -//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] -//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] -//[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] +[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 404fa0ad70d6a..77506546701cc 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -46,9 +46,9 @@ - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) - $(ProvisionWASISdkDir.Replace('\', '/')) - true + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) + $(ProvisionWasiSdkDir.Replace('\', '/')) + true diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e6796174a9f74..3e0a7ecd1f700 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -167,31 +167,31 @@ - + - $(ProvisionWASISdkDir) - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) - %(_VersionLines.Identity) - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASISdkVersion)/wasi-sdk-$(WASISdkVersion).0-linux.tar.gz - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WASISdkVersion)/wasi-sdk-$(WASISdkVersion).0-macos.tar.gz + $(ProvisionWasiSdkDir) + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi')) + %(_VersionLines.Identity) + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz - - + - + @@ -199,11 +199,11 @@ - %(_ActualVersionLines.Identity) - %(_ExpectedVersionLines.Identity) + %(_ActualVersionLines.Identity) + %(_ExpectedVersionLines.Identity) + Condition="'$(ActualWasiSdkVersion)' != '$(ExpectedWasiSdkVersion)'" /> @@ -870,7 +870,7 @@ CheckEnv;GetXcodeDir;GenerateRuntimeVersionFile;BuildMonoRuntime;BuildMonoCross GenerateRuntimeVersionFile;ProvisionEmscripten;$(MonoDependsOnTargets) - GenerateRuntimeVersionFile;ProvisionWASISdk;ValidateWASISdk;$(MonoDependsOnTargets) + GenerateRuntimeVersionFile;ProvisionWasiSdk;ValidateWasiSdk;$(MonoDependsOnTargets) diff --git a/src/mono/sample/wasi/Directory.Build.props b/src/mono/sample/wasi/Directory.Build.props index 722c684126f17..f2ecb0d30b5db 100644 --- a/src/mono/sample/wasi/Directory.Build.props +++ b/src/mono/sample/wasi/Directory.Build.props @@ -15,7 +15,7 @@ bin - false + false diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index ad286957bd339..a8c8e9a1c55f8 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -25,14 +25,14 @@ <_AOTFlag Condition="'$(RunAOTCompilation)' != ''">/p:RunAOTCompilation=$(RunAOTCompilation) <_WasmMainJSFileName>$([System.IO.Path]::GetFileName('$(WasmMainJSPath)')) - + - + - diff --git a/src/mono/wasi/README.md b/src/mono/wasi/README.md index 8d20546f11da0..66e59384297bb 100644 --- a/src/mono/wasi/README.md +++ b/src/mono/wasi/README.md @@ -10,11 +10,11 @@ The mechanism for executing .NET code in a WASI runtime environment is equivalen on Linux: ```.sh -./build.sh -bl -os WASI -subset mono+libs -c Debug +./build.sh -bl -os wasi -subset mono+libs -c Debug ``` or for just native rebuild ```.sh -./build.sh -bl -os WASI -subset mono.runtime+libs.native+mono.wasiruntime -c Debug +./build.sh -bl -os wasi -subset mono.runtime+libs.native+mono.wasiruntime -c Debug ``` ### 3. Run it @@ -22,7 +22,7 @@ or for just native rebuild Finally, you can build and run the sample: ``` -./dotnet.sh build /p:TargetOS=WASI /p:Configuration=Debug /t:RunSample src/mono/sample/wasi/console +./dotnet.sh build /p:TargetOS=wasi /p:Configuration=Debug /t:RunSample src/mono/sample/wasi/console ``` ### 4. Debug it diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 92b5b7affce44..c84ed9132f602 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -13,15 +13,15 @@ false false $(ArtifactsObjDir)wasm - <_WASIDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp - <_WASICompileRspPath>$(NativeBinDir)src\wasi-compile.rsp - <_WASILinkRspPath>$(NativeBinDir)src\wasi-link.rsp + <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp + <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp + <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp false - + @@ -76,12 +76,12 @@ - + @@ -92,24 +92,24 @@ - <_WASIFlags Include="@(_WASICommonFlags)" /> - - <_WASICompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_WASICompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> - <_WASICompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> - <_WASICompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> - <_WASICompileFlags Include="-D_WASI_EMULATED_MMAN"/> - <_WASILinkFlags Include="-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> + <_WasiFlags Include="@(_WasiCommonFlags)" /> + + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> + <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> + <_WasiLinkFlags Include="-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman"/> <_WasmOptConfigurationFlags>@(WasmOptConfigurationFlags, '%3B ') - <_WASIPropsJson> + <_WasiPropsJson> - + - - - - + DependsOnTargets="GenerateWasiPropsAndRspFiles;GenerateManagedToNative;BundleTimeZones"> -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 - -Oz + -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 + -Oz - $(CMakeConfigurationWASIFlags) + $(CMakeConfigurationWasiFlags) -O2 cmake $(MSBuildThisFileDirectory)runtime @@ -170,7 +170,7 @@ $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" - $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWASIFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WasiCC_FLAGS="$(CMakeConfigurationWasiFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" From 3e560f3a3c958425ed82a0fa317230ea1c3fb8e0 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:46:34 +0100 Subject: [PATCH 074/116] Update eng/build.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/build.sh b/eng/build.sh index 27b37a1dadd65..80fed9942f975 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -508,7 +508,7 @@ if [[ "$os" == "Browser" ]]; then arch=wasm fi if [[ "$os" == "wasi" ]]; then - # override default arch for Browser, we only support wasm + # override default arch for wasi, we only support wasm arch=wasm fi From 9db9d12ece75762ff0b25c2439f10474af9adff2 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:47:32 +0100 Subject: [PATCH 075/116] Update Directory.Build.props MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index e3491661b53a1..f7753ce342969 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -218,7 +218,7 @@ true true true - true + true true true From f968e7d1a6272b4f9dc84b4558bfdc35ff9231ab Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:50:01 +0100 Subject: [PATCH 076/116] Update eng/native/build-commons.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/native/build-commons.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index c9160b1e4b59a..4522af11f5c59 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -163,7 +163,7 @@ build_native() popd else cmake_command=cmake - if [[ "$build_arch" == "wasm" && "$__TargetOS" == "Browser" ]]; then + if [[ "$build_arch" == "wasm" && "$targetOS" == "Browser" ]]; then cmake_command="emcmake cmake" echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" From 7fb65a9c38481bb94bbbeadb809dfe3e7835f428 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:50:14 +0100 Subject: [PATCH 077/116] Update src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- .../src/System.Private.CoreLib.Shared.projitems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index dfcd339f290a8..f1070474198a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -37,7 +37,7 @@ $(DefineConstants);TARGET_IOS $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER - $(DefineConstants);TARGET_WASI + $(DefineConstants);TARGET_WASI $(DefineConstants);TARGET_ANDROID $(DefineConstants);TARGET_LINUX $(DefineConstants);TARGET_FREEBSD From b8591f290f0bac264931d7612f4330940e1983ea Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:51:11 +0100 Subject: [PATCH 078/116] Update eng/native/gen-buildsys.cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/native/gen-buildsys.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 0a4fb1ee19a01..38f493c9fb8d0 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -60,7 +60,7 @@ if /i "%__Arch%" == "wasm" ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" set __UseEmcmake=1 ) - if "%__Os%" == "wasi" ( + if /i "%__Os%" == "wasi" ( echo Error: WASI build not implemented on Windows yet exit /B 1 ) From 69fdb0337977ab2bc501e4c034b91e1baa2b83aa Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:51:24 +0100 Subject: [PATCH 079/116] Update eng/native/gen-buildsys.cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/native/gen-buildsys.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 38f493c9fb8d0..b97b8125e0f8c 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -46,7 +46,7 @@ if /i "%__Arch%" == "wasm" ( echo Error: Please add target OS parameter exit /B 1 ) - if "%__Os%" == "Browser" ( + if /i "%__Os%" == "Browser" ( if "%EMSDK_PATH%" == "" ( if not exist "%__repoRoot%src\mono\wasm\emsdk" ( echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root. From 87b2d3550cab9c28c06a2e05f3984ceb6eaf879b Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:51:39 +0100 Subject: [PATCH 080/116] Update src/coreclr/scripts/coreclr_arguments.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- src/coreclr/scripts/coreclr_arguments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py index 92ecc6e8d3930..4f3f8abe56df2 100644 --- a/src/coreclr/scripts/coreclr_arguments.py +++ b/src/coreclr/scripts/coreclr_arguments.py @@ -65,7 +65,7 @@ def __init__(self, self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "wasm"] self.valid_build_types = ["Debug", "Checked", "Release"] - self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "WASI"] + self.valid_host_os = ["windows", "OSX", "Linux", "illumos", "Solaris", "Browser", "Android", "wasi"] self.__initialize__(args) From bbed97d71bf855ec0b83bd2ecc79ab895ee7af9f Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 12:51:56 +0100 Subject: [PATCH 081/116] Update src/native/libs/build-native.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- src/native/libs/build-native.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index d93bffefbdd9f..e2d25a1a0c0da 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -45,7 +45,7 @@ source "$__RepoRootDir"/eng/native/build-commons.sh if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasm/emsdk/ ]]; then - export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ + export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/" else echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." exit 1 From 08283016cc62194ce3d34c420924eb3a0ceb3bbf Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 13:18:39 +0100 Subject: [PATCH 082/116] fix --- eng/native/build-commons.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 4522af11f5c59..c9160b1e4b59a 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -163,7 +163,7 @@ build_native() popd else cmake_command=cmake - if [[ "$build_arch" == "wasm" && "$targetOS" == "Browser" ]]; then + if [[ "$build_arch" == "wasm" && "$__TargetOS" == "Browser" ]]; then cmake_command="emcmake cmake" echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc" $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc" From 7a058df34844ceeafef99c402cf32d4bdb4286ea Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 13:50:11 +0100 Subject: [PATCH 083/116] case --- Directory.Build.props | 6 +++--- eng/testing/linker/SupportFiles/Directory.Build.targets | 2 +- eng/testing/linker/trimmingTests.targets | 8 ++++---- .../src/System.Runtime.InteropServices.JavaScript.csproj | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f7753ce342969..97b4e3e09bdf3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -180,9 +180,9 @@ <_toolsRID Condition="'$(_toolsRID)' == ''">$(_runtimeOS)-$(_hostArch) - <_toolsRID Condition="'$(_runtimeOS)' == 'browser'">linux-x64 - <_toolsRID Condition="'$(_runtimeOS)' == 'browser' and '$(HostOS)' == 'windows'">win-x64 - <_toolsRID Condition="'$(_runtimeOS)' == 'browser' and '$(HostOS)' == 'osx'">osx-x64 + <_toolsRID Condition="'$(_runtimeOS)' == 'Browser'">linux-x64 + <_toolsRID Condition="'$(_runtimeOS)' == 'Browser' and '$(HostOS)' == 'windows'">win-x64 + <_toolsRID Condition="'$(_runtimeOS)' == 'Browser' and '$(HostOS)' == 'osx'">osx-x64 <_toolsRID Condition="'$(_runtimeOS)' == 'android' or '$(_runtimeOS)' == 'linux-bionic'">linux-x64 diff --git a/eng/testing/linker/SupportFiles/Directory.Build.targets b/eng/testing/linker/SupportFiles/Directory.Build.targets index e735d71fa0f72..0e960695809e6 100644 --- a/eng/testing/linker/SupportFiles/Directory.Build.targets +++ b/eng/testing/linker/SupportFiles/Directory.Build.targets @@ -10,7 +10,7 @@ + Condition="'$(TargetArchitecture)' == 'wasm' And '$(TargetOS)' == 'Browser'" /> $(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets diff --git a/eng/testing/linker/trimmingTests.targets b/eng/testing/linker/trimmingTests.targets index 9f821e99c2a3a..26624e765089a 100644 --- a/eng/testing/linker/trimmingTests.targets +++ b/eng/testing/linker/trimmingTests.targets @@ -31,10 +31,10 @@ %(ProjectDir)project.csproj - $([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'publish', 'project')) - $([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'AppBundle', 'run-v8.sh')) - $([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'publish')) - $([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'AppBundle')) + $([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'publish', 'project')) + $([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'AppBundle', 'run-v8.sh')) + $([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'publish')) + $([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '%(TargetFramework)', '%(TestRuntimeIdentifier)', 'AppBundle')) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj index 7c007bd484aba..7ef580cd5ea70 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent) true - true + true $(DefineConstants);FEATURE_WASM_THREADS From 5eb412d2a7c38c3f467da52dedb6ebca11155c0e Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 16 Nov 2022 13:54:35 +0100 Subject: [PATCH 084/116] fix --- src/native/libs/build-native.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index e2d25a1a0c0da..d93bffefbdd9f 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -45,7 +45,7 @@ source "$__RepoRootDir"/eng/native/build-commons.sh if [[ "$__TargetOS" == Browser ]]; then if [[ -z "$EMSDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasm/emsdk/ ]]; then - export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/" + export EMSDK_PATH="$__RepoRootDir"/src/mono/wasm/emsdk/ else echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." exit 1 From 5aca392448bcb40071df40b30e45f364ad2e3fd6 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 15:53:27 +0100 Subject: [PATCH 085/116] wip --- src/libraries/System.Console/src/System.Console.csproj | 1 + .../System.IO.Compression/src/System.IO.Compression.csproj | 1 + .../src/System.IO.MemoryMappedFiles.csproj | 1 + src/libraries/System.Linq/src/System.Linq.csproj | 1 + src/libraries/System.Net.Http/src/System.Net.Http.csproj | 2 -- src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 1 + .../src/System.Net.NameResolution.csproj | 1 + .../System.Net.Primitives/src/System.Net.Primitives.csproj | 1 + .../System.Net.WebClient/src/System.Net.WebClient.csproj | 1 + .../System.Net.WebProxy/src/System.Net.WebProxy.csproj | 2 ++ .../src/System.Net.WebSockets.Client.csproj | 5 ++--- .../System.Net.WebSockets/src/System.Net.WebSockets.csproj | 1 + .../ref/System.Runtime.Serialization.Formatters.csproj | 2 ++ .../src/System.Runtime.Serialization.Formatters.csproj | 1 + .../src/System.Security.Cryptography.csproj | 1 + .../src/System.Text.Encodings.Web.csproj | 5 ++--- src/mono/wasm/runtime/gc-common.h | 2 +- .../libs/System.Globalization.Native/pal_icushim_static.c | 2 +- 18 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 43f8f2241e157..bf2d00fdc3977 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -6,6 +6,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(NoWarn);CA1418 SR.PlatformNotSupported_SystemConsole diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index 5179e9a2370ed..cfa84d1c90a33 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -7,6 +7,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_Compression + $(NoWarn);CA1418 diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index 4dcee115f02f0..3092e00dab960 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -7,6 +7,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_MemoryMappedFiles + $(NoWarn);CA1418 diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index 993638eedd83d..988e942b7e12c 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -6,6 +6,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) true + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 71d37b41a3bfb..c882589d8f830 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -5,9 +5,7 @@ $(DefineConstants);HTTP_DLL $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent) true - diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 61e9001c00834..44a92f8196a45 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -7,6 +7,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetMail + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index ae1e6fd7053e1..913861839679b 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -8,6 +8,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemNetNameResolution_PlatformNotSupported ExcludeApiList.PNSE.Browser.txt + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index c61e34eda1485..704a262ff816f 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -12,6 +12,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetPrimitives ReferenceAssemblyExclusions.txt + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj index 3b0b9533cf661..e9aa43cd1cef5 100644 --- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj +++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj @@ -6,6 +6,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemNetWebClient_PlatformNotSupported + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index 498629526d7cf..c4d7a583f8f9c 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -2,6 +2,8 @@ true $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index 21cdaa1f0e5d6..a078ac5e1725c 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -3,13 +3,12 @@ True $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + wasi + $(NoWarn);CA1418;CA1416 $(DefineConstants);TARGET_BROWSER - - $(DefineConstants);TARGET_WASI - diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index 4133f2e95950c..75e4871a31e5a 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -7,6 +7,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_WebSockets + $(NoWarn);CA1418 diff --git a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj index d6f7d98bc527d..e2c2e72bb32ea 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj @@ -1,6 +1,8 @@ $(NetCoreAppCurrent) + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(NoWarn);CA1418 diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index ebd413ee0fcde..4ed56a9123f51 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -11,6 +11,7 @@ $(NoWarn);CS0649 $(NoWarn);CA1822;IDE0060 + $(NoWarn);CA1418 diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index 37f3691de7cbd..df36fd7ab34a3 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -17,6 +17,7 @@ true true true + $(NoWarn);CA1418 diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 40cddc0f03c44..d57b35aa41700 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -4,7 +4,7 @@ true - $(NoWarn);CS3011;CS3019;CA1418 + $(NoWarn);CS3011;CS3019 true Provides types for encoding and escaping strings for use in JavaScript, HyperText Markup Language (HTML), and uniform resource locators (URL). @@ -19,8 +19,7 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER $(DefineConstants);TARGET_WASI - - $(NoWarn);CA1418 + $(NoWarn);CA1418 diff --git a/src/mono/wasm/runtime/gc-common.h b/src/mono/wasm/runtime/gc-common.h index a38752ddffc43..4432633db7645 100644 --- a/src/mono/wasm/runtime/gc-common.h +++ b/src/mono/wasm/runtime/gc-common.h @@ -1,7 +1,7 @@ #define PVOLATILE(T) T* volatile #define PPVOLATILE(T) T* volatile * -#if !defined(TARGET_BROWSER) +#if !defined(TARGET_BROWSER) && !defined(EMSCRIPTEN_KEEPALIVE) #define EMSCRIPTEN_KEEPALIVE #endif diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index fd66ea072c94b..0011460460668 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -48,7 +48,7 @@ static void U_CALLCONV icu_trace_data(const void* context, int32_t fnNumber, int #if defined(TARGET_BROWSER) || defined(TARGET_WASI) #ifdef __EMSCRIPTEN__ #include -#else +#elif !defined(EMSCRIPTEN_KEEPALIVE) #define EMSCRIPTEN_KEEPALIVE #endif From ab59ee338349df39f3c282a7387136c7626536f7 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 17:31:55 +0100 Subject: [PATCH 086/116] wip --- eng/versioning.targets | 6 ++++++ src/mono/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/versioning.targets b/eng/versioning.targets index d519199013599..b4f6471c93f95 100644 --- a/eng/versioning.targets +++ b/eng/versioning.targets @@ -65,6 +65,9 @@ true + + true + @@ -78,6 +81,9 @@ + + + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index d6e91608e4c0b..354f081802e2f 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -681,7 +681,7 @@ elseif(HOST_OSX AND NOT HOST_MACCAT) set(OSX_ICU_LIBRARY_PATH /usr/lib/libicucore.dylib) set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) -elseif(HOST_WASM) +elseif(HOST_BROWSER) set(ICU_FLAGS "-DPALEXPORT=\"\" -DU_DISABLE_RENAMING -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) From e48915bba77c076a0de62229ebb104c5edecc102 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 20:14:15 +0100 Subject: [PATCH 087/116] wip --- src/mono/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index f77f18f766e7c..02b0e765f0172 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -679,6 +679,10 @@ elseif(HOST_OSX AND NOT HOST_MACCAT) set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) elseif(HOST_BROWSER) + set(HAVE_SYS_ICU 0) + set(STATIC_ICU 1) + set(ICU_LIBS "icucore") +elseif(HOST_WASI) set(ICU_FLAGS "-DPALEXPORT=\"\" -DU_DISABLE_RENAMING -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) From cbd4f969e6a6b30c3ecf3400e4a6b365afa65019 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 20:44:09 +0100 Subject: [PATCH 088/116] wip --- eng/native/configureplatform.cmake | 8 ++-- .../System.Private.CoreLib.Shared.projitems | 20 ++++---- src/mono/CMakeLists.txt | 4 +- src/mono/Directory.Build.props | 4 +- .../System.Private.CoreLib.csproj | 18 ++++---- src/mono/cmake/configure.cmake | 4 +- src/mono/mono.proj | 46 +++++++++---------- 7 files changed, 52 insertions(+), 52 deletions(-) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 2e10489fb370d..b064079402eb4 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -214,9 +214,9 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten) set(CLR_CMAKE_HOST_BROWSER 1) endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten) -if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +if(CLR_CMAKE_TARGET_OS STREQUAL WASI) set(CLR_CMAKE_HOST_WASI 1) -endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +endif(CLR_CMAKE_TARGET_OS STREQUAL WASI) #-------------------------------------------- # This repo builds two set of binaries @@ -417,9 +417,9 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) set(CLR_CMAKE_TARGET_BROWSER 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten) -if(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +if(CLR_CMAKE_TARGET_OS STREQUAL WASI) set(CLR_CMAKE_TARGET_WASI 1) -endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi) +endif(CLR_CMAKE_TARGET_OS STREQUAL WASI) if(CLR_CMAKE_TARGET_UNIX) if(CLR_CMAKE_TARGET_ARCH STREQUAL x64) diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 0aa3dd35b0c89..7252f1f4260e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -12,7 +12,7 @@ enable true true - true + true true true true @@ -20,7 +20,7 @@ $(MSBuildThisFileDirectory)ILLink\ true true - true + true $(DefineConstants);BIGENDIAN @@ -2020,7 +2020,7 @@ - + Common\Interop\Unix\Interop.Errors.cs @@ -2269,7 +2269,7 @@ - + @@ -2278,7 +2278,7 @@ - + @@ -2312,7 +2312,7 @@ - + @@ -2416,7 +2416,7 @@ - + @@ -2429,11 +2429,11 @@ - + - + @@ -2451,7 +2451,7 @@ - + diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 02b0e765f0172..362c402dabd5c 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -678,11 +678,11 @@ elseif(HOST_OSX AND NOT HOST_MACCAT) set(OSX_ICU_LIBRARY_PATH /usr/lib/libicucore.dylib) set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) -elseif(HOST_BROWSER) +elseif(HOST_WASI) set(HAVE_SYS_ICU 0) set(STATIC_ICU 1) set(ICU_LIBS "icucore") -elseif(HOST_WASI) +elseif(HOST_BROWSER) set(ICU_FLAGS "-DPALEXPORT=\"\" -DU_DISABLE_RENAMING -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 77506546701cc..ef74df52c446a 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -45,7 +45,7 @@ - + $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi', 'wasi-sdk')) $(ProvisionWasiSdkDir.Replace('\', '/')) true @@ -60,7 +60,7 @@ true true true <_MonoUseLLVMPackage Condition="'$(MonoLLVMDir)' == '' and '$(MonoEnableLLVM)' == 'true'">true diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index a878e2f8787d0..ff4796b0ca82e 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -121,13 +121,13 @@ $(DefineConstants);MONO_FEATURE_SRE true - true - true + true + true true true - true - true - true + true + true + true true @@ -274,16 +274,16 @@ - + - + - + - + diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 573f83256a947..9939983f0e089 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -265,12 +265,12 @@ elseif(HOST_IOS) endif() elseif(HOST_MACCAT) set(HAVE_SYSTEM 0) +elseif(HOST_BROWSER) + set(HAVE_FORK 0) elseif(HOST_SOLARIS) set(HAVE_GETPROTOBYNAME 1) set(HAVE_NETINET_TCP_H 1) set(HAVE_GETADDRINFO 1) -elseif(HOST_BROWSER) - set(HAVE_FORK 0) elseif(HOST_WASI) # Redirected to errno.h set(SYS_ERRNO_H 0) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 3e0a7ecd1f700..1ef30c4d58541 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -28,7 +28,7 @@ $(CoreClrLibName) $(LibPrefix)$(MonoSharedLibName)$(LibSuffix) $(LibPrefix)$(MonoLibName)$(StaticLibSuffix) - $(MonoStaticLibFileName) + $(MonoStaticLibFileName) $(MonoSharedLibFileName) mono-aot-cross$(ExeSuffix) mono-aot-cross.pdb @@ -43,13 +43,13 @@ true true true $([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross')) $([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'config.h')) true - true + true $(Compiler) clang <_CompilerTargetArch Condition="'$(RealTargetArchitecture)' == ''">$(Platform) @@ -65,7 +65,7 @@ coop - preemptive + preemptive hybrid @@ -73,7 +73,7 @@ true - true + true true true false @@ -84,12 +84,12 @@ true - + - + <_MonoCMakeArgs Include="-DENABLE_WERROR=1"/> @@ -102,7 +102,7 @@ - + @@ -383,19 +383,19 @@ <_MonoBuildEnv Condition="'$(BuildArchitecture)' == 'arm64'" Include="arch -arch arm64" /> - + <_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages <_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads <_MonoMinimal Condition="'$(MonoWasmThreadsNoUser)' == 'true'">$(_MonoMinimal),wasm_user_threads - + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/> <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> - <_MonoCMakeArgs Condition="'$(TargetsWASI)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> + <_MonoCMakeArgs Condition="'$(TargetsWasi)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> <_MonoCMakeArgs Include="-DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm"/> <_MonoCFLAGS Include="-fexceptions"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> @@ -407,7 +407,7 @@ <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - + @@ -879,7 +879,7 @@ <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true'">$(MonoObjDir)out\bin\$(MonoFileName) <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName) <_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName) - <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWASI)' == 'true'">true + <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true <_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true From ff3575e45cda896217a7c8717ffa13ed5b768477 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 21:09:07 +0100 Subject: [PATCH 089/116] wip --- src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index ff4796b0ca82e..2f2c8230c771c 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -301,6 +301,9 @@ + + + From e71c206d7c338cb9cd41365300be5d2120a730d6 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 21:53:38 +0100 Subject: [PATCH 090/116] wip --- src/mono/wasi/wasi.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index a7ef8b59ba312..021bfa9a7971a 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -169,7 +169,7 @@ $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" - $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WasiCC_FLAGS="$(CMakeConfigurationWasiFlags)" + $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" From 8a361b2b4fbe7a60bafa1c3409456d046b50ef2c Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 21:59:55 +0100 Subject: [PATCH 091/116] wip --- src/mono/wasi/runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 2019a462421b9..8e4114f0c31e4 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -19,9 +19,9 @@ target_link_libraries(dotnet ${MONO_ARTIFACTS_DIR}/libmono-component-hot_reload-static.a ${MONO_ARTIFACTS_DIR}/libmono-component-debugger-static.a ${MONO_ARTIFACTS_DIR}/libmono-component-diagnostics_tracing-stub-static.a + ${MONO_ARTIFACTS_DIR}/libmono-component-marshal-ilgen-static.a ${MONO_ARTIFACTS_DIR}/libmono-ee-interp.a ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a - ${MONO_ARTIFACTS_DIR}/libmono-ilgen.a ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a ${NATIVE_BIN_DIR}/libSystem.Native.a ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a From da6a0fc02f3ed117fb554e11c1215090ef9d769a Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 22:00:48 +0100 Subject: [PATCH 092/116] UnsupportedOSPlatformAttribute --- .../src/System/Threading/Monitor.CoreCLR.cs | 2 +- .../src/System/Threading/Monitor.NativeAot.cs | 2 +- .../System/Threading/ThreadPool.Windows.cs | 2 +- .../Security/Cryptography/DSAOpenSsl.cs | 4 +- .../Cryptography/ECDiffieHellmanOpenSsl.cs | 6 +- .../Security/Cryptography/ECDsaOpenSsl.cs | 6 +- .../Security/Cryptography/RSAOpenSsl.cs | 4 +- .../Microsoft.Extensions.Configuration.Xml.cs | 2 +- .../src/XmlDocumentDecryptor.cs | 2 +- .../src/PhysicalFilesWatcher.cs | 14 +- .../Microsoft.Extensions.Hosting.Systemd.cs | 4 +- .../src/SystemdLifetime.cs | 2 +- .../src/SystemdNotifier.cs | 2 +- .../ref/Microsoft.Extensions.Hosting.cs | 10 +- .../src/HostingHostBuilderExtensions.cs | 8 +- .../src/Internal/ConsoleLifetime.cs | 2 +- .../Microsoft.Extensions.Logging.Console.cs | 4 +- .../src/AnsiParsingLogConsole.cs | 2 +- .../src/ConsoleLogger.cs | 2 +- .../src/ConsoleLoggerExtensions.cs | 6 +- .../src/ConsoleLoggerProcessor.cs | 2 +- .../src/ConsoleLoggerProvider.cs | 2 +- .../ref/System.Collections.Concurrent.cs | 2 +- .../Concurrent/BlockingCollection.cs | 4 +- .../System.ComponentModel.TypeConverter.cs | 8 +- .../System/ComponentModel/LicenseManager.cs | 4 +- .../ComponentModel/MaskedTextProvider.cs | 2 +- .../ExtendedProtectionPolicyTypeConverter.cs | 2 +- .../System.Console/ref/System.Console.cs | 48 ++-- .../System.Console/src/System/Console.cs | 58 ++--- .../Diagnostics/Metrics/AggregationManager.cs | 2 +- .../Diagnostics/Metrics/MetricsEventSource.cs | 9 +- .../System.Diagnostics.Tracing.Counters.cs | 10 +- .../Parallel/Channels/AsynchronousChannel.cs | 2 +- .../AsynchronousChannelMergeEnumerator.cs | 2 +- .../Linq/Parallel/Merging/MergeExecutor.cs | 2 +- .../OrderPreservingPipeliningMergeHelper.cs | 2 +- .../OrderPreservingPipeliningSpoolingTask.cs | 2 +- .../Linq/Parallel/Scheduling/SpoolingTask.cs | 4 +- .../src/System/Linq/Parallel/Utils/Sorting.cs | 2 +- .../System.Net.Http/ref/System.Net.Http.cs | 48 ++-- .../BrowserHttpHandler/SocketsHttpHandler.cs | 2 +- .../src/System/Net/Http/HttpClient.cs | 8 +- .../Net/Http/HttpClientHandler.AnyMobile.cs | 36 +-- .../src/System/Net/Http/HttpClientHandler.cs | 36 +-- .../SocketsHttpHandler/SocketsHttpHandler.cs | 2 +- .../System.Net.Mail/ref/System.Net.Mail.cs | 2 +- .../src/System/Net/Mail/SmtpClient.Browser.cs | 2 +- .../src/System/Net/Mail/SmtpClient.cs | 2 +- .../ref/System.Net.ServicePoint.cs | 2 +- .../src/System/Net/ServicePointManager.cs | 2 +- .../ref/System.Net.WebSockets.Client.cs | 28 +- .../ClientWebSocketOptions.cs | 28 +- .../Net/WebSockets/ClientWebSocketOptions.cs | 28 +- .../InteropServices/ComponentActivator.cs | 6 +- .../IsolatedComponentLoadContext.cs | 2 +- .../Diagnostics/Tracing/CounterGroup.cs | 2 +- .../Diagnostics/Tracing/DiagnosticCounter.cs | 2 +- .../Diagnostics/Tracing/EventCounter.cs | 2 +- .../Tracing/IncrementingEventCounter.cs | 2 +- .../Tracing/IncrementingPollingCounter.cs | 2 +- .../Diagnostics/Tracing/PollingCounter.cs | 2 +- .../Runtime/InteropServices/ComWrappers.cs | 2 +- .../PosixSignalRegistration.cs | 2 +- ...DependencyResolver.PlatformNotSupported.cs | 2 +- .../Loader/AssemblyDependencyResolver.cs | 2 +- .../src/System/Text/NormalizationForm.cs | 4 +- .../System/Threading/ManualResetEventSlim.cs | 12 +- .../src/System/Threading/Monitor.cs | 8 +- .../RegisteredWaitHandle.Portable.cs | 2 +- .../src/System/Threading/SemaphoreSlim.cs | 14 +- .../src/System/Threading/Tasks/Task.cs | 14 +- ...umerableExtensions.ToBlockingEnumerable.cs | 4 +- .../src/System/Threading/Thread.cs | 8 +- .../System/Threading/ThreadPoolWorkQueue.cs | 16 +- .../src/System/Xml/XmlUrlResolver.cs | 4 +- .../Configuration/CachingSectionGroup.cs | 2 +- .../Configuration/MemoryCacheElement.cs | 2 +- .../Configuration/MemoryCacheSection.cs | 2 +- .../MemoryCacheSettingsCollection.cs | 2 +- .../src/System/Runtime/Caching/Counters.cs | 2 +- .../Caching/FileChangeNotificationSystem.cs | 2 +- .../ref/System.Runtime.InteropServices.cs | 4 +- .../ref/System.Runtime.Loader.cs | 2 +- .../System.Runtime/ref/System.Runtime.cs | 16 +- .../ref/System.Security.Cryptography.cs | 242 +++++++++--------- .../src/System/Security/Cryptography/Aes.cs | 2 +- .../System/Security/Cryptography/AesCcm.cs | 2 +- .../Cryptography/AesCryptoServiceProvider.cs | 2 +- .../System/Security/Cryptography/AesGcm.cs | 2 +- .../Security/Cryptography/AesManaged.cs | 2 +- .../Security/Cryptography/ChaCha20Poly1305.cs | 2 +- .../Security/Cryptography/CryptoConfig.cs | 8 +- .../src/System/Security/Cryptography/DES.cs | 2 +- .../src/System/Security/Cryptography/DSA.cs | 6 +- .../Security/Cryptography/DSAOpenSsl.cs | 6 +- .../Security/Cryptography/ECDiffieHellman.cs | 6 +- .../Cryptography/ECDiffieHellmanOpenSsl.cs | 4 +- .../src/System/Security/Cryptography/ECDsa.cs | 6 +- .../Security/Cryptography/ECDsaOpenSsl.cs | 4 +- .../System/Security/Cryptography/HMACMD5.cs | 24 +- .../src/System/Security/Cryptography/MD5.cs | 18 +- .../Cryptography/OpenSsl.NotSupported.cs | 46 ++-- .../src/System/Security/Cryptography/RC2.cs | 2 +- .../RC2CryptoServiceProvider.NotSupported.cs | 2 +- .../RC2CryptoServiceProvider.Unix.cs | 2 +- .../RC2CryptoServiceProvider.Windows.cs | 2 +- .../src/System/Security/Cryptography/RSA.cs | 6 +- .../RSACryptoServiceProvider.NotSupported.cs | 4 +- .../RSACryptoServiceProvider.Unix.cs | 4 +- .../RSACryptoServiceProvider.Windows.cs | 4 +- .../Security/Cryptography/RSAOpenSsl.cs | 6 +- .../RSAPKCS1SignatureDeformatter.cs | 2 +- .../RSAPKCS1SignatureFormatter.cs | 2 +- .../System/Security/Cryptography/Rijndael.cs | 2 +- .../Cryptography/RijndaelImplementation.cs | 2 +- .../Security/Cryptography/RijndaelManaged.cs | 2 +- .../Cryptography/SafeEvpPKeyHandle.OpenSsl.cs | 6 +- .../System/Security/Cryptography/TripleDES.cs | 2 +- .../X509Certificates/CertificateRequest.cs | 2 +- .../X509Certificates/PublicKey.cs | 8 +- .../X509Certificates/X509Certificate.cs | 30 +-- .../X509Certificates/X509Certificate2.cs | 48 ++-- .../X509Certificates/X509Chain.cs | 2 +- .../ref/System.Threading.Thread.cs | 8 +- .../ref/System.Threading.ThreadPool.cs | 18 +- .../System.Threading/ref/System.Threading.cs | 72 +++--- .../src/System/Threading/Barrier.cs | 18 +- .../src/System/Threading/CountdownEvent.cs | 12 +- .../src/System/Threading/ReaderWriterLock.cs | 12 +- .../ref/System.Transactions.Local.cs | 4 +- .../Transactions/CommittableTransaction.cs | 2 +- .../System/Transactions/TransactionScope.cs | 2 +- .../ref/System.Xml.ReaderWriter.cs | 4 +- .../src/System/Threading/Monitor.Mono.cs | 2 +- .../Threading/ThreadPool.Browser.Mono.cs | 2 +- 136 files changed, 658 insertions(+), 651 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Threading/Monitor.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Threading/Monitor.CoreCLR.cs index c3257f9fc10df..56dca6c0d9ec4 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Threading/Monitor.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Threading/Monitor.CoreCLR.cs @@ -147,7 +147,7 @@ public static bool IsEntered(object obj) [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool ObjWait(int millisecondsTimeout, object obj); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, int millisecondsTimeout) { if (obj == null) 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 f5317ff6d22ed..75b1f7102c307 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 @@ -126,7 +126,7 @@ public static bool IsEntered(object obj) #region Public Wait/Pulse methods - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, int millisecondsTimeout) { Condition condition = GetCondition(obj); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs index 97217e7c615ef..f3a789cbaa276 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs @@ -14,7 +14,7 @@ namespace System.Threading // Windows-specific implementation of ThreadPool // #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public sealed class RegisteredWaitHandle : MarshalByRefObject { diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs index d10cc1ea870cc..203a91cdccfb7 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs @@ -25,7 +25,7 @@ public sealed partial class DSAOpenSsl : DSA, IRuntimeAlgorithm private Lazy? _key; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -35,7 +35,7 @@ public DSAOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs index 2f962e19fc3ef..4a49794c7d1e4 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs @@ -12,7 +12,7 @@ public sealed partial class ECDiffieHellmanOpenSsl : ECDiffieHellman private ECOpenSsl? _key; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -24,7 +24,7 @@ public ECDiffieHellmanOpenSsl(ECCurve curve) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -34,7 +34,7 @@ public ECDiffieHellmanOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs index 242711f8e5cf4..5e33c7fb33627 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs @@ -23,7 +23,7 @@ public sealed partial class ECDsaOpenSsl : ECDsa, IRuntimeAlgorithm /// The representing the curve. /// if is null. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -38,7 +38,7 @@ public ECDsaOpenSsl(ECCurve curve) /// Create an ECDsaOpenSsl algorithm with a random 521 bit key pair. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -52,7 +52,7 @@ public ECDsaOpenSsl() /// /// Size of the key to generate, in bits. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs b/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs index db6046ec7830b..6f606c747a212 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs @@ -20,7 +20,7 @@ public sealed partial class RSAOpenSsl : RSA, IRuntimeAlgorithm private Lazy? _key; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -30,7 +30,7 @@ public RSAOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs index 84d26a3faf4ea..6c711c597e6a4 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/ref/Microsoft.Extensions.Configuration.Xml.cs @@ -33,7 +33,7 @@ public partial class XmlDocumentDecryptor public static readonly Microsoft.Extensions.Configuration.Xml.XmlDocumentDecryptor Instance; protected XmlDocumentDecryptor() { } public System.Xml.XmlReader CreateDecryptingXmlReader(System.IO.Stream input, System.Xml.XmlReaderSettings? settings) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] protected virtual System.Xml.XmlReader DecryptDocumentAndCreateXmlReader(System.Xml.XmlDocument document) { throw null; } } public partial class XmlStreamConfigurationProvider : Microsoft.Extensions.Configuration.StreamConfigurationProvider diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs index 2fe2ce2df91a0..d6dd81db711d3 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs @@ -91,7 +91,7 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett /// /// The document. /// An XmlReader which can read the document. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document) { // Perform the actual decryption step, updating the XmlDocument in-place. diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index f5b5b4520bec7..6326fe5b4e939 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -271,7 +271,7 @@ protected virtual void Dispose(bool disposing) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -307,7 +307,7 @@ ex is DirectoryNotFoundException || } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -316,7 +316,7 @@ private void OnChanged(object sender, FileSystemEventArgs e) OnFileSystemEntryChange(e.FullPath); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -329,7 +329,7 @@ private void OnError(object sender, ErrorEventArgs e) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -355,7 +355,7 @@ ex is SecurityException || } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -395,7 +395,7 @@ private void ReportChangeForMatchedEntries(string path) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] @@ -416,7 +416,7 @@ private void TryDisableFileSystemWatcher() } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.cs index 7d1462aba0005..b559143e7a3d6 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/ref/Microsoft.Extensions.Hosting.Systemd.cs @@ -33,7 +33,7 @@ public static partial class SystemdHelpers public static bool IsSystemdService() { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("maccatalyst")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] @@ -44,7 +44,7 @@ public void Dispose() { } public System.Threading.Tasks.Task StopAsync(System.Threading.CancellationToken cancellationToken) { throw null; } public System.Threading.Tasks.Task WaitForStartAsync(System.Threading.CancellationToken cancellationToken) { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public partial class SystemdNotifier : Microsoft.Extensions.Hosting.Systemd.ISystemdNotifier { public SystemdNotifier() { } diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs index e1b196fb2a6f5..e631e4afb9c91 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdLifetime.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.Hosting.Systemd /// Provides notification messages for application started and stopping, and configures console logging to the systemd format. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index bfde5fe73df6a..946f58706e1c1 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Hosting.Systemd { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public class SystemdNotifier : ISystemdNotifier { private const string NOTIFY_SOCKET = "NOTIFY_SOCKET"; diff --git a/src/libraries/Microsoft.Extensions.Hosting/ref/Microsoft.Extensions.Hosting.cs b/src/libraries/Microsoft.Extensions.Hosting/ref/Microsoft.Extensions.Hosting.cs index 7910670857169..c51fad8533127 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/ref/Microsoft.Extensions.Hosting.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/ref/Microsoft.Extensions.Hosting.cs @@ -84,22 +84,22 @@ public static partial class HostingHostBuilderExtensions public static Microsoft.Extensions.Hosting.IHostBuilder ConfigureLogging(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action configureLogging) { throw null; } public static Microsoft.Extensions.Hosting.IHostBuilder ConfigureServices(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action configureDelegate) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action configureOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action configureOptions) { throw null; } @@ -130,7 +130,7 @@ public void NotifyStopped() { } public void StopApplication() { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public partial class ConsoleLifetime : Microsoft.Extensions.Hosting.IHostLifetime, System.IDisposable diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs index ad09104a153ce..edca555fdf4b0 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs @@ -321,7 +321,7 @@ internal static ServiceProviderOptions CreateDefaultServiceProviderOptions(HostB /// The to configure. /// The same instance of the for chaining. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder) @@ -337,7 +337,7 @@ public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder) /// The delegate for configuring the . /// The same instance of the for chaining. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder, Action configureOptions) @@ -356,7 +356,7 @@ public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder, Act /// A that can be used to cancel the console. /// A that only completes when the token is triggered or shutdown is triggered. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default) @@ -372,7 +372,7 @@ public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationTo /// A that can be used to cancel the console. /// A that only completes when the token is triggered or shutdown is triggered. [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static Task RunConsoleAsync(this IHostBuilder hostBuilder, Action configureOptions, CancellationToken cancellationToken = default) diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs index 372a6146c55d2..f78865467cabd 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/Internal/ConsoleLifetime.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.Hosting.Internal /// Listens for Ctrl+C or SIGTERM and initiates shutdown. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public partial class ConsoleLifetime : IHostLifetime, IDisposable diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs index 0941865d6e3db..752b3800d6c19 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.cs @@ -6,7 +6,7 @@ namespace Microsoft.Extensions.Logging { - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static partial class ConsoleLoggerExtensions { public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder) { throw null; } @@ -72,7 +72,7 @@ public ConsoleLoggerOptions() { } public bool UseUtcTimestamp { get { throw null; } set { } } } [Microsoft.Extensions.Logging.ProviderAliasAttribute("Console")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public partial class ConsoleLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Microsoft.Extensions.Logging.ISupportExternalScope, System.IDisposable { public ConsoleLoggerProvider(Microsoft.Extensions.Options.IOptionsMonitor options) { } diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs index 8cab45f3ffc06..cb2c4c0d3a1bf 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/AnsiParsingLogConsole.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Logging.Console { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] internal sealed class AnsiParsingLogConsole : IConsole diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs index 3a542e6063635..edbad042e2711 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLogger.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Logging.Console /// /// A logger that writes messages in the console. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] internal sealed class ConsoleLogger : ILogger { private readonly string _name; diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs index 160e099097f8c..f896bee082f67 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.Logging { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static class ConsoleLoggerExtensions { internal const string RequiresDynamicCodeMessage = "Binding TOptions to configuration values may require generating dynamic code at runtime."; @@ -163,7 +163,7 @@ private static ILoggingBuilder AddFormatterWithName(this ILoggingBuilder builder } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] internal sealed class ConsoleLoggerFormatterConfigureOptions : ConfigureFromConfigurationOptions where TOptions : ConsoleFormatterOptions where TFormatter : ConsoleFormatter @@ -176,7 +176,7 @@ public ConsoleLoggerFormatterConfigureOptions(ILoggerProviderConfiguration : ConfigurationChangeTokenSource where TOptions : ConsoleFormatterOptions where TFormatter : ConsoleFormatter diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs index ff48c3880c418..51face2a0cd01 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProcessor.cs @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Logging.Console { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] internal class ConsoleLoggerProcessor : IDisposable { private readonly Queue _messageQueue; diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs index 6bbb9b7e3f46c..8dfabeb12637a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Logging.Console /// /// A provider of instances. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [ProviderAlias("Console")] public class ConsoleLoggerProvider : ILoggerProvider, ISupportExternalScope { diff --git a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs index 6c2b09321b7f9..fd84493400d19 100644 --- a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs +++ b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs @@ -7,7 +7,7 @@ #if !BUILDING_CORELIB_REFERENCE namespace System.Collections.Concurrent { - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public partial class BlockingCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable, System.IDisposable { public BlockingCollection() { } diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs index 7a7737f71232a..1c8c5543379e1 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs @@ -39,7 +39,7 @@ namespace System.Collections.Concurrent /// away as an . /// /// Specifies the type of elements in the collection. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [DebuggerTypeProxy(typeof(BlockingCollectionDebugView<>))] [DebuggerDisplay("Count = {Count}, Type = {_collection}")] public class BlockingCollection : IEnumerable, ICollection, IDisposable, IReadOnlyCollection @@ -1762,7 +1762,7 @@ public BlockingCollectionDebugView(BlockingCollection collection) } /// Returns a snapshot of the underlying collection's elements. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items { diff --git a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs index 8e77546fccb68..f7650b0e00793 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -734,9 +734,9 @@ public sealed partial class LicenseManager internal LicenseManager() { } public static System.ComponentModel.LicenseContext CurrentContext { get { throw null; } set { } } public static System.ComponentModel.LicenseUsageMode UsageMode { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static object? CreateWithContext([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type, System.ComponentModel.LicenseContext creationContext) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static object? CreateWithContext([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type, System.ComponentModel.LicenseContext creationContext, object[] args) { throw null; } public static bool IsLicensed(System.Type type) { throw null; } public static bool IsValid(System.Type type) { throw null; } @@ -919,7 +919,7 @@ public MaskedTextProvider(string mask, System.Globalization.CultureInfo? culture public bool Add(string input, out int testPosition, out System.ComponentModel.MaskedTextResultHint resultHint) { throw null; } public void Clear() { } public void Clear(out System.ComponentModel.MaskedTextResultHint resultHint) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public object Clone() { throw null; } public int FindAssignedEditPositionFrom(int position, bool direction) { throw null; } public int FindAssignedEditPositionInRange(int startPosition, int endPosition, bool direction) { throw null; } @@ -2350,7 +2350,7 @@ public partial class ExtendedProtectionPolicyTypeConverter : System.ComponentMod { public ExtendedProtectionPolicyTypeConverter() { } public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public override object? ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; } } } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs index b672334a38375..de7341e512767 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs @@ -115,7 +115,7 @@ private static void CacheProvider(Type type, LicenseProvider? provider) /// creationContext /// as the context in which the licensed instance can be used. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static object? CreateWithContext( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type, LicenseContext creationContext) @@ -128,7 +128,7 @@ private static void CacheProvider(Type type, LicenseProvider? provider) /// specified arguments, using creationContext as the context in which the licensed /// instance can be used. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static object? CreateWithContext( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type, LicenseContext creationContext, diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs index 20c083f9ff152..859a27400d59a 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs @@ -462,7 +462,7 @@ private void Initialize() /// Derived classes can override this method and call base.Clone to get proper cloning semantics but must /// implement the full-parameter constructor (passing parameters to the base constructor as well). /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public object Clone() { MaskedTextProvider clonedProvider; diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs index c918ac07258d0..fc47f7c1418d9 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs @@ -18,7 +18,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( return destinationType == typeof(InstanceDescriptor) || base.CanConvertTo(context, destinationType); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) diff --git a/src/libraries/System.Console/ref/System.Console.cs b/src/libraries/System.Console/ref/System.Console.cs index dfcce82fb96b8..f23a632b4d837 100644 --- a/src/libraries/System.Console/ref/System.Console.cs +++ b/src/libraries/System.Console/ref/System.Console.cs @@ -9,7 +9,7 @@ namespace System public static partial class Console { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.ConsoleColor BackgroundColor { get { throw null; } set { } } @@ -18,30 +18,30 @@ public static partial class Console [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static bool CapsLock { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int CursorLeft { get { throw null; } set { } } public static int CursorSize { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int CursorTop { get { throw null; } set { } } public static bool CursorVisible { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] set { } } public static System.IO.TextWriter Error { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.ConsoleColor ForegroundColor { get { throw null; } set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.IO.TextReader In { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Text.Encoding InputEncoding { get { throw null; } set { } } @@ -50,12 +50,12 @@ public static partial class Console public static bool IsOutputRedirected { get { throw null; } } public static bool KeyAvailable { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int LargestWindowHeight { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int LargestWindowWidth { get { throw null; } } @@ -65,29 +65,29 @@ public static partial class Console public static System.Text.Encoding OutputEncoding { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] set { } } public static string Title { [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static bool TreatControlCAsInput { get { throw null; } set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int WindowHeight { get { throw null; } set { } } public static int WindowLeft { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } public static int WindowTop { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static int WindowWidth { get { throw null; } set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static event System.ConsoleCancelEventHandler? CancelKeyPress { add { } remove { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void Beep() { } @@ -98,7 +98,7 @@ public static void Beep(int frequency, int duration) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void Clear() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static (int Left, int Top) GetCursorPosition() { throw null; } @@ -109,46 +109,46 @@ public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth public static System.IO.Stream OpenStandardError() { throw null; } public static System.IO.Stream OpenStandardError(int bufferSize) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.IO.Stream OpenStandardInput() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.IO.Stream OpenStandardInput(int bufferSize) { throw null; } public static System.IO.Stream OpenStandardOutput() { throw null; } public static System.IO.Stream OpenStandardOutput(int bufferSize) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static int Read() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.ConsoleKeyInfo ReadKey() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.ConsoleKeyInfo ReadKey(bool intercept) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static string? ReadLine() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void ResetColor() { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void SetBufferSize(int width, int height) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void SetCursorPosition(int left, int top) { } public static void SetError(System.IO.TextWriter newError) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void SetIn(System.IO.TextReader newIn) { } @@ -156,7 +156,7 @@ public static void SetOut(System.IO.TextWriter newOut) { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public static void SetWindowPosition(int left, int top) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static void SetWindowSize(int width, int height) { } diff --git a/src/libraries/System.Console/src/System/Console.cs b/src/libraries/System.Console/src/System/Console.cs index 3f86082591046..cdb12b9117aff 100644 --- a/src/libraries/System.Console/src/System/Console.cs +++ b/src/libraries/System.Console/src/System/Console.cs @@ -37,7 +37,7 @@ public static class Console private static PosixSignalRegistration? s_sigQuitRegistration; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static TextReader In @@ -64,7 +64,7 @@ static TextReader EnsureInitialized() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static Encoding InputEncoding @@ -167,7 +167,7 @@ public static bool KeyAvailable } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static ConsoleKeyInfo ReadKey() @@ -176,7 +176,7 @@ public static ConsoleKeyInfo ReadKey() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static ConsoleKeyInfo ReadKey(bool intercept) @@ -299,7 +299,7 @@ static StrongBox EnsureInitialized() public static int CursorSize { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] get { return ConsolePal.CursorSize; } @@ -322,7 +322,7 @@ public static bool CapsLock internal const ConsoleColor UnknownColor = (ConsoleColor)(-1); [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static ConsoleColor BackgroundColor @@ -332,7 +332,7 @@ public static ConsoleColor BackgroundColor } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static ConsoleColor ForegroundColor @@ -342,7 +342,7 @@ public static ConsoleColor ForegroundColor } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static void ResetColor() @@ -353,7 +353,7 @@ public static void ResetColor() public static int BufferWidth { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] get { return ConsolePal.BufferWidth; } @@ -364,7 +364,7 @@ public static int BufferWidth public static int BufferHeight { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] get { return ConsolePal.BufferHeight; } @@ -393,7 +393,7 @@ public static int WindowTop } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int WindowWidth @@ -416,7 +416,7 @@ public static int WindowWidth } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int WindowHeight @@ -445,7 +445,7 @@ public static void SetWindowPosition(int left, int top) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static void SetWindowSize(int width, int height) @@ -469,7 +469,7 @@ public static void SetWindowSize(int width, int height) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int LargestWindowWidth @@ -478,7 +478,7 @@ public static int LargestWindowWidth } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int LargestWindowHeight @@ -491,14 +491,14 @@ public static bool CursorVisible [SupportedOSPlatform("windows")] get { return ConsolePal.CursorVisible; } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] set { ConsolePal.CursorVisible = value; } } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int CursorLeft @@ -508,7 +508,7 @@ public static int CursorLeft } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static int CursorTop @@ -523,7 +523,7 @@ public static int CursorTop /// Columns are numbered from left to right starting at 0. Rows are numbered from top to bottom starting at 0. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static (int Left, int Top) GetCursorPosition() @@ -536,7 +536,7 @@ public static string Title [SupportedOSPlatform("windows")] get { return ConsolePal.Title; } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] set @@ -546,7 +546,7 @@ public static string Title } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static void Beep() @@ -581,7 +581,7 @@ public static void Clear() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static void SetCursorPosition(int left, int top) @@ -596,7 +596,7 @@ public static void SetCursorPosition(int left, int top) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static event ConsoleCancelEventHandler? CancelKeyPress @@ -639,7 +639,7 @@ public static event ConsoleCancelEventHandler? CancelKeyPress } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static bool TreatControlCAsInput @@ -649,7 +649,7 @@ public static bool TreatControlCAsInput } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static Stream OpenStandardInput() @@ -658,7 +658,7 @@ public static Stream OpenStandardInput() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static Stream OpenStandardInput(int bufferSize) { // bufferSize is ignored, other than in argument validation, even in the .NET Framework @@ -700,7 +700,7 @@ public static Stream OpenStandardError(int bufferSize) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static void SetIn(TextReader newIn) @@ -750,7 +750,7 @@ private static void CheckNonNull(object obj, string paramName) // [MethodImplAttribute(MethodImplOptions.NoInlining)] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static int Read() { return In.Read(); @@ -758,7 +758,7 @@ public static int Read() [MethodImplAttribute(MethodImplOptions.NoInlining)] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static string? ReadLine() { return In.ReadLine(); diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs index 8af2391019299..f90e1cdfc2669 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs @@ -11,7 +11,7 @@ namespace System.Diagnostics.Metrics { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [SecuritySafeCritical] internal sealed class AggregationManager { diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index 458d1c9d34e5a..8a700f177e72b 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -235,6 +235,13 @@ public void OnEventCommand(EventCommandEventArgs command) Parent.Error("", "System.Diagnostics.Metrics EventSource not supported on browser"); return; } +#endif +#if OS_ISWASI_SUPPORT + if (OperatingSystem.IsOSPlatform("Wasi")) // TODO replace with https://github.com/dotnet/runtime/issues/78389 + { + Parent.Error("", "System.Diagnostics.Metrics EventSource not supported on WASI"); + return; + } #endif if (command.Command == EventCommand.Update || command.Command == EventCommand.Disable || command.Command == EventCommand.Enable) @@ -379,7 +386,7 @@ private bool LogError(Exception e) private static readonly char[] s_instrumentSeparators = new char[] { '\r', '\n', ',', ';' }; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private void ParseSpecs(string? metricsSpecs) { if (metricsSpecs == null) diff --git a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs index 79a8e9ddd909c..d28f66002684b 100644 --- a/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs +++ b/src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs @@ -4,7 +4,7 @@ namespace System.Diagnostics.Tracing { #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif public abstract partial class DiagnosticCounter : System.IDisposable { @@ -17,7 +17,7 @@ public void AddMetadata(string key, string? value) { } public void Dispose() { } } #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif public partial class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter { @@ -25,7 +25,7 @@ public PollingCounter(string name, System.Diagnostics.Tracing.EventSource eventS public override string ToString() { throw null; } } #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif public partial class IncrementingEventCounter : System.Diagnostics.Tracing.DiagnosticCounter { @@ -35,7 +35,7 @@ public void Increment(double increment = 1) { } public override string ToString() { throw null; } } #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif public partial class IncrementingPollingCounter : System.Diagnostics.Tracing.DiagnosticCounter { @@ -44,7 +44,7 @@ public IncrementingPollingCounter(string name, System.Diagnostics.Tracing.EventS public override string ToString() { throw null; } } #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif public partial class EventCounter : System.Diagnostics.Tracing.DiagnosticCounter { diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs index 95c8d1f658ba1..822966243d868 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs @@ -17,7 +17,7 @@ namespace System.Linq.Parallel /// This is a bounded channel meant for single-producer/single-consumer scenarios. /// /// Specifies the type of data in the channel. - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal sealed class AsynchronousChannel : IDisposable { // The producer will be blocked once the channel reaches a capacity, and unblocked diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs index 161fb73749130..63c15d41025c0 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs @@ -26,7 +26,7 @@ namespace System.Linq.Parallel /// /// /// - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal sealed class AsynchronousChannelMergeEnumerator : MergeEnumerator { private readonly AsynchronousChannel[] _channels; // The channels being enumerated. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs index 5a18d6fd93ca6..773c6313ed1fb 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs @@ -141,7 +141,7 @@ public IEnumerator GetEnumerator() // An array of asynchronous channels, one for each partition. // - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal static AsynchronousChannel[] MakeAsynchronousChannels(int partitionCount, ParallelMergeOptions options, IntValueEvent? consumerEvent, CancellationToken cancellationToken) { AsynchronousChannel[] channels = new AsynchronousChannel[partitionCount]; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs index ddf0377cc9397..9e8fab2836f43 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs @@ -36,7 +36,7 @@ namespace System.Linq.Parallel /// Finally, if the producer notices that its buffer has exceeded an even greater threshold, it will /// go to sleep and wait until the consumer takes the entire buffer. /// - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal sealed class OrderPreservingPipeliningMergeHelper : IMergeHelper { private readonly QueryTaskGroupState _taskGroupState; // State shared among tasks. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs index b419c38ce7839..e15e87e0e1354 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs @@ -18,7 +18,7 @@ namespace System.Linq.Parallel { - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal sealed class OrderPreservingPipeliningSpoolingTask : SpoolingTaskBase { private readonly QueryTaskGroupState _taskGroupState; // State shared among tasks. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs index 198fd693c458d..a7eb275973828 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs @@ -82,7 +82,7 @@ internal static void SpoolStopAndGo( // taskScheduler - the task manager on which to execute // - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal static void SpoolPipeline( QueryTaskGroupState groupState, PartitionedStream partitions, AsynchronousChannel[] channels, TaskScheduler taskScheduler) @@ -262,7 +262,7 @@ protected override void SpoolingFinally() /// /// /// - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] internal sealed class PipelineSpoolingTask : SpoolingTaskBase { // The data source from which to pull data. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs index 5a0fb29343b15..35d2a0a0c0fad 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs @@ -351,7 +351,7 @@ private void QuickSortIndicesInPlace(GrowingArray keys, List // negatively impact speedups. // - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] private void MergeSortCooperatively() { CancellationToken cancelToken = _groupState.CancellationState.MergedCancellationToken; diff --git a/src/libraries/System.Net.Http/ref/System.Net.Http.cs b/src/libraries/System.Net.Http/ref/System.Net.Http.cs index ebbbc59fea446..ab8fde5c1e33b 100644 --- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs +++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs @@ -96,13 +96,13 @@ protected override void Dispose(bool disposing) { } public System.Threading.Tasks.Task PutAsync([System.Diagnostics.CodeAnalysis.StringSyntaxAttribute("Uri")] string? requestUri, System.Net.Http.HttpContent? content, System.Threading.CancellationToken cancellationToken) { throw null; } public System.Threading.Tasks.Task PutAsync(System.Uri? requestUri, System.Net.Http.HttpContent? content) { throw null; } public System.Threading.Tasks.Task PutAsync(System.Uri? requestUri, System.Net.Http.HttpContent? content, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public override System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; } public System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request) { throw null; } public System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption) { throw null; } @@ -113,47 +113,47 @@ public partial class HttpClientHandler : System.Net.Http.HttpMessageHandler { public HttpClientHandler() { } public bool AllowAutoRedirect { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool CheckCertificateRevocationList { get { throw null; } set { } } public System.Net.Http.ClientCertificateOption ClientCertificateOptions { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.CookieContainer CookieContainer { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.ICredentials? Credentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Func DangerousAcceptAnyServerCertificateValidator { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.ICredentials? DefaultProxyCredentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public int MaxAutomaticRedirections { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public int MaxConnectionsPerServer { get { throw null; } set { } } public long MaxRequestContentBufferSize { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public int MaxResponseHeadersLength { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool PreAuthenticate { get { throw null; } set { } } public System.Collections.Generic.IDictionary Properties { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.Net.IWebProxy? Proxy { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Func? ServerCertificateCustomValidationCallback { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Authentication.SslProtocols SslProtocols { get { throw null; } set { } } public virtual bool SupportsAutomaticDecompression { get { throw null; } } public virtual bool SupportsProxy { get { throw null; } } public virtual bool SupportsRedirectConfiguration { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool UseCookies { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool UseDefaultCredentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool UseProxy { get { throw null; } set { } } protected override void Dispose(bool disposing) { } // @@ -161,7 +161,7 @@ protected override void Dispose(bool disposing) { } // API compat will fail until this is fixed // //[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] //[System.Runtime.Versioning.UnsupportedOSPlatformAttributeUnsupportedOSPlatform("ios")] //[System.Runtime.Versioning.UnsupportedOSPlatformAttributeUnsupportedOSPlatform("tvos")] protected internal override System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; } @@ -215,7 +215,7 @@ public HttpMessageInvoker(System.Net.Http.HttpMessageHandler handler) { } public HttpMessageInvoker(System.Net.Http.HttpMessageHandler handler, bool disposeHandler) { } public void Dispose() { } protected virtual void Dispose(bool disposing) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public virtual System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; } public virtual System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; } } @@ -369,7 +369,7 @@ protected override void SerializeToStream(System.IO.Stream stream, System.Net.Tr protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext? context, System.Threading.CancellationToken cancellationToken) { throw null; } protected internal override bool TryComputeLength(out long length) { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public sealed partial class SocketsHttpHandler : System.Net.Http.HttpMessageHandler { public SocketsHttpHandler() { } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs index 1cd0dbdb7a645..9ad76fda29e69 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs @@ -12,7 +12,7 @@ namespace System.Net.Http { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class SocketsHttpHandler : HttpMessageHandler { [UnsupportedOSPlatformGuard("browser")] diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs index 83f4ab8db1166..b039d44b57474 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs @@ -450,19 +450,19 @@ public Task DeleteAsync(Uri? requestUri, CancellationToken #region Advanced Send Overloads - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public HttpResponseMessage Send(HttpRequestMessage request) => Send(request, DefaultCompletionOption, cancellationToken: default); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public HttpResponseMessage Send(HttpRequestMessage request, HttpCompletionOption completionOption) => Send(request, completionOption, cancellationToken: default); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) => Send(request, DefaultCompletionOption, cancellationToken); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public HttpResponseMessage Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) { CheckRequestBeforeSend(request); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs index a355a7af61e03..339bd5d48f311 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.AnyMobile.cs @@ -73,7 +73,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseCookies { get @@ -100,7 +100,7 @@ public bool UseCookies } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public CookieContainer CookieContainer { get @@ -129,7 +129,7 @@ public CookieContainer CookieContainer } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ICredentials? DefaultProxyCredentials { get @@ -156,7 +156,7 @@ public ICredentials? DefaultProxyCredentials } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseDefaultCredentials { // SocketsHttpHandler doesn't have a separate UseDefaultCredentials property. There @@ -211,7 +211,7 @@ public bool UseDefaultCredentials } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ICredentials? Credentials { get @@ -265,7 +265,7 @@ public bool AllowAutoRedirect } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxConnectionsPerServer { get @@ -325,7 +325,7 @@ public long MaxRequestContentBufferSize } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxResponseHeadersLength { get @@ -394,7 +394,7 @@ public ClientCertificateOption ClientCertificateOptions } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509CertificateCollection ClientCertificates { get @@ -416,7 +416,7 @@ public X509CertificateCollection ClientCertificates } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public Func? ServerCertificateCustomValidationCallback { get @@ -446,7 +446,7 @@ public X509CertificateCollection ClientCertificates } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool CheckCertificateRevocationList { get @@ -474,7 +474,7 @@ public bool CheckCertificateRevocationList } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public SslProtocols SslProtocols { get @@ -562,7 +562,7 @@ public virtual bool SupportsRedirectConfiguration } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public DecompressionMethods AutomaticDecompression { get @@ -589,7 +589,7 @@ public DecompressionMethods AutomaticDecompression } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseProxy { get @@ -616,7 +616,7 @@ public bool UseProxy } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public IWebProxy? Proxy @@ -645,7 +645,7 @@ public IWebProxy? Proxy } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool PreAuthenticate { get @@ -672,7 +672,7 @@ public bool PreAuthenticate } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxAutomaticRedirections { get @@ -704,7 +704,7 @@ public int MaxAutomaticRedirections // API compat will fail until this is fixed // //[UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] //[UnsupportedOSPlatform("ios")] //[UnsupportedOSPlatform("tvos")] protected internal override HttpResponseMessage Send(HttpRequestMessage request, @@ -733,7 +733,7 @@ protected internal override Task SendAsync(HttpRequestMessa // lazy-load the validator func so it can be trimmed by the ILLinker if it isn't used. private static Func? s_dangerousAcceptAnyServerCertificateValidator; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static Func DangerousAcceptAnyServerCertificateValidator { get diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs index b1946ac433118..c2ba64f20a449 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs @@ -63,14 +63,14 @@ protected override void Dispose(bool disposing) public virtual bool SupportsProxy => HttpHandlerType.SupportsProxy; public virtual bool SupportsRedirectConfiguration => HttpHandlerType.SupportsRedirectConfiguration; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseCookies { get => _underlyingHandler.UseCookies; set => _underlyingHandler.UseCookies = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public CookieContainer CookieContainer { get => _underlyingHandler.CookieContainer; @@ -82,21 +82,21 @@ public CookieContainer CookieContainer } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public DecompressionMethods AutomaticDecompression { get => _underlyingHandler.AutomaticDecompression; set => _underlyingHandler.AutomaticDecompression = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseProxy { get => _underlyingHandler.UseProxy; set => _underlyingHandler.UseProxy = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public IWebProxy? Proxy @@ -105,21 +105,21 @@ public IWebProxy? Proxy set => _underlyingHandler.Proxy = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ICredentials? DefaultProxyCredentials { get => _underlyingHandler.DefaultProxyCredentials; set => _underlyingHandler.DefaultProxyCredentials = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool PreAuthenticate { get => _underlyingHandler.PreAuthenticate; set => _underlyingHandler.PreAuthenticate = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseDefaultCredentials { // SocketsHttpHandler doesn't have a separate UseDefaultCredentials property. There @@ -142,7 +142,7 @@ public bool UseDefaultCredentials } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ICredentials? Credentials { get => _underlyingHandler.Credentials; @@ -155,14 +155,14 @@ public bool AllowAutoRedirect set => _underlyingHandler.AllowAutoRedirect = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxAutomaticRedirections { get => _underlyingHandler.MaxAutomaticRedirections; set => _underlyingHandler.MaxAutomaticRedirections = value; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxConnectionsPerServer { get => _underlyingHandler.MaxConnectionsPerServer; @@ -202,7 +202,7 @@ public long MaxRequestContentBufferSize } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public int MaxResponseHeadersLength { get => _underlyingHandler.MaxResponseHeadersLength; @@ -242,7 +242,7 @@ public ClientCertificateOption ClientCertificateOptions } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509CertificateCollection ClientCertificates { get @@ -257,7 +257,7 @@ public X509CertificateCollection ClientCertificates } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public Func? ServerCertificateCustomValidationCallback { #if TARGET_BROWSER @@ -275,7 +275,7 @@ public X509CertificateCollection ClientCertificates #endif } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool CheckCertificateRevocationList { get => _underlyingHandler.SslOptions.CertificateRevocationCheckMode == X509RevocationMode.Online; @@ -286,7 +286,7 @@ public bool CheckCertificateRevocationList } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public SslProtocols SslProtocols { get => _underlyingHandler.SslOptions.EnabledSslProtocols; @@ -304,7 +304,7 @@ public SslProtocols SslProtocols // API compat will fail until this is fixed // //[UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] //[UnsupportedOSPlatform("ios")] //[UnsupportedOSPlatform("tvos")] protected internal override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) => @@ -315,7 +315,7 @@ protected internal override Task SendAsync(HttpRequestMessa // lazy-load the validator func so it can be trimmed by the ILLinker if it isn't used. private static Func? s_dangerousAcceptAnyServerCertificateValidator; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static Func DangerousAcceptAnyServerCertificateValidator => Volatile.Read(ref s_dangerousAcceptAnyServerCertificateValidator) ?? Interlocked.CompareExchange(ref s_dangerousAcceptAnyServerCertificateValidator, delegate { return true; }, null) ?? diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs index 3553e0890552a..b451e31c2773d 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs @@ -13,7 +13,7 @@ namespace System.Net.Http { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class SocketsHttpHandler : HttpMessageHandler { private readonly HttpConnectionSettings _settings = new HttpConnectionSettings(); diff --git a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs index 6c91e785def67..8c6c5ced5d42c 100644 --- a/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs +++ b/src/libraries/System.Net.Mail/ref/System.Net.Mail.cs @@ -165,7 +165,7 @@ public enum MailPriority High = 2, } public delegate void SendCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public partial class SmtpClient : System.IDisposable { public SmtpClient() { } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs index 0266f161b4546..4ce88790e11cc 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs @@ -27,7 +27,7 @@ public enum SmtpDeliveryFormat International = 1, // SMTPUTF8 - Email Address Internationalization (EAI) } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs index d323c244dda87..9bcb1bd6520ab 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs @@ -32,7 +32,7 @@ public enum SmtpDeliveryFormat International = 1, // SMTPUTF8 - Email Address Internationalization (EAI) } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public class SmtpClient : IDisposable { private string? _host; diff --git a/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs b/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs index a8282e9d3cc24..454eb446ac9eb 100644 --- a/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs +++ b/src/libraries/System.Net.ServicePoint/ref/System.Net.ServicePoint.cs @@ -48,7 +48,7 @@ internal ServicePointManager() { } public static int DefaultConnectionLimit { get { throw null; } set { } } public static int DnsRefreshTimeout { get { throw null; } set { } } public static bool EnableDnsRoundRobin { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public static System.Net.Security.EncryptionPolicy EncryptionPolicy { get { throw null; } } public static bool Expect100Continue { get { throw null; } set { } } public static int MaxServicePointIdleTime { get { throw null; } set { } } diff --git a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs index 1013bbcd4d2f2..b83365505bb4e 100644 --- a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs +++ b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs @@ -103,7 +103,7 @@ public static int DnsRefreshTimeout public static bool CheckCertificateRevocationList { get; set; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static EncryptionPolicy EncryptionPolicy { get; } = EncryptionPolicy.RequireEncryption; [Obsolete(Obsoletions.WebRequestMessage, DiagnosticId = Obsoletions.WebRequestDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] diff --git a/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs b/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs index d7b7a97d72495..bd6a2e6c8ab56 100644 --- a/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs +++ b/src/libraries/System.Net.WebSockets.Client/ref/System.Net.WebSockets.Client.cs @@ -30,32 +30,32 @@ public override void Dispose() { } public sealed partial class ClientWebSocketOptions { internal ClientWebSocketOptions() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.CookieContainer? Cookies { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool CollectHttpResponseDetails { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.ICredentials? Credentials { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.TimeSpan KeepAliveInterval { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.WebSockets.WebSocketDeflateOptions? DangerousDeflateOptions { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.IWebProxy? Proxy { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Net.Security.RemoteCertificateValidationCallback? RemoteCertificateValidationCallback { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool UseDefaultCredentials { get { throw null; } set { } } - public System.Version HttpVersion { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] set { } } - public System.Net.Http.HttpVersionPolicy HttpVersionPolicy { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] set { } } + public System.Version HttpVersion { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] set { } } + public System.Net.Http.HttpVersionPolicy HttpVersionPolicy { get { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] set { } } public void AddSubProtocol(string subProtocol) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, System.ArraySegment buffer) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void SetRequestHeader(string headerName, string? headerValue) { } } } diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs index 59096fc864d3a..0a2c9f18d5e05 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/ClientWebSocketOptions.cs @@ -19,14 +19,14 @@ internal ClientWebSocketOptions() #region HTTP Settings - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] // Note that some headers are restricted like Host. public void SetRequestHeader(string headerName, string headerValue) { throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseDefaultCredentials { get => throw new PlatformNotSupportedException(); @@ -36,53 +36,53 @@ public bool UseDefaultCredentials public Version HttpVersion { get => Net.HttpVersion.Version11; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] set => throw new PlatformNotSupportedException(); } public System.Net.Http.HttpVersionPolicy HttpVersionPolicy { get => HttpVersionPolicy.RequestVersionOrLower; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public System.Net.ICredentials Credentials { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public System.Net.IWebProxy Proxy { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509CertificateCollection ClientCertificates { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public System.Net.Security.RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public System.Net.CookieContainer Cookies { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool CollectHttpResponseDetails { get => throw new PlatformNotSupportedException(); @@ -115,27 +115,27 @@ public void AddSubProtocol(string subProtocol) internal List RequestedSubProtocols => _requestedSubProtocols ??= new List(); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public TimeSpan KeepAliveInterval { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public WebSocketDeflateOptions? DangerousDeflateOptions { get => throw new PlatformNotSupportedException(); set => throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment buffer) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs index f5d51871981bc..d5435173609b3 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs @@ -47,7 +47,7 @@ internal ClientWebSocketOptions() { } // prevent external instantiation public Version HttpVersion { get => _version; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] set { ThrowIfReadOnly(); @@ -61,7 +61,7 @@ public Version HttpVersion public HttpVersionPolicy HttpVersionPolicy { get => _versionPolicy; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] set { ThrowIfReadOnly(); @@ -69,7 +69,7 @@ public HttpVersionPolicy HttpVersionPolicy } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] // Note that some headers are restricted like Host. public void SetRequestHeader(string headerName, string? headerValue) { @@ -83,7 +83,7 @@ public void SetRequestHeader(string headerName, string? headerValue) internal List RequestedSubProtocols => _requestedSubProtocols ??= new List(); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool UseDefaultCredentials { get => _useDefaultCredentials; @@ -94,7 +94,7 @@ public bool UseDefaultCredentials } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ICredentials? Credentials { get => _credentials; @@ -105,7 +105,7 @@ public ICredentials? Credentials } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public IWebProxy? Proxy { get => _proxy; @@ -116,7 +116,7 @@ public IWebProxy? Proxy } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509CertificateCollection ClientCertificates { get => _clientCertificates ??= new X509CertificateCollection(); @@ -128,7 +128,7 @@ public X509CertificateCollection ClientCertificates } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RemoteCertificateValidationCallback? RemoteCertificateValidationCallback { get => _remoteCertificateValidationCallback; @@ -139,7 +139,7 @@ public RemoteCertificateValidationCallback? RemoteCertificateValidationCallback } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public CookieContainer? Cookies { get => _cookies; @@ -171,7 +171,7 @@ public void AddSubProtocol(string subProtocol) subprotocols.Add(subProtocol); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public TimeSpan KeepAliveInterval { get => _keepAliveInterval; @@ -197,13 +197,13 @@ public TimeSpan KeepAliveInterval /// It is strongly advised to turn off compression when sending data containing secrets by /// specifying flag for such messages. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public WebSocketDeflateOptions? DangerousDeflateOptions { get; set; } internal int ReceiveBufferSize => _receiveBufferSize; internal ArraySegment? Buffer => _buffer; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize) { ThrowIfReadOnly(); @@ -221,7 +221,7 @@ public void SetBuffer(int receiveBufferSize, int sendBufferSize) _buffer = null; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment buffer) { ThrowIfReadOnly(); @@ -248,7 +248,7 @@ public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment /// Indicates whether and should be set when establishing the connection. /// - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool CollectHttpResponseDetails { get => _collectHttpResponseDetails; diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index 12961f17bdb63..6d17c5e86444a 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -17,7 +17,7 @@ internal static partial class ComponentActivator private const string NativeAOTIncompatibleWarningMessage = "The native code for the method requested might not be available at runtime."; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] @@ -53,7 +53,7 @@ private static string MarshalToString(IntPtr arg, string argName) [RequiresDynamicCode(NativeAOTIncompatibleWarningMessage)] [RequiresUnreferencedCode(TrimIncompatibleWarningMessage, Url = "https://aka.ms/dotnet-illink/nativehost")] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] @@ -167,7 +167,7 @@ public static unsafe int GetFunctionPointer(IntPtr typeNameNative, [RequiresUnreferencedCode(TrimIncompatibleWarningMessage, Url = "https://aka.ms/dotnet-illink/nativehost")] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] private static IsolatedComponentLoadContext GetIsolatedComponentLoadContext(string assemblyPath) diff --git a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs index 94ed1f4441ba8..0e5e12877f168 100644 --- a/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs +++ b/src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/IsolatedComponentLoadContext.cs @@ -15,7 +15,7 @@ namespace Internal.Runtime.InteropServices /// dependencies within the ALC and not pollute the default ALC. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("maccatalyst")] [UnsupportedOSPlatform("tvos")] diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs index 703738efbc3c9..7c1209091bb0e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs @@ -9,7 +9,7 @@ namespace System.Diagnostics.Tracing { #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif internal sealed class CounterGroup diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs index 3bbb7eca48f68..ab62eaf6cab81 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs @@ -14,7 +14,7 @@ namespace System.Diagnostics.Tracing /// #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif public abstract class DiagnosticCounter : IDisposable diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs index a2fa85a262be4..edf4897a6a627 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs @@ -18,7 +18,7 @@ namespace System.Diagnostics.Tracing /// #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif public partial class EventCounter : DiagnosticCounter diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs index 3779b2639b8d6..952f60e6918a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs @@ -14,7 +14,7 @@ namespace System.Diagnostics.Tracing /// #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif public partial class IncrementingEventCounter : DiagnosticCounter diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs index bc952cec2a2ad..ffdfe314d0732 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs @@ -16,7 +16,7 @@ namespace System.Diagnostics.Tracing /// #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif public partial class IncrementingPollingCounter : DiagnosticCounter diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs index 450f47abca640..95e5c9d161a26 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs @@ -15,7 +15,7 @@ namespace System.Diagnostics.Tracing /// #if !ES_BUILD_STANDALONE #if !FEATURE_WASM_PERFTRACING - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] #endif #endif public partial class PollingCounter : DiagnosticCounter diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs index 08769a6ab32fd..ac07ad1042a33 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs @@ -70,7 +70,7 @@ public enum CreateObjectFlags /// Class for managing wrappers of COM IUnknown types. /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [CLSCompliant(false)] diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PosixSignalRegistration.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PosixSignalRegistration.cs index 6cec67330022e..037a6a9e84ddf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PosixSignalRegistration.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/PosixSignalRegistration.cs @@ -31,7 +31,7 @@ public sealed partial class PosixSignalRegistration : IDisposable /// On Unix, terminal configuration can be canceled for and . /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static PosixSignalRegistration Create(PosixSignal signal, Action handler) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs index 5f0597bf337be..dea6aad724143 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.PlatformNotSupported.cs @@ -7,7 +7,7 @@ namespace System.Runtime.Loader { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed class AssemblyDependencyResolver diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs index 6e523ab9a2e4b..46ae82c8b2bf8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyDependencyResolver.cs @@ -11,7 +11,7 @@ namespace System.Runtime.Loader { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed class AssemblyDependencyResolver diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/NormalizationForm.cs b/src/libraries/System.Private.CoreLib/src/System/Text/NormalizationForm.cs index 3254499051a15..d5913bdce2508 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/NormalizationForm.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/NormalizationForm.cs @@ -9,9 +9,9 @@ public enum NormalizationForm { FormC = 1, FormD = 2, - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] FormKC = 5, - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] FormKD = 6 } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs index cdcfe33ee97ac..1193bae1a97b6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs @@ -353,7 +353,7 @@ public void Reset() /// The caller of this method blocks indefinitely until the current instance is set. The caller will /// return immediately if the event is currently in a set state. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait() { Wait(Timeout.Infinite, CancellationToken.None); @@ -374,7 +374,7 @@ public void Wait() /// The caller of this method blocks indefinitely until the current instance is set. The caller will /// return immediately if the event is currently in a set state. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait(CancellationToken cancellationToken) { Wait(Timeout.Infinite, cancellationToken); @@ -395,7 +395,7 @@ public void Wait(CancellationToken cancellationToken) /// /// The maximum number of waiters has been exceeded. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout) { long totalMilliseconds = (long)timeout.TotalMilliseconds; @@ -427,7 +427,7 @@ public bool Wait(TimeSpan timeout) /// /// The maximum number of waiters has been exceeded. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { long totalMilliseconds = (long)timeout.TotalMilliseconds; @@ -452,7 +452,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) /// /// The maximum number of waiters has been exceeded. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout) { return Wait(millisecondsTimeout, CancellationToken.None); @@ -476,7 +476,7 @@ public bool Wait(int millisecondsTimeout) /// /// was canceled. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { ThrowIfDisposed(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs index 7354bd9d12aa6..559edc81d6b6b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs @@ -13,19 +13,19 @@ public static bool TryEnter(object obj, TimeSpan timeout) public static void TryEnter(object obj, TimeSpan timeout, ref bool lockTaken) => TryEnter(obj, WaitHandle.ToTimeoutMilliseconds(timeout), ref lockTaken); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, TimeSpan timeout) => Wait(obj, WaitHandle.ToTimeoutMilliseconds(timeout)); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj) => Wait(obj, Timeout.Infinite); // Remoting is not supported, exitContext argument is unused - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) => Wait(obj, millisecondsTimeout); // Remoting is not supported, exitContext argument is unused - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, TimeSpan timeout, bool exitContext) => Wait(obj, WaitHandle.ToTimeoutMilliseconds(timeout)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs index e216cbb78d55c..ac31f6613440c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs @@ -11,7 +11,7 @@ namespace System.Threading /// An object representing the registration of a via . /// #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public sealed partial class RegisteredWaitHandle : MarshalByRefObject { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs index 9f8413e543216..4e6787500af0e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs @@ -171,7 +171,7 @@ public SemaphoreSlim(int initialCount, int maxCount) /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait() { // Call wait with infinite timeout @@ -188,7 +188,7 @@ public void Wait() /// canceled. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait(CancellationToken cancellationToken) { // Call wait with infinite timeout @@ -207,7 +207,7 @@ public void Wait(CancellationToken cancellationToken) /// is a negative /// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater /// than . - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout) { // Validate the timeout @@ -238,7 +238,7 @@ public bool Wait(TimeSpan timeout) /// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater /// than . /// was canceled. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { // Validate the timeout @@ -263,7 +263,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) /// otherwise, false. /// is a /// negative number other than -1, which represents an infinite time-out. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout) { return Wait(millisecondsTimeout, CancellationToken.None); @@ -281,7 +281,7 @@ public bool Wait(int millisecondsTimeout) /// is a negative number other than -1, /// which represents an infinite time-out. /// was canceled. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { CheckDispose(); @@ -427,7 +427,7 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) /// The start ticks to calculate the elapsed time /// The CancellationToken to observe. /// true if the monitor received a signal, false if the timeout expired - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, CancellationToken cancellationToken) { int remainingWaitMilliseconds = Timeout.Infinite; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 6230fda260589..9ecb5b092b090 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -4617,7 +4617,7 @@ internal void RemoveContinuation(object continuationObject) // could be TaskCont /// At least one of the instances was canceled -or- an exception was thrown during /// the execution of at least one of the instances. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static void WaitAll(params Task[] tasks) { @@ -4660,7 +4660,7 @@ public static void WaitAll(params Task[] tasks) /// infinite time-out -or- timeout is greater than /// . /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, TimeSpan timeout) { @@ -4699,7 +4699,7 @@ public static bool WaitAll(Task[] tasks, TimeSpan timeout) /// is a negative number other than -1, which represents an /// infinite time-out. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, int millisecondsTimeout) { @@ -4728,7 +4728,7 @@ public static bool WaitAll(Task[] tasks, int millisecondsTimeout) /// /// The was canceled. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static void WaitAll(Task[] tasks, CancellationToken cancellationToken) { @@ -4769,14 +4769,14 @@ public static void WaitAll(Task[] tasks, CancellationToken cancellationToken) /// /// The was canceled. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) => WaitAllCore(tasks, millisecondsTimeout, cancellationToken); // Separated out to allow it to be optimized (caller is marked NoOptimization for VS parallel debugger // to be able to see the method on the stack and inspect arguments). - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private static bool WaitAllCore(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) { if (tasks == null) @@ -4915,7 +4915,7 @@ private static void AddToList(T item, ref List? list, int initSize) /// The timeout. /// The cancellation token. /// true if all of the tasks completed; otherwise, false. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private static bool WaitAllBlockingCore(List tasks, int millisecondsTimeout, CancellationToken cancellationToken) { Debug.Assert(tasks != null, "Expected a non-null list of tasks"); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs index 4c165a913929a..2257c8c1b68a5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs @@ -23,7 +23,7 @@ public static partial class TaskAsyncEnumerableExtensions /// unless the returned is enumerated by calling its method. /// Async enumeration does not happen in the background; each MoveNext call will invoke the underlying exactly once. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static IEnumerable ToBlockingEnumerable(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { IAsyncEnumerator enumerator = source.GetAsyncEnumerator(cancellationToken); @@ -76,7 +76,7 @@ public ManualResetEventWithAwaiterSupport() _onCompleted = Set; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion { awaiter.UnsafeOnCompleted(_onCompleted); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index 19d00e5d9ac19..c0d353c40888c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -182,7 +182,7 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false) /// There is not enough memory available to start this thread. /// This thread was created using a delegate instead of a delegate. #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void Start(object? parameter) => Start(parameter, captureContext: true); @@ -196,7 +196,7 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false) /// explicitly avoids capturing the current context and flowing it to the invocation. /// #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void UnsafeStart(object? parameter) => Start(parameter, captureContext: false); @@ -227,7 +227,7 @@ private void Start(object? parameter, bool captureContext, bool internalThread = /// The thread has already been started. /// There is not enough memory available to start this thread. #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void Start() => Start(captureContext: true); @@ -239,7 +239,7 @@ private void Start(object? parameter, bool captureContext, bool internalThread = /// explicitly avoids capturing the current context and flowing it to the invocation. /// #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void UnsafeStart() => Start(captureContext: false); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index 8ad921e002cd5..a0409221a3700 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -1374,7 +1374,7 @@ public static partial class ThreadPool internal static bool EnableWorkerTracking => IsWorkerTrackingEnabledInConfig && EventSource.IsSupported; #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif [CLSCompliant(false)] public static RegisteredWaitHandle RegisterWaitForSingleObject( @@ -1391,7 +1391,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif [CLSCompliant(false)] public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( @@ -1408,7 +1408,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, @@ -1424,7 +1424,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, @@ -1440,7 +1440,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, @@ -1458,7 +1458,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, @@ -1476,7 +1476,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, @@ -1495,7 +1495,7 @@ bool executeOnlyOnce } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs index 558ad2e4b0218..1ff8aea96feb7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlUrlResolver.cs @@ -22,13 +22,13 @@ public partial class XmlUrlResolver : XmlResolver public XmlUrlResolver() { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public override ICredentials? Credentials { set { _credentials = value; } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public IWebProxy? Proxy { set { _proxy = value; } diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/CachingSectionGroup.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/CachingSectionGroup.cs index 327dd53ba4073..ae0c332d3a0a6 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/CachingSectionGroup.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/CachingSectionGroup.cs @@ -8,7 +8,7 @@ namespace System.Runtime.Caching.Configuration { #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] #endif internal sealed class CachingSectionGroup : ConfigurationSectionGroup { diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheElement.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheElement.cs index 9fcfd59126aa4..16f336e0c0d49 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheElement.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheElement.cs @@ -9,7 +9,7 @@ namespace System.Runtime.Caching.Configuration { #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] #endif internal sealed class MemoryCacheElement : ConfigurationElement { diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSection.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSection.cs index 05e0387374ec8..b574e134f3fbf 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSection.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSection.cs @@ -22,7 +22,7 @@ namespace System.Runtime.Caching.Configuration */ #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] #endif internal sealed class MemoryCacheSection : ConfigurationSection { diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSettingsCollection.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSettingsCollection.cs index e3c1a5bd3eb1d..8c0c004240bcf 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSettingsCollection.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Configuration/MemoryCacheSettingsCollection.cs @@ -8,7 +8,7 @@ namespace System.Runtime.Caching.Configuration { #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] #endif [ConfigurationCollection(typeof(MemoryCacheElement), CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)] diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Counters.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Counters.cs index 8d3f7237d27af..a3f6351c7e357 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Counters.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/Counters.cs @@ -10,7 +10,7 @@ namespace System.Runtime.Caching { #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] #endif internal sealed class Counters : EventSource { diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/FileChangeNotificationSystem.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/FileChangeNotificationSystem.cs index 22595a4bd5845..0ac48d555304d 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/FileChangeNotificationSystem.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/FileChangeNotificationSystem.cs @@ -12,7 +12,7 @@ namespace System.Runtime.Caching { #if NETCOREAPP - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index c1ace3807df84..db0fc6d0a60e7 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -546,7 +546,7 @@ public ComSourceInterfacesAttribute(System.Type sourceInterface1, System.Type so public string Value { get { throw null; } } } [System.Runtime.Versioning.UnsupportedOSPlatform("android")] - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatform("ios")] [System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] [System.CLSCompliantAttribute(false)] @@ -1369,7 +1369,7 @@ public sealed partial class PosixSignalRegistration : System.IDisposable { internal PosixSignalRegistration() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Runtime.InteropServices.PosixSignalRegistration Create(System.Runtime.InteropServices.PosixSignal signal, System.Action handler) { throw null; } diff --git a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs index a6ab1de1524fd..76a72ab514280 100644 --- a/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs +++ b/src/libraries/System.Runtime.Loader/ref/System.Runtime.Loader.cs @@ -41,7 +41,7 @@ public class MetadataUpdateOriginalTypeAttribute : Attribute namespace System.Runtime.Loader { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public sealed partial class AssemblyDependencyResolver diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 8406052aab3b5..1f7fb5cee305c 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -14070,9 +14070,9 @@ public enum NormalizationForm { FormC = 1, FormD = 2, - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] FormKC = 5, - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] FormKD = 6, } public readonly partial struct Rune : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.ISpanFormattable @@ -14514,15 +14514,15 @@ public void Wait() { } public void Wait(System.Threading.CancellationToken cancellationToken) { } public bool Wait(System.TimeSpan timeout) { throw null; } public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static void WaitAll(params System.Threading.Tasks.Task[] tasks) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool WaitAll(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool WaitAll(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static void WaitAll(System.Threading.Tasks.Task[] tasks, System.Threading.CancellationToken cancellationToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool WaitAll(System.Threading.Tasks.Task[] tasks, System.TimeSpan timeout) { throw null; } public static int WaitAny(params System.Threading.Tasks.Task[] tasks) { throw null; } public static int WaitAny(System.Threading.Tasks.Task[] tasks, int millisecondsTimeout) { throw null; } @@ -14548,7 +14548,7 @@ public static partial class TaskAsyncEnumerableExtensions { public static System.Runtime.CompilerServices.ConfiguredAsyncDisposable ConfigureAwait(this System.IAsyncDisposable source, bool continueOnCapturedContext) { throw null; } public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable ConfigureAwait(this System.Collections.Generic.IAsyncEnumerable source, bool continueOnCapturedContext) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Collections.Generic.IEnumerable ToBlockingEnumerable(this System.Collections.Generic.IAsyncEnumerable source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable WithCancellation(this System.Collections.Generic.IAsyncEnumerable source, System.Threading.CancellationToken cancellationToken) { throw null; } } diff --git a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs index 2a40af5a1f91f..cc1ad65b5af06 100644 --- a/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs +++ b/src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs @@ -47,13 +47,13 @@ namespace System.Security.Cryptography public abstract partial class Aes : System.Security.Cryptography.SymmetricAlgorithm { protected Aes() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.Aes Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] public static new System.Security.Cryptography.Aes? Create(string algorithmName) { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public sealed partial class AesCcm : System.IDisposable @@ -99,7 +99,7 @@ public override void GenerateKey() { } [System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] public sealed partial class AesCryptoServiceProvider : System.Security.Cryptography.Aes { - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public AesCryptoServiceProvider() { } public override int BlockSize { get { throw null; } set { } } public override int FeedbackSize { get { throw null; } set { } } @@ -118,7 +118,7 @@ protected override void Dispose(bool disposing) { } public override void GenerateIV() { } public override void GenerateKey() { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public sealed partial class AesGcm : System.IDisposable @@ -136,7 +136,7 @@ public void Encrypt(byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] ta } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public sealed partial class AesManaged : System.Security.Cryptography.Aes { public AesManaged() { } @@ -276,7 +276,7 @@ public AuthenticationTagMismatchException() { } public AuthenticationTagMismatchException(string? message) { } public AuthenticationTagMismatchException(string? message, System.Exception? inner) { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public sealed partial class ChaCha20Poly1305 : System.IDisposable @@ -520,18 +520,18 @@ public partial class CryptoConfig { public CryptoConfig() { } public static bool AllowOnlyFipsAlgorithms { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static void AddAlgorithm(System.Type algorithm, params string[] names) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static void AddOID(string oid, params string[] names) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] public static object? CreateFromName(string name) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] public static object? CreateFromName(string name, params object?[]? args) { throw null; } [System.ObsoleteAttribute("EncodeOID is obsolete. Use the ASN.1 functionality provided in System.Formats.Asn1.", DiagnosticId="SYSLIB0031", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] EncodeOID(string str) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static string? MapNameToOID(string name) { throw null; } } public static partial class CryptographicOperations @@ -645,7 +645,7 @@ public abstract partial class DES : System.Security.Cryptography.SymmetricAlgori { protected DES() { } public override byte[] Key { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.DES Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -668,15 +668,15 @@ public override void GenerateKey() { } public abstract partial class DSA : System.Security.Cryptography.AsymmetricAlgorithm { protected DSA() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static new System.Security.Cryptography.DSA Create() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Security.Cryptography.DSA Create(int keySizeInBits) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Security.Cryptography.DSA Create(System.Security.Cryptography.DSAParameters parameters) { throw null; } @@ -804,31 +804,31 @@ public override void ImportParameters(System.Security.Cryptography.DSAParameters public sealed partial class DSAOpenSsl : System.Security.Cryptography.DSA { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public DSAOpenSsl() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public DSAOpenSsl(int keySize) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public DSAOpenSsl(System.IntPtr handle) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public DSAOpenSsl(System.Security.Cryptography.DSAParameters parameters) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] @@ -954,11 +954,11 @@ protected ECDiffieHellman() { } public override string KeyExchangeAlgorithm { get { throw null; } } public abstract System.Security.Cryptography.ECDiffieHellmanPublicKey PublicKey { get; } public override string? SignatureAlgorithm { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.ECDiffieHellman Create() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.ECDiffieHellman Create(System.Security.Cryptography.ECCurve curve) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.ECDiffieHellman Create(System.Security.Cryptography.ECParameters parameters) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -1043,31 +1043,31 @@ public enum ECDiffieHellmanKeyDerivationFunction public sealed partial class ECDiffieHellmanOpenSsl : System.Security.Cryptography.ECDiffieHellman { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDiffieHellmanOpenSsl() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDiffieHellmanOpenSsl(int keySize) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDiffieHellmanOpenSsl(System.IntPtr handle) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDiffieHellmanOpenSsl(System.Security.Cryptography.ECCurve curve) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] @@ -1098,11 +1098,11 @@ public abstract partial class ECDsa : System.Security.Cryptography.ECAlgorithm protected ECDsa() { } public override string? KeyExchangeAlgorithm { get { throw null; } } public override string SignatureAlgorithm { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.ECDsa Create() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.ECDsa Create(System.Security.Cryptography.ECCurve curve) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.ECDsa Create(System.Security.Cryptography.ECParameters parameters) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -1201,31 +1201,31 @@ public override void ImportParameters(System.Security.Cryptography.ECParameters public sealed partial class ECDsaOpenSsl : System.Security.Cryptography.ECDsa { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDsaOpenSsl() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDsaOpenSsl(int keySize) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDsaOpenSsl(System.IntPtr handle) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public ECDsaOpenSsl(System.Security.Cryptography.ECCurve curve) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] @@ -1354,35 +1354,35 @@ public partial class HMACMD5 : System.Security.Cryptography.HMAC { public const int HashSizeInBits = 128; public const int HashSizeInBytes = 16; - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public HMACMD5() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public HMACMD5(byte[] key) { } public override byte[] Key { get { throw null; } set { } } protected override void Dispose(bool disposing) { } protected override void HashCore(byte[] rgb, int ib, int cb) { } protected override void HashCore(System.ReadOnlySpan source) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(byte[] key, byte[] source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(byte[] key, System.IO.Stream source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(System.ReadOnlySpan key, System.IO.Stream source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static int HashData(System.ReadOnlySpan key, System.IO.Stream source, System.Span destination) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(System.ReadOnlySpan key, System.ReadOnlySpan source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static int HashData(System.ReadOnlySpan key, System.ReadOnlySpan source, System.Span destination) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Threading.Tasks.ValueTask HashDataAsync(byte[] key, System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Threading.Tasks.ValueTask HashDataAsync(System.ReadOnlyMemory key, System.IO.Stream source, System.Memory destination, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Threading.Tasks.ValueTask HashDataAsync(System.ReadOnlyMemory key, System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override byte[] HashFinal() { throw null; } public override void Initialize() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool TryHashData(System.ReadOnlySpan key, System.ReadOnlySpan source, System.Span destination, out int bytesWritten) { throw null; } protected override bool TryHashFinal(System.Span destination, out int bytesWritten) { throw null; } } @@ -1557,26 +1557,26 @@ public abstract partial class MD5 : System.Security.Cryptography.HashAlgorithm public const int HashSizeInBits = 128; public const int HashSizeInBytes = 16; protected MD5() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.MD5 Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] public static new System.Security.Cryptography.MD5? Create(string algName) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(byte[] source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(System.IO.Stream source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static int HashData(System.IO.Stream source, System.Span destination) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static byte[] HashData(System.ReadOnlySpan source) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static int HashData(System.ReadOnlySpan source, System.Span destination) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Threading.Tasks.ValueTask HashDataAsync(System.IO.Stream source, System.Memory destination, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Threading.Tasks.ValueTask HashDataAsync(System.IO.Stream source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool TryHashData(System.ReadOnlySpan source, System.Span destination, out int bytesWritten) { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -1737,7 +1737,7 @@ protected RC2() { } public virtual int EffectiveKeySize { get { throw null; } set { } } public override int KeySize { get { throw null; } set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.RC2 Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -1748,7 +1748,7 @@ protected RC2() { } public sealed partial class RC2CryptoServiceProvider : System.Security.Cryptography.RC2 { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public RC2CryptoServiceProvider() { } public override int EffectiveKeySize { get { throw null; } set { } } public bool UseSalt { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } @@ -1792,7 +1792,7 @@ public override void Reset() { } public abstract partial class Rijndael : System.Security.Cryptography.SymmetricAlgorithm { protected Rijndael() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.Rijndael Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -1800,7 +1800,7 @@ protected Rijndael() { } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.", DiagnosticId="SYSLIB0022", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public sealed partial class RijndaelManaged : System.Security.Cryptography.Rijndael { public RijndaelManaged() { } @@ -1840,11 +1840,11 @@ public abstract partial class RSA : System.Security.Cryptography.AsymmetricAlgor protected RSA() { } public override string? KeyExchangeAlgorithm { get { throw null; } } public override string SignatureAlgorithm { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.RSA Create() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.RSA Create(int keySizeInBits) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.RSA Create(System.Security.Cryptography.RSAParameters parameters) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -1940,9 +1940,9 @@ public override void ImportParameters(System.Security.Cryptography.RSAParameters } public sealed partial class RSACryptoServiceProvider : System.Security.Cryptography.RSA, System.Security.Cryptography.ICspAsymmetricAlgorithm { - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public RSACryptoServiceProvider() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public RSACryptoServiceProvider(int dwKeySize) { } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public RSACryptoServiceProvider(int dwKeySize, System.Security.Cryptography.CspParameters? parameters) { } @@ -2028,31 +2028,31 @@ public override void SetKey(System.Security.Cryptography.AsymmetricAlgorithm key public sealed partial class RSAOpenSsl : System.Security.Cryptography.RSA { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public RSAOpenSsl() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public RSAOpenSsl(int keySize) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public RSAOpenSsl(System.IntPtr handle) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public RSAOpenSsl(System.Security.Cryptography.RSAParameters parameters) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] @@ -2091,7 +2091,7 @@ public RSAPKCS1KeyExchangeFormatter(System.Security.Cryptography.AsymmetricAlgor public override byte[] CreateKeyExchange(byte[] rgbData, System.Type? symAlgType) { throw null; } public override void SetKey(System.Security.Cryptography.AsymmetricAlgorithm key) { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public partial class RSAPKCS1SignatureDeformatter : System.Security.Cryptography.AsymmetricSignatureDeformatter { public RSAPKCS1SignatureDeformatter() { } @@ -2100,7 +2100,7 @@ public override void SetHashAlgorithm(string strName) { } public override void SetKey(System.Security.Cryptography.AsymmetricAlgorithm key) { } public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature) { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public partial class RSAPKCS1SignatureFormatter : System.Security.Cryptography.AsymmetricSignatureFormatter { public RSAPKCS1SignatureFormatter() { } @@ -2130,20 +2130,20 @@ public enum RSASignaturePaddingMode public sealed partial class SafeEvpPKeyHandle : System.Runtime.InteropServices.SafeHandle { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public SafeEvpPKeyHandle() : base (default(System.IntPtr), default(bool)) { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] public SafeEvpPKeyHandle(System.IntPtr handle, bool ownsHandle) : base (default(System.IntPtr), default(bool)) { } public override bool IsInvalid { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("windows")] @@ -2424,7 +2424,7 @@ public abstract partial class TripleDES : System.Security.Cryptography.Symmetric { protected TripleDES() { } public override byte[] Key { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static new System.Security.Cryptography.TripleDES Create() { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] [System.ObsoleteAttribute("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] @@ -2482,7 +2482,7 @@ public override void GenerateKey() { } } namespace System.Security.Cryptography.X509Certificates { - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public sealed partial class CertificateRequest { public CertificateRequest(System.Security.Cryptography.X509Certificates.X500DistinguishedName subjectName, System.Security.Cryptography.ECDsa key, System.Security.Cryptography.HashAlgorithmName hashAlgorithm) { } @@ -2567,15 +2567,15 @@ public PublicKey(System.Security.Cryptography.Oid oid, System.Security.Cryptogra public System.Security.Cryptography.Oid Oid { get { throw null; } } public static System.Security.Cryptography.X509Certificates.PublicKey CreateFromSubjectPublicKeyInfo(System.ReadOnlySpan source, out int bytesRead) { throw null; } public byte[] ExportSubjectPublicKeyInfo() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.Security.Cryptography.DSA? GetDSAPublicKey() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Cryptography.ECDiffieHellman? GetECDiffieHellmanPublicKey() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Cryptography.ECDsa? GetECDsaPublicKey() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Security.Cryptography.RSA? GetRSAPublicKey() { throw null; } public bool TryExportSubjectPublicKeyInfo(System.Span destination, out int bytesWritten) { throw null; } } @@ -2707,44 +2707,44 @@ public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEnc public partial class X509Certificate : System.IDisposable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable { [System.ObsoleteAttribute("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(byte[] data) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(byte[] rawData, System.Security.SecureString? password) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(byte[] rawData, string? password) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(System.IntPtr handle) { } public X509Certificate(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(System.Security.Cryptography.X509Certificates.X509Certificate cert) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(string fileName) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(string fileName, System.Security.SecureString? password) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(string fileName, string? password) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate(string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } public System.IntPtr Handle { get { throw null; } } public string Issuer { get { throw null; } } public System.ReadOnlyMemory SerialNumberBytes { get { throw null; } } public string Subject { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate CreateFromCertFile(string filename) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate CreateFromSignedFile(string filename) { throw null; } public void Dispose() { } protected virtual void Dispose(bool disposing) { } @@ -2800,42 +2800,42 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser public partial class X509Certificate2 : System.Security.Cryptography.X509Certificates.X509Certificate { [System.ObsoleteAttribute("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(byte[] rawData) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(byte[] rawData, System.Security.SecureString? password) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(byte[] rawData, string? password) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(System.IntPtr handle) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(System.ReadOnlySpan rawData) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(System.ReadOnlySpan rawData, System.ReadOnlySpan password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet) { } protected X509Certificate2(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(System.Security.Cryptography.X509Certificates.X509Certificate certificate) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName, System.ReadOnlySpan password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName, System.Security.SecureString? password) { } [System.CLSCompliantAttribute(false)] - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName, string? password) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public X509Certificate2(string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { } public bool Archived { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } public System.Security.Cryptography.X509Certificates.X509ExtensionCollection Extensions { get { throw null; } } @@ -2855,22 +2855,22 @@ public X509Certificate2(string fileName, string? password, System.Security.Crypt public string Thumbprint { get { throw null; } } public int Version { get { throw null; } } public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.ECDiffieHellman privateKey) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateFromEncryptedPem(System.ReadOnlySpan certPem, System.ReadOnlySpan keyPem, System.ReadOnlySpan password) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateFromEncryptedPemFile(string certPemFilePath, System.ReadOnlySpan password, string? keyPemFilePath = null) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateFromPem(System.ReadOnlySpan certPem) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateFromPem(System.ReadOnlySpan certPem, System.ReadOnlySpan keyPem) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509Certificate2 CreateFromPemFile(string certPemFilePath, string? keyPemFilePath = null) { throw null; } public string ExportCertificatePem() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509ContentType GetCertContentType(byte[] rawData) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509ContentType GetCertContentType(System.ReadOnlySpan rawData) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static System.Security.Cryptography.X509Certificates.X509ContentType GetCertContentType(string fileName) { throw null; } public System.Security.Cryptography.ECDiffieHellman? GetECDiffieHellmanPrivateKey() { throw null; } public System.Security.Cryptography.ECDiffieHellman? GetECDiffieHellmanPublicKey() { throw null; } @@ -2985,7 +2985,7 @@ public X509Chain(System.IntPtr chainContext) { } public System.Security.Cryptography.X509Certificates.X509ChainPolicy ChainPolicy { get { throw null; } set { } } public System.Security.Cryptography.X509Certificates.X509ChainStatus[] ChainStatus { get { throw null; } } public Microsoft.Win32.SafeHandles.SafeX509ChainHandle? SafeHandle { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Build(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { throw null; } public static System.Security.Cryptography.X509Certificates.X509Chain Create() { throw null; } public void Dispose() { } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs index e00abeeac2d7a..cd7872c7dd3eb 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs @@ -20,7 +20,7 @@ protected Aes() ModeValue = CipherMode.CBC; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new Aes Create() { return new AesImplementation(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCcm.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCcm.cs index 74d974f7cefe7..cebb27ed93728 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCcm.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCcm.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed partial class AesCcm : IDisposable diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCryptoServiceProvider.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCryptoServiceProvider.cs index 2e081e8a06493..a7095a8a59324 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCryptoServiceProvider.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCryptoServiceProvider.cs @@ -12,7 +12,7 @@ public sealed class AesCryptoServiceProvider : Aes { private readonly Aes _impl; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public AesCryptoServiceProvider() { // This class wraps Aes diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs index 104d280452482..f52cb0f9b2fe9 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed partial class AesGcm : IDisposable diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesManaged.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesManaged.cs index dc62371051733..76e9094ad18f2 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesManaged.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesManaged.cs @@ -8,7 +8,7 @@ namespace System.Security.Cryptography { [Obsolete(Obsoletions.DerivedCryptographicTypesMessage, DiagnosticId = Obsoletions.DerivedCryptographicTypesDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class AesManaged : Aes { private readonly Aes _impl; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs index 63ac0a3f7eca2..6942b4ec93fb8 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ChaCha20Poly1305.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public sealed partial class ChaCha20Poly1305 : IDisposable diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptoConfig.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptoConfig.cs index d7397d28223b9..b3c4330d3b448 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptoConfig.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptoConfig.cs @@ -299,7 +299,7 @@ private static Dictionary DefaultNameHT } #endif - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static void AddAlgorithm(Type algorithm, params string[] names) { #if BROWSER @@ -496,7 +496,7 @@ public static void AddAlgorithm(Type algorithm, params string[] names) return CreateFromName(name, null); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static void AddOID(string oid, params string[] names) { #if BROWSER @@ -526,7 +526,7 @@ public static void AddOID(string oid, params string[] names) #endif } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static string? MapNameToOID(string name) { #if BROWSER @@ -550,7 +550,7 @@ public static void AddOID(string oid, params string[] names) #endif } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [Obsolete(Obsoletions.CryptoConfigEncodeOIDMessage, DiagnosticId = Obsoletions.CryptoConfigEncodeOIDDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static byte[] EncodeOID(string str) { diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DES.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DES.cs index 48effb4c6ecf7..2afbd8ec4b543 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DES.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DES.cs @@ -21,7 +21,7 @@ protected DES() FeedbackSizeValue = BlockSizeValue; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new DES Create() { return new DesImplementation(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSA.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSA.cs index b1331334dc8a4..cdb6a63157ad6 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSA.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSA.cs @@ -34,7 +34,7 @@ protected DSA() { } return (DSA?)CryptoConfig.CreateFromName(algName); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static new DSA Create() @@ -42,7 +42,7 @@ protected DSA() { } return CreateCore(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static DSA Create(int keySizeInBits) @@ -61,7 +61,7 @@ public static DSA Create(int keySizeInBits) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public static DSA Create(DSAParameters parameters) diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSAOpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSAOpenSsl.cs index e1805a2f99e9e..06b5528b7b5f2 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSAOpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/DSAOpenSsl.cs @@ -9,7 +9,7 @@ namespace System.Security.Cryptography public sealed partial class DSAOpenSsl : DSA { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -32,7 +32,7 @@ public DSAOpenSsl(DSAParameters parameters) /// /// is not a valid enveloped DSA* [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -66,7 +66,7 @@ public DSAOpenSsl(SafeEvpPKeyHandle pkeyHandle) /// A pointer to an OpenSSL DSA* /// is invalid [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellman.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellman.cs index 9eaf8d78c920d..83c9d36a37761 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellman.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellman.cs @@ -22,13 +22,13 @@ public override string? SignatureAlgorithm get { return null; } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new partial ECDiffieHellman Create(); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static partial ECDiffieHellman Create(ECCurve curve); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static partial ECDiffieHellman Create(ECParameters parameters); [Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs index 95c1bdf82a39e..c884e7b843370 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.cs @@ -18,7 +18,7 @@ public sealed partial class ECDiffieHellmanOpenSsl : ECDiffieHellman /// /// is not a valid enveloped EC_KEY* [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -53,7 +53,7 @@ public ECDiffieHellmanOpenSsl(SafeEvpPKeyHandle pkeyHandle) /// A pointer to an OpenSSL EC_KEY* /// is invalid [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsa.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsa.cs index 645c3303d0a06..f9463aeb2d5c4 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsa.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsa.cs @@ -20,13 +20,13 @@ public abstract partial class ECDsa : ECAlgorithm protected ECDsa() { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new partial ECDsa Create(); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static partial ECDsa Create(ECCurve curve); - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static partial ECDsa Create(ECParameters parameters); [Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsaOpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsaOpenSsl.cs index 5e2d8f5fe271c..09b15f8014a90 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsaOpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/ECDsaOpenSsl.cs @@ -18,7 +18,7 @@ public sealed partial class ECDsaOpenSsl : ECDsa /// /// is not a valid enveloped EC_KEY* [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -53,7 +53,7 @@ public ECDsaOpenSsl(SafeEvpPKeyHandle pkeyHandle) /// A pointer to an OpenSSL EC_KEY* /// is invalid [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HMACMD5.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HMACMD5.cs index bf8a9f76e5b6a..a1a1f96e043b5 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HMACMD5.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HMACMD5.cs @@ -27,13 +27,13 @@ public class HMACMD5 : HMAC /// public const int HashSizeInBytes = HashSizeInBits / 8; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public HMACMD5() : this(RandomNumberGenerator.GetBytes(BlockSize)) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public HMACMD5(byte[] key) { ArgumentNullException.ThrowIfNull(key); @@ -85,7 +85,7 @@ protected override bool TryHashFinal(Span destination, out int bytesWritte /// /// or is . /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(byte[] key, byte[] source) { ArgumentNullException.ThrowIfNull(key); @@ -100,7 +100,7 @@ public static byte[] HashData(byte[] key, byte[] source) /// The HMAC key. /// The data to HMAC. /// The HMAC of the data. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(ReadOnlySpan key, ReadOnlySpan source) { byte[] buffer = new byte[HashSizeInBytes]; @@ -122,7 +122,7 @@ public static byte[] HashData(ReadOnlySpan key, ReadOnlySpan source) /// The buffer in is too small to hold the calculated hash /// size. The MD5 algorithm always produces a 128-bit HMAC, or 16 bytes. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static int HashData(ReadOnlySpan key, ReadOnlySpan source, Span destination) { if (!TryHashData(key, source, destination, out int bytesWritten)) @@ -146,7 +146,7 @@ public static int HashData(ReadOnlySpan key, ReadOnlySpan source, Sp /// if is too small to hold the /// calculated hash, otherwise. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool TryHashData(ReadOnlySpan key, ReadOnlySpan source, Span destination, out int bytesWritten) { if (destination.Length < HashSizeInBytes) @@ -181,7 +181,7 @@ public static bool TryHashData(ReadOnlySpan key, ReadOnlySpan source /// does not support reading. ///

/// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static int HashData(ReadOnlySpan key, Stream source, Span destination) { ArgumentNullException.ThrowIfNull(source); @@ -207,7 +207,7 @@ public static int HashData(ReadOnlySpan key, Stream source, Span des /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(ReadOnlySpan key, Stream source) { ArgumentNullException.ThrowIfNull(source); @@ -230,7 +230,7 @@ public static byte[] HashData(ReadOnlySpan key, Stream source) /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(byte[] key, Stream source) { ArgumentNullException.ThrowIfNull(key); @@ -254,7 +254,7 @@ public static byte[] HashData(byte[] key, Stream source) /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static ValueTask HashDataAsync(ReadOnlyMemory key, Stream source, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(source); @@ -281,7 +281,7 @@ public static ValueTask HashDataAsync(ReadOnlyMemory key, Stream s /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static ValueTask HashDataAsync(byte[] key, Stream source, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(key); @@ -313,7 +313,7 @@ public static ValueTask HashDataAsync(byte[] key, Stream source, Cancell /// does not support reading. ///

/// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static ValueTask HashDataAsync( ReadOnlyMemory key, Stream source, diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MD5.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MD5.cs index 31dad400f6c8d..49426a04268ff 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MD5.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MD5.cs @@ -34,7 +34,7 @@ protected MD5() HashSizeValue = HashSizeInBits; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new MD5 Create() => new Implementation(); [Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] @@ -49,7 +49,7 @@ protected MD5() /// /// is . /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(byte[] source) { ArgumentNullException.ThrowIfNull(source); @@ -62,7 +62,7 @@ public static byte[] HashData(byte[] source) /// /// The data to hash. /// The hash of the data. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(ReadOnlySpan source) { byte[] buffer = GC.AllocateUninitializedArray(HashSizeInBytes); @@ -83,7 +83,7 @@ public static byte[] HashData(ReadOnlySpan source) /// The buffer in is too small to hold the calculated hash /// size. The MD5 algorithm always produces a 128-bit hash, or 16 bytes. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static int HashData(ReadOnlySpan source, Span destination) { if (!TryHashData(source, destination, out int bytesWritten)) @@ -104,7 +104,7 @@ public static int HashData(ReadOnlySpan source, Span destination) /// if is too small to hold the /// calculated hash, otherwise. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool TryHashData(ReadOnlySpan source, Span destination, out int bytesWritten) { if (destination.Length < HashSizeInBytes) @@ -138,7 +138,7 @@ public static bool TryHashData(ReadOnlySpan source, Span destination /// does not support reading. ///

/// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static int HashData(Stream source, Span destination) { ArgumentNullException.ThrowIfNull(source); @@ -163,7 +163,7 @@ public static int HashData(Stream source, Span destination) /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static byte[] HashData(Stream source) { ArgumentNullException.ThrowIfNull(source); @@ -189,7 +189,7 @@ public static byte[] HashData(Stream source) /// /// does not support reading. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static ValueTask HashDataAsync(Stream source, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(source); @@ -223,7 +223,7 @@ public static ValueTask HashDataAsync(Stream source, CancellationToken c /// does not support reading. ///

/// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static ValueTask HashDataAsync( Stream source, Memory destination, diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OpenSsl.NotSupported.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OpenSsl.NotSupported.cs index b5611338e8daa..698806413c8c6 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OpenSsl.NotSupported.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/OpenSsl.NotSupported.cs @@ -9,7 +9,7 @@ namespace System.Security.Cryptography public sealed class DSAOpenSsl : DSA { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -19,7 +19,7 @@ public DSAOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -29,7 +29,7 @@ public DSAOpenSsl(int keySize) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -39,7 +39,7 @@ public DSAOpenSsl(IntPtr handle) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -49,7 +49,7 @@ public DSAOpenSsl(DSAParameters parameters) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -67,7 +67,7 @@ public override void ImportParameters(DSAParameters parameters) { } public sealed class ECDiffieHellmanOpenSsl : ECDiffieHellman { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -77,7 +77,7 @@ public ECDiffieHellmanOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -87,7 +87,7 @@ public ECDiffieHellmanOpenSsl(int keySize) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -97,7 +97,7 @@ public ECDiffieHellmanOpenSsl(IntPtr handle) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -107,7 +107,7 @@ public ECDiffieHellmanOpenSsl(ECCurve curve) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -124,7 +124,7 @@ public override void ImportParameters(ECParameters parameters) { } public sealed class ECDsaOpenSsl : ECDsa { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -134,7 +134,7 @@ public ECDsaOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -144,7 +144,7 @@ public ECDsaOpenSsl(int keySize) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -154,7 +154,7 @@ public ECDsaOpenSsl(IntPtr handle) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -164,7 +164,7 @@ public ECDsaOpenSsl(ECCurve curve) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -180,7 +180,7 @@ public ECDsaOpenSsl(SafeEvpPKeyHandle pkeyHandle) public sealed class RSAOpenSsl : RSA { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -190,7 +190,7 @@ public RSAOpenSsl() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -200,7 +200,7 @@ public RSAOpenSsl(int keySize) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -210,7 +210,7 @@ public RSAOpenSsl(IntPtr handle) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -220,7 +220,7 @@ public RSAOpenSsl(RSAParameters parameters) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -236,7 +236,7 @@ public override void ImportParameters(RSAParameters parameters) { } public sealed class SafeEvpPKeyHandle : SafeHandle { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -246,7 +246,7 @@ public SafeEvpPKeyHandle() : base(IntPtr.Zero, false) } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -256,7 +256,7 @@ public SafeEvpPKeyHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHand } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2.cs index 97020e10d5d12..bb53e1352e3c0 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2.cs @@ -22,7 +22,7 @@ protected RC2() } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new RC2 Create() { return new RC2Implementation(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.NotSupported.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.NotSupported.cs index 1c5dcb868862e..2e29331620413 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.NotSupported.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.NotSupported.cs @@ -13,7 +13,7 @@ public sealed partial class RC2CryptoServiceProvider : RC2 { [SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of RC2CryptoServiceProvider")] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RC2CryptoServiceProvider() { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Unix.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Unix.cs index 4824979408459..d076a6e0958bb 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Unix.cs @@ -19,7 +19,7 @@ public sealed partial class RC2CryptoServiceProvider : RC2 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of RC2CryptoServiceProvider")] [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RC2CryptoServiceProvider() { _impl = RC2.Create(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs index c7e0cc4003d71..40fd18db04bd5 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs @@ -21,7 +21,7 @@ public sealed class RC2CryptoServiceProvider : RC2 }; [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RC2CryptoServiceProvider() { LegalKeySizesValue = s_legalKeySizes.CloneKeySizesArray(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSA.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSA.cs index 375c1f2b1cf9d..07f7de5c2b759 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSA.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSA.cs @@ -15,7 +15,7 @@ namespace System.Security.Cryptography { public abstract partial class RSA : AsymmetricAlgorithm { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new partial RSA Create(); [Obsolete(Obsoletions.CryptoStringFactoryMessage, DiagnosticId = Obsoletions.CryptoStringFactoryDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] @@ -25,7 +25,7 @@ public abstract partial class RSA : AsymmetricAlgorithm return (RSA?)CryptoConfig.CreateFromName(algName); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static RSA Create(int keySizeInBits) { RSA rsa = Create(); @@ -42,7 +42,7 @@ public static RSA Create(int keySizeInBits) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static RSA Create(RSAParameters parameters) { RSA rsa = Create(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.NotSupported.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.NotSupported.cs index 4be85c451896d..f1e5812c75741 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.NotSupported.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.NotSupported.cs @@ -8,13 +8,13 @@ namespace System.Security.Cryptography { public sealed partial class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgorithm { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider() { throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider(int dwKeySize) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs index 374faf2d85d37..fb23645272483 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Unix.cs @@ -14,11 +14,11 @@ public sealed partial class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgori private readonly RSA _impl; private bool _publicOnly; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider() : this(DefaultKeySize) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider(int dwKeySize) { if (dwKeySize < 0) diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs index 5050cd0e4796a..8aba26cc6bf64 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs @@ -20,7 +20,7 @@ public sealed partial class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgori private static volatile CspProviderFlags s_useMachineKeyStore; private bool _disposed; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider() : this(0, new CspParameters(CapiHelper.DefaultRsaProviderType, null, @@ -30,7 +30,7 @@ public RSACryptoServiceProvider() { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSACryptoServiceProvider(int dwKeySize) : this(dwKeySize, new CspParameters(CapiHelper.DefaultRsaProviderType, diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAOpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAOpenSsl.cs index b2ad115fd34d9..8e206416034db 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAOpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAOpenSsl.cs @@ -10,7 +10,7 @@ namespace System.Security.Cryptography public sealed partial class RSAOpenSsl : RSA { [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -34,7 +34,7 @@ public RSAOpenSsl(RSAParameters parameters) /// A pointer to an OpenSSL RSA* /// is invalid [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -61,7 +61,7 @@ public RSAOpenSsl(IntPtr handle) /// /// is not a valid enveloped RSA* [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureDeformatter.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureDeformatter.cs index 11ce2d106648e..90fe45bf2b7aa 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureDeformatter.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureDeformatter.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public class RSAPKCS1SignatureDeformatter : AsymmetricSignatureDeformatter { private RSA? _rsaKey; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureFormatter.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureFormatter.cs index a85e5d68f6fea..a5dd7dba1dae5 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureFormatter.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSAPKCS1SignatureFormatter.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public class RSAPKCS1SignatureFormatter : AsymmetricSignatureFormatter { private RSA? _rsaKey; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rijndael.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rijndael.cs index 4c9de50ee6e2c..05e99249eb43f 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rijndael.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Rijndael.cs @@ -12,7 +12,7 @@ namespace System.Security.Cryptography [EditorBrowsable(EditorBrowsableState.Never)] public abstract class Rijndael : SymmetricAlgorithm { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new Rijndael Create() { return new RijndaelImplementation(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelImplementation.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelImplementation.cs index 698926032dfdb..f7d825c77940a 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelImplementation.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelImplementation.cs @@ -17,7 +17,7 @@ internal sealed class RijndaelImplementation : Rijndael { private readonly Aes _impl; - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] internal RijndaelImplementation() { LegalBlockSizesValue = new KeySizes[] { new KeySizes(minSize: 128, maxSize: 128, skipSize: 0) }; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelManaged.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelManaged.cs index 2c866a2459f69..43881fc723b9e 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelManaged.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RijndaelManaged.cs @@ -9,7 +9,7 @@ namespace System.Security.Cryptography { [Obsolete(Obsoletions.RijndaelMessage, DiagnosticId = Obsoletions.RijndaelDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class RijndaelManaged : Rijndael { private readonly Aes _impl; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SafeEvpPKeyHandle.OpenSsl.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SafeEvpPKeyHandle.OpenSsl.cs index 99c0f42106db8..a25dbd1100843 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SafeEvpPKeyHandle.OpenSsl.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/SafeEvpPKeyHandle.OpenSsl.cs @@ -12,7 +12,7 @@ public sealed class SafeEvpPKeyHandle : SafeHandle internal static readonly SafeEvpPKeyHandle InvalidHandle = new SafeEvpPKeyHandle(); [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -22,7 +22,7 @@ public SafeEvpPKeyHandle() : } [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] @@ -81,7 +81,7 @@ public SafeEvpPKeyHandle DuplicateHandle() /// for OpenSSL 1.0.x this is the result of SSLeay(). /// [UnsupportedOSPlatform("android")] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [UnsupportedOSPlatform("windows")] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/TripleDES.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/TripleDES.cs index d70e60fdc47f3..ccf23ad6d67d0 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/TripleDES.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/TripleDES.cs @@ -20,7 +20,7 @@ protected TripleDES() LegalKeySizesValue = s_legalKeySizes.CloneKeySizesArray(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static new TripleDES Create() { return new TripleDesImplementation(); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs index c3084c964d7dc..d5af321b7dc4d 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs @@ -17,7 +17,7 @@ namespace System.Security.Cryptography.X509Certificates /// allowing callers to create self-signed or chain-signed X.509 Public-Key Certificates, as well as /// create a certificate signing request blob to send to a Certificate Authority (CA). /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed partial class CertificateRequest { private readonly AsymmetricAlgorithm? _key; diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/PublicKey.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/PublicKey.cs index e53f36d403e4b..a70a2f32e211e 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/PublicKey.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/PublicKey.cs @@ -148,7 +148,7 @@ public static PublicKey CreateFromSubjectPublicKeyInfo(ReadOnlySpan source /// /// The key contents are corrupt or could not be read successfully. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public RSA? GetRSAPublicKey() { if (_oid.Value != Oids.Rsa) @@ -177,7 +177,7 @@ public static PublicKey CreateFromSubjectPublicKeyInfo(ReadOnlySpan source /// /// The key contents are corrupt or could not be read successfully. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] public DSA? GetDSAPublicKey() @@ -208,7 +208,7 @@ public static PublicKey CreateFromSubjectPublicKeyInfo(ReadOnlySpan source /// /// The key contents are corrupt or could not be read successfully. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ECDsa? GetECDsaPublicKey() { if (_oid.Value != Oids.EcPublicKey) @@ -238,7 +238,7 @@ public static PublicKey CreateFromSubjectPublicKeyInfo(ReadOnlySpan source /// /// The key contents are corrupt or could not be read successfully. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public ECDiffieHellman? GetECDiffieHellmanPublicKey() { if (_oid.Value != Oids.EcPublicKey) diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs index 59a82d473dc57..51be2962e33e1 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs @@ -45,13 +45,13 @@ public virtual void Reset() } [Obsolete(Obsoletions.X509CertificateImmutableMessage, DiagnosticId = Obsoletions.X509CertificateImmutableDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate() { } // Null turns into the empty span here, which is correct for compat. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(byte[] data) : this(new ReadOnlySpan(data)) { @@ -69,20 +69,20 @@ private protected X509Certificate(ReadOnlySpan data) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(byte[] rawData, string? password) : this(rawData, password, X509KeyStorageFlags.DefaultKeySet) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate(byte[] rawData, SecureString? password) : this(rawData, password, X509KeyStorageFlags.DefaultKeySet) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(byte[] rawData, string? password, X509KeyStorageFlags keyStorageFlags) { if (rawData == null || rawData.Length == 0) @@ -96,7 +96,7 @@ public X509Certificate(byte[] rawData, string? password, X509KeyStorageFlags key } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate(byte[] rawData, SecureString? password, X509KeyStorageFlags keyStorageFlags) { @@ -124,7 +124,7 @@ private protected X509Certificate(ReadOnlySpan rawData, ReadOnlySpan } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(IntPtr handle) { Pal = CertificatePal.FromHandle(handle); @@ -136,26 +136,26 @@ internal X509Certificate(ICertificatePalCore pal) Pal = pal; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(string fileName) : this(fileName, (string?)null, X509KeyStorageFlags.DefaultKeySet) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(string fileName, string? password) : this(fileName, password, X509KeyStorageFlags.DefaultKeySet) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate(string fileName, SecureString? password) : this(fileName, password, X509KeyStorageFlags.DefaultKeySet) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(string fileName, string? password, X509KeyStorageFlags keyStorageFlags) { ArgumentNullException.ThrowIfNull(fileName); @@ -180,7 +180,7 @@ private protected X509Certificate(string fileName, ReadOnlySpan password, } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] #pragma warning disable SYSLIB0026 public X509Certificate(string fileName, SecureString? password, X509KeyStorageFlags keyStorageFlags) : this() @@ -196,7 +196,7 @@ public X509Certificate(string fileName, SecureString? password, X509KeyStorageFl } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate(X509Certificate cert) { ArgumentNullException.ThrowIfNull(cert); @@ -214,13 +214,13 @@ public X509Certificate(SerializationInfo info, StreamingContext context) : this( throw new PlatformNotSupportedException(); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate CreateFromCertFile(string filename) { return new X509Certificate(filename); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate CreateFromSignedFile(string filename) { return new X509Certificate(filename); diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs index b2855084370f4..54de8862e1a62 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs @@ -42,38 +42,38 @@ public override void Reset() } [Obsolete(Obsoletions.X509CertificateImmutableMessage, DiagnosticId = Obsoletions.X509CertificateImmutableDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2() : base() { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(byte[] rawData) : base(rawData) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(byte[] rawData, string? password) : base(rawData, password) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate2(byte[] rawData, SecureString? password) : base(rawData, password) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(byte[] rawData, string? password, X509KeyStorageFlags keyStorageFlags) : base(rawData, password, keyStorageFlags) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate2(byte[] rawData, SecureString? password, X509KeyStorageFlags keyStorageFlags) : base(rawData, password, keyStorageFlags) @@ -87,7 +87,7 @@ public X509Certificate2(byte[] rawData, SecureString? password, X509KeyStorageFl /// The certificate data to process. /// /// An error with the certificate occurs. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(ReadOnlySpan rawData) : base(rawData) { @@ -107,13 +107,13 @@ public X509Certificate2(ReadOnlySpan rawData) /// A bitwise combination of the enumeration values that control where and how to import the certificate. /// /// An error with the certificate occurs. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(ReadOnlySpan rawData, ReadOnlySpan password, X509KeyStorageFlags keyStorageFlags = 0) : base(rawData, password, keyStorageFlags) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(IntPtr handle) : base(handle) { @@ -124,45 +124,45 @@ internal X509Certificate2(ICertificatePal pal) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(string fileName) : base(fileName) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(string fileName, string? password) : base(fileName, password) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate2(string fileName, SecureString? password) : base(fileName, password) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(string fileName, string? password, X509KeyStorageFlags keyStorageFlags) : base(fileName, password, keyStorageFlags) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] [CLSCompliantAttribute(false)] public X509Certificate2(string fileName, SecureString? password, X509KeyStorageFlags keyStorageFlags) : base(fileName, password, keyStorageFlags) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(string fileName, ReadOnlySpan password, X509KeyStorageFlags keyStorageFlags = 0) : base(fileName, password, keyStorageFlags) { } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public X509Certificate2(X509Certificate certificate) : base(certificate) { @@ -376,7 +376,7 @@ public int Version } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509ContentType GetCertContentType(byte[] rawData) { if (rawData == null || rawData.Length == 0) @@ -394,7 +394,7 @@ public static X509ContentType GetCertContentType(byte[] rawData) /// /// One of the enumeration values that indicate the content type of the provided data. /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509ContentType GetCertContentType(ReadOnlySpan rawData) { if (rawData.Length == 0) @@ -403,7 +403,7 @@ public static X509ContentType GetCertContentType(ReadOnlySpan rawData) return X509Pal.Instance.GetCertContentType(rawData); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509ContentType GetCertContentType(string fileName) { ArgumentNullException.ThrowIfNull(fileName); @@ -818,7 +818,7 @@ public X509Certificate2 CopyWithPrivateKey(ECDiffieHellman privateKey) /// For password protected PEM-encoded keys, use to specify a password. /// /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate2 CreateFromPemFile(string certPemFilePath, string? keyPemFilePath = default) { ArgumentNullException.ThrowIfNull(certPemFilePath); @@ -884,7 +884,7 @@ public static X509Certificate2 CreateFromPemFile(string certPemFilePath, string? /// For PEM-encoded keys without a password, use . /// /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate2 CreateFromEncryptedPemFile(string certPemFilePath, ReadOnlySpan password, string? keyPemFilePath = default) { ArgumentNullException.ThrowIfNull(certPemFilePath); @@ -934,7 +934,7 @@ public static X509Certificate2 CreateFromEncryptedPemFile(string certPemFilePath /// For password protected PEM-encoded keys, use to specify a password. /// /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate2 CreateFromPem(ReadOnlySpan certPem, ReadOnlySpan keyPem) { using (X509Certificate2 certificate = CreateFromPem(certPem)) @@ -1005,7 +1005,7 @@ Oids.EcPublicKey when IsECDiffieHellman(certificate) => /// For PEM-encoded keys without a password, use . /// /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate2 CreateFromEncryptedPem(ReadOnlySpan certPem, ReadOnlySpan keyPem, ReadOnlySpan password) { using (X509Certificate2 certificate = CreateFromPem(certPem)) @@ -1070,7 +1070,7 @@ private static bool IsECDiffieHellman(X509Certificate2 certificate) /// For PEM-encoded certificates in a file, use . /// /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static X509Certificate2 CreateFromPem(ReadOnlySpan certPem) { foreach ((ReadOnlySpan contents, PemFields fields) in new PemEnumerator(certPem)) diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Chain.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Chain.cs index 50eaba6eb91b9..6fdb9111e8dc4 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Chain.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Chain.cs @@ -85,7 +85,7 @@ public SafeX509ChainHandle? SafeHandle } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Build(X509Certificate2 certificate) { return Build(certificate, true); diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs index d764627ce6365..58dc6dc68f80f 100644 --- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs +++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs @@ -90,22 +90,22 @@ public static void Sleep(int millisecondsTimeout) { } public static void Sleep(System.TimeSpan timeout) { } public static void SpinWait(int iterations) { } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void Start() { } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void Start(object? parameter) { } [System.ObsoleteAttribute("Thread.Suspend has been deprecated. Use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.")] public void Suspend() { } public bool TrySetApartmentState(System.Threading.ApartmentState state) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void UnsafeStart() { } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public void UnsafeStart(object? parameter) { } public static byte VolatileRead(ref byte address) { throw null; } diff --git a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs index 20ca9318b980c..08ec181ab4f81 100644 --- a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs +++ b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs @@ -11,7 +11,7 @@ public partial interface IThreadPoolWorkItem void Execute(); } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public sealed partial class RegisteredWaitHandle : System.MarshalByRefObject { @@ -35,20 +35,20 @@ public static partial class ThreadPool public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool QueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } public static bool SetMaxThreads(int workerThreads, int completionPortThreads) { throw null; } @@ -60,20 +60,20 @@ public static partial class ThreadPool public static bool UnsafeQueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool UnsafeQueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } } diff --git a/src/libraries/System.Threading/ref/System.Threading.cs b/src/libraries/System.Threading/ref/System.Threading.cs index 2963a3ad970c4..2cf38ca9da6ca 100644 --- a/src/libraries/System.Threading/ref/System.Threading.cs +++ b/src/libraries/System.Threading/ref/System.Threading.cs @@ -14,25 +14,25 @@ public Barrier(int participantCount, System.Action? po public long CurrentPhaseNumber { get { throw null; } } public int ParticipantCount { get { throw null; } } public int ParticipantsRemaining { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public long AddParticipant() { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public long AddParticipants(int participantCount) { throw null; } public void Dispose() { } protected virtual void Dispose(bool disposing) { } public void RemoveParticipant() { } public void RemoveParticipants(int participantCount) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void SignalAndWait() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool SignalAndWait(int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool SignalAndWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void SignalAndWait(System.Threading.CancellationToken cancellationToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool SignalAndWait(System.TimeSpan timeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool SignalAndWait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } } public partial class BarrierPostPhaseException : System.Exception @@ -60,17 +60,17 @@ public void Reset(int count) { } public bool Signal(int signalCount) { throw null; } public bool TryAddCount() { throw null; } public bool TryAddCount(int signalCount) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait(System.Threading.CancellationToken cancellationToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } } public partial class HostExecutionContext : System.IDisposable @@ -104,9 +104,9 @@ public ReaderWriterLock() { } public bool IsReaderLockHeld { get { throw null; } } public bool IsWriterLockHeld { get { throw null; } } public int WriterSeqNum { get { throw null; } } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void AcquireReaderLock(int millisecondsTimeout) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void AcquireReaderLock(System.TimeSpan timeout) { } public void AcquireWriterLock(int millisecondsTimeout) { } public void AcquireWriterLock(System.TimeSpan timeout) { } @@ -115,11 +115,11 @@ public void DowngradeFromWriterLock(ref System.Threading.LockCookie lockCookie) public System.Threading.LockCookie ReleaseLock() { throw null; } public void ReleaseReaderLock() { } public void ReleaseWriterLock() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void RestoreLock(ref System.Threading.LockCookie lockCookie) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Threading.LockCookie UpgradeToWriterLock(int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public System.Threading.LockCookie UpgradeToWriterLock(System.TimeSpan timeout) { throw null; } } } @@ -305,17 +305,17 @@ public void Dispose() { } protected virtual void Dispose(bool disposing) { } public void Reset() { } public void Set() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait(System.Threading.CancellationToken cancellationToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } } public static partial class Monitor @@ -333,15 +333,15 @@ public static void TryEnter(object obj, ref bool lockTaken) { } public static void TryEnter(object obj, int millisecondsTimeout, ref bool lockTaken) { } public static bool TryEnter(object obj, System.TimeSpan timeout) { throw null; } public static void TryEnter(object obj, System.TimeSpan timeout, ref bool lockTaken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool Wait(object obj) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool Wait(object obj, int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool Wait(object obj, System.TimeSpan timeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public static bool Wait(object obj, System.TimeSpan timeout, bool exitContext) { throw null; } } public sealed partial class Mutex : System.Threading.WaitHandle @@ -412,17 +412,17 @@ public void Dispose() { } protected virtual void Dispose(bool disposing) { } public int Release() { throw null; } public int Release(int releaseCount) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait() { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public void Wait(System.Threading.CancellationToken cancellationToken) { } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout) { throw null; } - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } public System.Threading.Tasks.Task WaitAsync() { throw null; } public System.Threading.Tasks.Task WaitAsync(int millisecondsTimeout) { throw null; } diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index 747bc2def3281..5b5584cfc4e90 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -284,7 +284,7 @@ private bool SetCurrentTotal(int currentTotal, int current, int total, bool sens /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public long AddParticipant() { try @@ -313,7 +313,7 @@ public long AddParticipant() /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public long AddParticipants(int participantCount) { ObjectDisposedException.ThrowIf(_disposed, this); @@ -483,7 +483,7 @@ public void RemoveParticipants(int participantCount) /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SignalAndWait() { SignalAndWait(CancellationToken.None); @@ -504,7 +504,7 @@ public void SignalAndWait() /// canceled. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void SignalAndWait(CancellationToken cancellationToken) { #if DEBUG @@ -534,7 +534,7 @@ public void SignalAndWait(CancellationToken cancellationToken) /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool SignalAndWait(TimeSpan timeout) { return SignalAndWait(timeout, CancellationToken.None); @@ -562,7 +562,7 @@ public bool SignalAndWait(TimeSpan timeout) /// canceled. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken) { long totalMilliseconds = (long)timeout.TotalMilliseconds; @@ -590,7 +590,7 @@ public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken) /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool SignalAndWait(int millisecondsTimeout) { return SignalAndWait(millisecondsTimeout, CancellationToken.None); @@ -617,7 +617,7 @@ public bool SignalAndWait(int millisecondsTimeout) /// canceled. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool SignalAndWait(int millisecondsTimeout, CancellationToken cancellationToken) { ObjectDisposedException.ThrowIf(_disposed, this); @@ -857,7 +857,7 @@ private void WaitCurrentPhase(ManualResetEventSlim currentPhaseEvent, long obser /// cancellation token passed to SignalAndWait /// The current phase number for this thread /// True if the event is set or the phase number changed, false if the timeout expired - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private bool DiscontinuousWait(ManualResetEventSlim currentPhaseEvent, int totalTimeout, CancellationToken token, long observedPhase) { int maxWait = 100; // 100 ms diff --git a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs index b7e28eba55680..a006fdf80f674 100644 --- a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs +++ b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs @@ -415,7 +415,7 @@ public void Reset(int count) /// /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait() { Wait(Timeout.Infinite, CancellationToken.None); @@ -439,7 +439,7 @@ public void Wait() /// canceled. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void Wait(CancellationToken cancellationToken) { Wait(Timeout.Infinite, cancellationToken); @@ -459,7 +459,7 @@ public void Wait(CancellationToken cancellationToken) /// than . /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout) { long totalMilliseconds = (long)timeout.TotalMilliseconds; @@ -490,7 +490,7 @@ public bool Wait(TimeSpan timeout) /// disposed. /// has /// been canceled. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { long totalMilliseconds = (long)timeout.TotalMilliseconds; @@ -514,7 +514,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) /// negative number other than -1, which represents an infinite time-out. /// The current instance has already been /// disposed. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout) { return Wait(millisecondsTimeout, CancellationToken.None); @@ -537,7 +537,7 @@ public bool Wait(int millisecondsTimeout) /// disposed. /// has /// been canceled. - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { if (millisecondsTimeout < -1) diff --git a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs index eb14b86dd9aaa..dee919fcff48b 100644 --- a/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs +++ b/src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs @@ -74,7 +74,7 @@ public bool AnyWritersSince(int seqNum) return (uint)_writerSeqNum > (uint)seqNum; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void AcquireReaderLock(int millisecondsTimeout) { if (millisecondsTimeout < -1) @@ -277,7 +277,7 @@ public void AcquireReaderLock(int millisecondsTimeout) ++threadLocalLockEntry._readerLevel; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void AcquireReaderLock(TimeSpan timeout) => AcquireReaderLock(ToTimeoutMilliseconds(timeout)); public void AcquireWriterLock(int millisecondsTimeout) @@ -668,7 +668,7 @@ public void ReleaseWriterLock() } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public LockCookie UpgradeToWriterLock(int millisecondsTimeout) { if (millisecondsTimeout < -1) @@ -748,7 +748,7 @@ public LockCookie UpgradeToWriterLock(int millisecondsTimeout) } } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public LockCookie UpgradeToWriterLock(TimeSpan timeout) => UpgradeToWriterLock(ToTimeoutMilliseconds(timeout)); public void DowngradeFromWriterLock(ref LockCookie lockCookie) @@ -916,7 +916,7 @@ public LockCookie ReleaseLock() return lockCookie; } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public void RestoreLock(ref LockCookie lockCookie) { // Validate cookie @@ -982,7 +982,7 @@ public void RestoreLock(ref LockCookie lockCookie) /// /// Helper function that restores the lock to the original state indicated by parameters /// - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] private void RecoverLock(ref LockCookie lockCookie, LockCookieFlags flags) { // Contrary to the legacy code, this method does not use a finite timeout for recovering the previous lock state, as diff --git a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs index 99e82f525ee68..efa22a86bf7b1 100644 --- a/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs +++ b/src/libraries/System.Transactions.Local/ref/System.Transactions.Local.cs @@ -8,7 +8,7 @@ namespace System.Transactions { - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public sealed partial class CommittableTransaction : System.Transactions.Transaction, System.IAsyncResult { public CommittableTransaction() { } @@ -223,7 +223,7 @@ protected TransactionPromotionException(System.Runtime.Serialization.Serializati public TransactionPromotionException(string? message) { } public TransactionPromotionException(string? message, System.Exception? innerException) { } } - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public sealed partial class TransactionScope : System.IDisposable { public TransactionScope() { } diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs index dfeace8bd4a53..ca9f0b250124f 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs @@ -9,7 +9,7 @@ namespace System.Transactions { - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class CommittableTransaction : Transaction, IAsyncResult { // Create a transaction with defaults diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs index b761e13c0c2de..93e384558bd1b 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs @@ -33,7 +33,7 @@ public enum EnterpriseServicesInteropOption Full = 2 } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class TransactionScope : IDisposable { public TransactionScope() : this(TransactionScopeOption.Required) diff --git a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs index 126e319d3d446..82754b0f09165 100644 --- a/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs +++ b/src/libraries/System.Xml.ReaderWriter/ref/System.Xml.ReaderWriter.cs @@ -1142,9 +1142,9 @@ public partial class XmlUrlResolver : System.Xml.XmlResolver { public XmlUrlResolver() { } public System.Net.Cache.RequestCachePolicy CachePolicy { set { } } - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public override System.Net.ICredentials? Credentials { set { } } - [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatform("browser"), System.Runtime.Versioning.UnsupportedOSPlatform("wasi")] public System.Net.IWebProxy? Proxy { set { } } public override object? GetEntity(System.Uri absoluteUri, string? role, System.Type? ofObjectToReturn) { throw null; } public override System.Threading.Tasks.Task GetEntityAsync(System.Uri absoluteUri, string? role, System.Type? ofObjectToReturn) { throw null; } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs index 413198df4ad48..ec98c5ef23530 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs @@ -60,7 +60,7 @@ public static bool IsEntered(object obj) return IsEnteredNative(obj); } - [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public static bool Wait(object obj, int millisecondsTimeout) { ArgumentNullException.ThrowIfNull(obj); diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs index a5e54288a2920..3cebf9adf1815 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs @@ -14,7 +14,7 @@ namespace System.Threading { #if !FEATURE_WASM_THREADS - [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")] #endif public sealed class RegisteredWaitHandle : MarshalByRefObject { From 28a064bdd2772c88bbd7f62a5da9f53e5285f6cf Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 22:18:19 +0100 Subject: [PATCH 093/116] wip --- src/mono/wasi/wasi.proj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 021bfa9a7971a..90d02d60269cd 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -174,7 +174,9 @@ $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASM_OPT_FLAGS="@(WasmOptConfigurationFlags, ';')" $(CMakeBuildRuntimeConfigureCmd) -DMONO_INCLUDES="$(MonoArtifactsPath)include/mono-2.0" $(CMakeBuildRuntimeConfigureCmd) -DMONO_OBJ_INCLUDES="$(MonoObjDir.TrimEnd('\/'))" + $(CMakeBuildRuntimeConfigureCmd) -DMONO_ARTIFACTS_DIR="$(MonoArtifactsPath.TrimEnd('\/'))" $(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/'))" $(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd" From 9955c07d638f693599faee6f5159dc1624b5c113 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 22:42:32 +0100 Subject: [PATCH 094/116] wip --- .../src/System/Security/Cryptography/Helpers.cs | 12 ++++++------ .../Common/tests/System/IO/ReparsePointUtilities.cs | 2 +- .../src/PhysicalFileProvider.cs | 2 +- .../src/PhysicalFilesWatcher.cs | 2 +- .../src/HostBuilder.netcoreapp.cs | 2 +- .../src/HostingHostBuilderExtensions.cs | 2 +- .../System/Diagnostics/Metrics/MetricsEventSource.cs | 4 ++-- .../src/System/Diagnostics/XmlWriterTraceListener.cs | 2 +- .../tests/MemoryMappedFilesTestsBase.Unix.cs | 2 +- .../src/System/Linq/ParallelEnumerable.cs | 2 +- src/libraries/System.Net.Http/ref/System.Net.Http.cs | 2 +- .../Http/BrowserHttpHandler/SocketsHttpHandler.cs | 2 +- .../Http/SocketsHttpHandler/SocketsHttpHandler.cs | 4 ++-- .../Win32/SafeHandles/SafeFileHandle.Unix.cs | 2 +- .../System/Globalization/GlobalizationMode.Unix.cs | 2 +- .../src/System/Globalization/Normalization.Icu.cs | 2 +- .../src/System/IO/FileSystem.Unix.cs | 2 +- .../src/System/Threading/Thread.cs | 6 +++--- .../System/Runtime/Caching/HostFileChangeMonitor.cs | 2 +- .../src/System/Runtime/Caching/MemoryCache.cs | 4 ++-- .../System/Runtime/Caching/MemoryCacheStatistics.cs | 4 ++-- .../src/System/Runtime/Caching/MemoryCacheStore.cs | 4 ++-- .../tests/System/EnvironmentTests.cs | 4 ++-- .../src/System/Threading/Tasks/Parallel.cs | 2 +- .../src/System/Threading/Tasks/TaskReplicator.cs | 2 +- .../Common/CoreCLRTestLibrary/OutOfProcessTest.cs | 3 ++- .../Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs | 4 ++-- src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs | 4 ++++ 28 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs b/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs index b1dc4d1de9a04..8c5382aa882d1 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs @@ -10,10 +10,10 @@ namespace Internal.Cryptography { internal static partial class Helpers { - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] internal static bool HasSymmetricEncryption { get; } = #if NETCOREAPP - !OperatingSystem.IsBrowser(); + !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else true; #endif @@ -28,16 +28,16 @@ internal static partial class Helpers #if NETCOREAPP [UnsupportedOSPlatformGuard("android")] - [UnsupportedOSPlatformGuard("browser")] - public static bool IsRC2Supported => !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser(); + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] + public static bool IsRC2Supported => !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else public static bool IsRC2Supported => true; #endif - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] internal static bool HasMD5 { get; } = #if NETCOREAPP - !OperatingSystem.IsBrowser(); + !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else true; #endif diff --git a/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs b/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs index 8a146c9b0dc19..532ac9ed002da 100644 --- a/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs +++ b/src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs @@ -76,7 +76,7 @@ public static bool CreateSymbolicLink(string linkPath, string targetPath, bool i #if NETFRAMEWORK bool isWindows = true; #else - if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsBrowser()) // OSes that don't support Process.Start() + if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) // OSes that don't support Process.Start() { return false; } diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs index fb2306d56e9f9..0499f4fdb1e90 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs @@ -164,7 +164,7 @@ internal PhysicalFilesWatcher CreateFileWatcher() FileSystemWatcher? watcher; #if NETCOREAPP // For browser/iOS/tvOS we will proactively fallback to polling since FileSystemWatcher is not supported. - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi") || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { UsePollingFileWatcher = true; UseActivePolling = true; diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index 6326fe5b4e939..5c8f67fa2b515 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -89,7 +89,7 @@ public PhysicalFilesWatcher( if (fileSystemWatcher != null) { #if NETCOREAPP - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi") || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher))); } diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs index 1407f690de359..d2e975156f1cc 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs @@ -11,7 +11,7 @@ public partial class HostBuilder { private static void AddLifetime(IServiceCollection services) { - if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) + if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi") && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) { services.AddSingleton(); } diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs index edca555fdf4b0..a489bceb13042 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs @@ -280,7 +280,7 @@ internal static void AddDefaultServices(HostBuilderContext hostingContext, IServ logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); #if NETCOREAPP - if (!OperatingSystem.IsBrowser()) + if (!OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi")) #endif { logging.AddConsole(); diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index 8a700f177e72b..9837156361f21 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -236,13 +236,13 @@ public void OnEventCommand(EventCommandEventArgs command) return; } #endif -#if OS_ISWASI_SUPPORT +//#if OS_ISWASI_SUPPORT TODOWASI if (OperatingSystem.IsOSPlatform("Wasi")) // TODO replace with https://github.com/dotnet/runtime/issues/78389 { Parent.Error("", "System.Diagnostics.Metrics EventSource not supported on WASI"); return; } -#endif +//#endif if (command.Command == EventCommand.Update || command.Command == EventCommand.Disable || command.Command == EventCommand.Enable) { diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs index a513b8aa86159..5b32a9e8f072e 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs @@ -250,7 +250,7 @@ private void WriteEndHeader() string? processName = s_processName; if (processName is null) { - if (OperatingSystem.IsBrowser()) // Process isn't supported on Browser + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) // Process isn't supported on Browser { s_processName = processName = string.Empty; } diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs index 8764766e46a87..f58139221d971 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedFilesTestsBase.Unix.cs @@ -14,7 +14,7 @@ public abstract partial class MemoryMappedFilesTestBase : FileCleanupTestBase /// Gets the system's page size. protected static Lazy s_pageSize = new Lazy(() => { - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) return Environment.SystemPageSize; int pageSize; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs index 81de50225cbd8..9d8ce440ffdf9 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs @@ -65,7 +65,7 @@ public static class ParallelEnumerable // When running in single partition mode, PLINQ operations will occur on a single partition and will not // be executed in parallel, but will retain PLINQ semantics (exceptions wrapped as aggregates, etc). [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")] - internal static bool SinglePartitionMode => OperatingSystem.IsBrowser(); + internal static bool SinglePartitionMode => OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi"); //----------------------------------------------------------------------------------- // Converts any IEnumerable into something that can be the target of parallel diff --git a/src/libraries/System.Net.Http/ref/System.Net.Http.cs b/src/libraries/System.Net.Http/ref/System.Net.Http.cs index ab8fde5c1e33b..8e3aba1e23a90 100644 --- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs +++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs @@ -374,7 +374,7 @@ public sealed partial class SocketsHttpHandler : System.Net.Http.HttpMessageHand { public SocketsHttpHandler() { } public int InitialHttp2StreamWindowSize { get { throw null; } set { } } - [System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute("browser")] + [System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute("browser"), System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute("wasi")] public static bool IsSupported { get { throw null; } } public bool AllowAutoRedirect { get { throw null; } set { } } public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs index 9ad76fda29e69..b72d6b552ab2f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs @@ -15,7 +15,7 @@ namespace System.Net.Http [UnsupportedOSPlatform("browser"), UnsupportedOSPlatform("wasi")] public sealed class SocketsHttpHandler : HttpMessageHandler { - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] public static bool IsSupported => false; public bool UseCookies diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs index b451e31c2773d..5eb4facf6ff65 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs @@ -33,8 +33,8 @@ private void CheckDisposedOrStarted() /// /// Gets a value that indicates whether the handler is supported on the current platform. /// - [UnsupportedOSPlatformGuard("browser")] - public static bool IsSupported => !OperatingSystem.IsBrowser(); + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] + public static bool IsSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); public bool UseCookies { diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs index fb5c8faad4688..a4894c29624a6 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs @@ -34,7 +34,7 @@ public sealed partial class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid UnixFileMode.OtherRead | UnixFileMode.OtherWrite; - internal static bool DisableFileLocking { get; } = OperatingSystem.IsBrowser() // #40065: Emscripten does not support file locking + internal static bool DisableFileLocking { get; } = OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi") // #40065: Emscripten does not support file locking || AppContextConfigHelper.GetBooleanConfig("System.IO.DisableFileLocking", "DOTNET_SYSTEM_IO_DISABLEFILELOCKING", defaultValue: false); // not using bool? as it's not thread safe diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index 46850d3d090df..5bafbba00838e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -36,7 +36,7 @@ static Settings() private static string GetIcuLoadFailureMessage() { // These strings can't go into resources, because a resource lookup requires globalization, which requires ICU - if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi") || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS()) { return "Unable to load required ICU Globalization data. Please see https://aka.ms/dotnet-missing-libicu for more information"; diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs index cfe698fabcd98..c2b99f7dfd72d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs @@ -101,7 +101,7 @@ private static void ValidateArguments(string strInput, NormalizationForm normali Debug.Assert(strInput != null); - if (OperatingSystem.IsBrowser() && (normalizationForm == NormalizationForm.FormKC || normalizationForm == NormalizationForm.FormKD)) + if ((OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) && (normalizationForm == NormalizationForm.FormKC || normalizationForm == NormalizationForm.FormKD)) { // Browser's ICU doesn't contain data needed for FormKC and FormKD throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs index f28cd70f08f83..fef892e1874aa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs @@ -395,7 +395,7 @@ private static void MoveDirectory(string sourceFullPath, string destFullPath, bo // When the path ends with a directory separator, it must not be a file. // On Unix 'rename' fails with ENOTDIR, on wasm we need to manually check. - if (OperatingSystem.IsBrowser() && Path.EndsInDirectorySeparator(sourceFullPath) && FileExists(sourceFullPath)) + if ((OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) && Path.EndsInDirectorySeparator(sourceFullPath) && FileExists(sourceFullPath)) { throw new IOException(SR.Format(SR.IO_PathNotFound_Path, sourceFullPath)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index c0d353c40888c..ad91527a1bd8e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -154,15 +154,15 @@ public Thread(ParameterizedThreadStart start, int maxStackSize) } #if !(TARGET_BROWSER || TARGET_WASI) || FEATURE_WASM_THREADS - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => true; internal static bool IsInternalThreadStartSupported => true; #elif FEATURE_WASM_PERFTRACING - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => false; internal static bool IsInternalThreadStartSupported => true; #else - [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => false; internal static bool IsInternalThreadStartSupported => false; #endif diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs index 85730638cd743..3879af4ead559 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs @@ -99,7 +99,7 @@ private static void InitFCN() if (fcn == null) { #if NETCOREAPP - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsOSPlatform("Wasi") || OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs index e740eed69ed51..84bc2a5e9147f 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs @@ -41,8 +41,8 @@ public class MemoryCache : ObjectCache, IEnumerable, IDisposable private EventHandler _onAppDomainUnload; private UnhandledExceptionEventHandler _onUnhandledException; #if NETCOREAPP - [UnsupportedOSPlatformGuard("browser")] - private static bool _countersSupported => !OperatingSystem.IsBrowser(); + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] + private static bool _countersSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else private static bool _countersSupported => true; #endif diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs index 96cfc3bda655b..633cfc384b185 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs @@ -38,8 +38,8 @@ internal sealed class MemoryCacheStatistics : IDisposable private readonly MemoryCache _memoryCache; private readonly PhysicalMemoryMonitor _physicalMemoryMonitor; #if NETCOREAPP - [UnsupportedOSPlatformGuard("browser")] - private static bool _configSupported => !OperatingSystem.IsBrowser(); + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] + private static bool _configSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else private static bool _configSupported => true; #endif diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs index 343f3beb4a845..90768c5aab65c 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs @@ -27,8 +27,8 @@ internal sealed class MemoryCacheStore : IDisposable private readonly MemoryCache _cache; private readonly Counters _perfCounters; #if NETCOREAPP - [UnsupportedOSPlatformGuard("browser")] - private static bool _countersSupported => !OperatingSystem.IsBrowser(); + [UnsupportedOSPlatformGuard("browser"), UnsupportedOSPlatformGuard("wasi")] + private static bool _countersSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsOSPlatform("Wasi"); #else private static bool _countersSupported => true; #endif diff --git a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs index 55c666ba0b8b4..9782ad0cec546 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs @@ -139,7 +139,7 @@ public void OSVersion_Idempotent() public void OSVersion_MatchesPlatform() { PlatformID id = Environment.OSVersion.Platform; - PlatformID expected = OperatingSystem.IsWindows() ? PlatformID.Win32NT : OperatingSystem.IsBrowser() ? PlatformID.Other : PlatformID.Unix; + PlatformID expected = OperatingSystem.IsWindows() ? PlatformID.Win32NT : (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) ? PlatformID.Other : PlatformID.Unix; Assert.Equal(expected, id); } @@ -154,7 +154,7 @@ public void OSVersion_ValidVersion() Assert.Contains(version.ToString(2), versionString); - string expectedOS = OperatingSystem.IsWindows() ? "Windows " : OperatingSystem.IsBrowser() ? "Other " : "Unix "; + string expectedOS = OperatingSystem.IsWindows() ? "Windows " : (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) ? "Other " : "Unix "; Assert.Contains(expectedOS, versionString); } diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs index a64f09a25ff31..045ed694747b4 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs @@ -238,7 +238,7 @@ public static void Invoke(ParallelOptions parallelOptions, params Action[] actio // If we've gotten this far, it's time to process the actions. // Web browsers need special treatment that is implemented in TaskReplicator - if (OperatingSystem.IsBrowser() || + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi") || // This is more efficient for a large number of actions, or for enforcing MaxDegreeOfParallelism: (actionsCopy.Length > SMALL_ACTIONCOUNT_LIMIT) || (parallelOptions.MaxDegreeOfParallelism != -1 && parallelOptions.MaxDegreeOfParallelism < actionsCopy.Length) diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs index a84113bd775aa..eeed2f8647067 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs @@ -133,7 +133,7 @@ public static void Run(ReplicatableUserAction action, ParallelOp { // Browser hosts do not support synchronous Wait so we want to run the // replicated task directly instead of going through Task infrastructure - if (OperatingSystem.IsBrowser()) { + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) { // Since we are running on a single thread, we don't want the action to time out var timeout = int.MaxValue - 1; var state = default(TState)!; diff --git a/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs b/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs index ad68f35537b92..d805f4c21a1cf 100644 --- a/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs +++ b/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs @@ -46,7 +46,8 @@ static OutOfProcessTest() !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS() && !OperatingSystem.IsAndroid() - && !OperatingSystem.IsBrowser(); + && !OperatingSystem.IsBrowser() + && !OperatingSystem.IsOSPlatform("Wasi"); public static void RunOutOfProcessTest(string basePath, string assemblyPath) { diff --git a/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs b/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs index daf22773002ef..43dd5d38db87e 100644 --- a/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs +++ b/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs @@ -30,7 +30,7 @@ public static async Task RunTests( { entryPoint = new AppleEntryPoint(new SimpleDevice(assemblyName), runTestsCallback, assemblyName, filter, testExclusionList); } - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) { entryPoint = new WasmEntryPoint(runTestsCallback, assemblyName, filter, testExclusionList); } @@ -42,7 +42,7 @@ public static async Task RunTests( entryPoint.TestsCompleted += (o, e) => anyFailedTests = e.FailedTests > 0; await entryPoint.RunAsync(); - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsOSPlatform("Wasi")) { // Browser expects all xharness processes to exit with 0, even in case of failure return 0; diff --git a/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs b/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs index 213fc3d36d1bb..6ec3f4e5765c2 100644 --- a/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs +++ b/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs @@ -182,6 +182,10 @@ private static string GetPlatformConditionFromTestPlatform(Xunit.TestPlatforms p { platformCheckConditions.Add("global::System.OperatingSystem.IsBrowser()"); } + if (platform.HasFlag(Xunit.TestPlatforms.Wasi)) + { + platformCheckConditions.Add("global::System.OperatingSystem.IsOSPlatform("Wasi")"); + } if (platform.HasFlag(Xunit.TestPlatforms.FreeBSD)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsFreeBSD()"); From 33a62d18697f0ff2b5d01170c61c90bf7ad051bd Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 16 Nov 2022 22:44:10 +0100 Subject: [PATCH 095/116] wip --- src/libraries/Directory.Build.props | 5 +++++ src/libraries/System.Console/src/System.Console.csproj | 1 - .../src/System.Diagnostics.DiagnosticSource.csproj | 3 +++ .../System.IO.Compression/src/System.IO.Compression.csproj | 1 - .../src/System.IO.MemoryMappedFiles.csproj | 1 - .../System.Linq.Parallel/src/System.Linq.Parallel.csproj | 5 +++++ src/libraries/System.Linq/src/System.Linq.csproj | 1 - src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 1 - .../src/System.Net.NameResolution.csproj | 1 - .../System.Net.Primitives/src/System.Net.Primitives.csproj | 1 - .../System.Net.WebClient/src/System.Net.WebClient.csproj | 1 - .../System.Net.WebProxy/src/System.Net.WebProxy.csproj | 1 - .../System.Net.WebSockets/src/System.Net.WebSockets.csproj | 1 - .../ref/System.Runtime.Serialization.Formatters.csproj | 1 - .../src/System.Runtime.Serialization.Formatters.csproj | 1 - .../src/System.Security.Cryptography.csproj | 1 - .../src/System.Text.Encodings.Web.csproj | 1 - .../System.Private.CoreLib/System.Private.CoreLib.csproj | 4 ++++ 18 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 7cf964f8366d8..2cbab269e9ba7 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -133,6 +133,11 @@ --interpreter + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + false + $(NoWarn);CA1416 + $(ArtifactsBinDir)dotnet-none\ diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index bf2d00fdc3977..43f8f2241e157 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -6,7 +6,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(NoWarn);CA1418 SR.PlatformNotSupported_SystemConsole diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj index b3f55c9254d7c..3a8c5856cf6a0 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj @@ -19,6 +19,9 @@ System.Diagnostics.DiagnosticSource $(DefineConstants);ALLOW_PARTIALLY_TRUSTED_CALLERS;ENABLE_HTTP_HANDLER $(DefineConstants);W3C_DEFAULT_ID_FORMAT;MEMORYMARSHAL_SUPPORT;OS_ISBROWSER_SUPPORT true + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(NoWarn);CA1416 diff --git a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj index cfa84d1c90a33..5179e9a2370ed 100644 --- a/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj +++ b/src/libraries/System.IO.Compression/src/System.IO.Compression.csproj @@ -7,7 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_Compression - $(NoWarn);CA1418 diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index 3092e00dab960..4dcee115f02f0 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -7,7 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_MemoryMappedFiles - $(NoWarn);CA1418 diff --git a/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj b/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj index b9bcf9eefa255..15898f8a267dd 100644 --- a/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj +++ b/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj @@ -3,6 +3,11 @@ true $(NetCoreAppCurrent) + + + $(NoWarn);CA1416 + + diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index 988e942b7e12c..993638eedd83d 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -6,7 +6,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) true - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 44a92f8196a45..61e9001c00834 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -7,7 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetMail - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 913861839679b..ae1e6fd7053e1 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -8,7 +8,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemNetNameResolution_PlatformNotSupported ExcludeApiList.PNSE.Browser.txt - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 704a262ff816f..c61e34eda1485 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -12,7 +12,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetPrimitives ReferenceAssemblyExclusions.txt - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj index e9aa43cd1cef5..3b0b9533cf661 100644 --- a/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj +++ b/src/libraries/System.Net.WebClient/src/System.Net.WebClient.csproj @@ -6,7 +6,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemNetWebClient_PlatformNotSupported - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index c4d7a583f8f9c..1a6e5df4e90f6 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -3,7 +3,6 @@ true $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-wasi $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(NoWarn);CA1418 diff --git a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj index 75e4871a31e5a..4133f2e95950c 100644 --- a/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj +++ b/src/libraries/System.Net.WebSockets/src/System.Net.WebSockets.csproj @@ -7,7 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_WebSockets - $(NoWarn);CA1418 diff --git a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj index e2c2e72bb32ea..bf3180575eb51 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/ref/System.Runtime.Serialization.Formatters.csproj @@ -2,7 +2,6 @@ $(NetCoreAppCurrent) $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(NoWarn);CA1418 diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj index 4ed56a9123f51..ebd413ee0fcde 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj @@ -11,7 +11,6 @@ $(NoWarn);CS0649 $(NoWarn);CA1822;IDE0060 - $(NoWarn);CA1418 diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index df36fd7ab34a3..37f3691de7cbd 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -17,7 +17,6 @@ true true true - $(NoWarn);CA1418 diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index d57b35aa41700..0f63651fb135b 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -19,7 +19,6 @@ System.Text.Encodings.Web.JavaScriptEncoder $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) $(DefineConstants);TARGET_BROWSER $(DefineConstants);TARGET_WASI - $(NoWarn);CA1418 diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 2f2c8230c771c..80296af04103a 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -304,6 +304,10 @@ + + + false + From f9ef2f9621191e2c2e75dd5fc8ccb5f0ab44dc08 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 13:14:31 +0100 Subject: [PATCH 096/116] pal_mount.c --- src/native/libs/Common/pal_config.h.in | 1 + src/native/libs/System.Native/pal_mount.c | 53 +++++++++-------------- src/native/libs/configure.cmake | 4 ++ 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in index 6b5b83d4a191a..2b44bcfc1b732 100644 --- a/src/native/libs/Common/pal_config.h.in +++ b/src/native/libs/Common/pal_config.h.in @@ -51,6 +51,7 @@ #cmakedefine01 HAVE_FDS_BITS #cmakedefine01 HAVE_PRIVATE_FDS_BITS #cmakedefine01 HAVE_STATFS +#cmakedefine01 HAVE_MNTENT_H #cmakedefine01 HAVE_SYS_SOCKIO_H #cmakedefine01 HAVE_ETHTOOL_H #cmakedefine01 HAVE_SYS_POLL_H diff --git a/src/native/libs/System.Native/pal_mount.c b/src/native/libs/System.Native/pal_mount.c index 34c63b6d6a292..efae24f776847 100644 --- a/src/native/libs/System.Native/pal_mount.c +++ b/src/native/libs/System.Native/pal_mount.c @@ -10,27 +10,29 @@ #include // Check if we should use getmntinfo or /proc/mounts -#if !defined(TARGET_WASI) #if HAVE_MNTINFO #include -#else +#else /* HAVE_MNTINFO */ +#if HAVE_STATFS #include +#endif /* HAVE_STATFS */ #if HAVE_SYS_MNTENT_H #include #include #if HAVE_SYS_STATVFS_H #include -#endif -#else +#endif /* HAVE_SYS_STATVFS_H */ +#else /* HAVE_SYS_MNTENT_H */ +#if HAVE_MNTENT_H #include -#endif #define STRING_BUFFER_SIZE 8192 - // Android does not define MNTOPT_RO #ifndef MNTOPT_RO #define MNTOPT_RO "r" -#endif -#endif +#endif /* MNTOPT_RO */ +#endif /* HAVE_MNTENT_H */ +#endif /* HAVE_SYS_MNTENT_H */ +#endif /* HAVE_MNTINFO */ int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) { @@ -71,7 +73,7 @@ int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) return result; } -#else +#elif HAVE_MNTENT_H int result = -1; FILE* fp = setmntent("/proc/mounts", MNTOPT_RO); if (fp != NULL) @@ -92,6 +94,8 @@ int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) } return result; +#else + return -1; } #endif @@ -106,12 +110,15 @@ int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInfor memset(&stats, 0, sizeof(struct statfs)); int result = statfs(name, &stats); -#else +#elif HAVE_MNTENT_H struct statvfs stats; memset(&stats, 0, sizeof(struct statvfs)); int result = statvfs(name, &stats); +#else + return -1; #endif +#if HAVE_NON_LEGACY_STATFS || HAVE_MNTENT_H if (result == 0) { // Note that these have signed integer types on some platforms but mustn't be negative. @@ -132,6 +139,7 @@ int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInfor } return result; +#endif } int32_t @@ -143,9 +151,11 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer #if HAVE_NON_LEGACY_STATFS struct statfs stats; int result = statfs(name, &stats); -#else +#elif HAVE_MNTENT_H struct statvfs stats; int result = statvfs(name, &stats); +#else + int result = -1; #endif if (result == 0) { @@ -180,24 +190,3 @@ SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer return result; } -#else /* TARGET_WASI */ -int32_t SystemNative_GetAllMountPoints(MountPointFound onFound, void* context) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0; -} - -int32_t SystemNative_GetSpaceInfoForMountPoint(const char* name, MountPointInformation* mpi) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - memset(mpi, 0, sizeof(MountPointInformation)); - return -1; -} - -int32_t -SystemNative_GetFormatInfoForMountPoint(const char* name, char* formatNameBuffer, int32_t bufferLength, int64_t* formatType) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} -#endif /* TARGET_WASI */ diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 3c29b5ad723c6..887ee3be5979a 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -367,6 +367,10 @@ check_symbol_exists( ${STATFS_INCLUDES} HAVE_STATFS) +check_include_files( + "mntent.h" + HAVE_MNTENT_H) + check_type_size( "struct statfs" STATFS_SIZE From 3b36bf88294cc0caef893d6ecfb22a583d54a297 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 13:45:53 +0100 Subject: [PATCH 097/116] pal_process.c --- src/native/libs/Common/pal_config.h.in | 2 + src/native/libs/System.Native/pal_process.c | 163 +++++--------------- src/native/libs/configure.cmake | 9 ++ 3 files changed, 53 insertions(+), 121 deletions(-) diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in index 2b44bcfc1b732..7749490c023b0 100644 --- a/src/native/libs/Common/pal_config.h.in +++ b/src/native/libs/Common/pal_config.h.in @@ -52,6 +52,8 @@ #cmakedefine01 HAVE_PRIVATE_FDS_BITS #cmakedefine01 HAVE_STATFS #cmakedefine01 HAVE_MNTENT_H +#cmakedefine01 HAVE_SIGNAL_KILL +#cmakedefine01 HAVE_SYS_RESOURCE_H #cmakedefine01 HAVE_SYS_SOCKIO_H #cmakedefine01 HAVE_ETHTOOL_H #cmakedefine01 HAVE_SYS_POLL_H diff --git a/src/native/libs/System.Native/pal_process.c b/src/native/libs/System.Native/pal_process.c index 92548fc021a99..0ac81db47cc75 100644 --- a/src/native/libs/System.Native/pal_process.c +++ b/src/native/libs/System.Native/pal_process.c @@ -217,6 +217,7 @@ handler_from_sigaction (struct sigaction *sa) return sa->sa_handler; } } +#endif /* TARGET_WASI */ int32_t SystemNative_ForkAndExecProcess(const char* filename, char* const argv[], @@ -520,6 +521,7 @@ done:; #endif } +#if !defined(TARGET_WASI) // Each platform type has it's own RLIMIT values but the same name, so we need // to convert our standard types into the platform specific ones. static int32_t ConvertRLimitResourcesPalToPlatform(RLimitResources value) @@ -618,11 +620,12 @@ typedef __priority_which_t priorityWhich; typedef int rlimitResource; typedef int priorityWhich; #endif +#endif /* TARGET_WASI */ int32_t SystemNative_GetRLimit(RLimitResources resourceType, RLimit* limits) { assert(limits != NULL); - +#if HAVE_SYS_RESOURCE_H int32_t platformLimit = ConvertRLimitResourcesPalToPlatform(resourceType); struct rlimit internalLimit; int result = getrlimit((rlimitResource)platformLimit, &internalLimit); @@ -634,6 +637,10 @@ int32_t SystemNative_GetRLimit(RLimitResources resourceType, RLimit* limits) { memset(limits, 0, sizeof(RLimit)); } +#else /* HAVE_SYS_RESOURCE_H */ + int result = -1; + memset(limits, 0, sizeof(RLimit)); +#endif return result; } @@ -642,14 +649,19 @@ int32_t SystemNative_SetRLimit(RLimitResources resourceType, const RLimit* limit { assert(limits != NULL); +#if HAVE_SYS_RESOURCE_H int32_t platformLimit = ConvertRLimitResourcesPalToPlatform(resourceType); struct rlimit internalLimit; ConvertFromRLimitManagedToPal(limits, &internalLimit); return setrlimit((rlimitResource)platformLimit, &internalLimit); +#else /* HAVE_SYS_RESOURCE_H */ + return -1; +#endif } int32_t SystemNative_Kill(int32_t pid, int32_t signal) { +#if HAVE_SIGNAL_KILL switch (signal) { case PAL_NONE: @@ -671,25 +683,39 @@ int32_t SystemNative_Kill(int32_t pid, int32_t signal) } return kill(pid, signal); +#else /* HAVE_SIGNAL_KILL */ + return -1; +#endif /* HAVE_SIGNAL_KILL */ } int32_t SystemNative_GetPid(void) { +#if !defined(TARGET_WASI) return getpid(); +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetSid(int32_t pid) { +#if !defined(TARGET_WASI) return getsid(pid); +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } void SystemNative_SysLog(SysLogPriority priority, const char* message, const char* arg1) { +#if !defined(TARGET_WASI) syslog((int)(LOG_USER | priority), message, arg1); +#endif /* TARGET_WASI */ } int32_t SystemNative_WaitIdAnyExitedNoHangNoWait(void) { +#if !defined(TARGET_WASI) siginfo_t siginfo; memset(&siginfo, 0, sizeof(siginfo)); int32_t result; @@ -709,10 +735,14 @@ int32_t SystemNative_WaitIdAnyExitedNoHangNoWait(void) result = 0; } return result; +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } int32_t SystemNative_WaitPidExitedNoHang(int32_t pid, int32_t* exitCode) { +#if !defined(TARGET_WASI) assert(exitCode != NULL); int32_t result; @@ -736,6 +766,9 @@ int32_t SystemNative_WaitPidExitedNoHang(int32_t pid, int32_t* exitCode) } } return result; +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } int64_t SystemNative_PathConf(const char* path, PathConfName name) @@ -784,6 +817,7 @@ int64_t SystemNative_PathConf(const char* path, PathConfName name) int32_t SystemNative_GetPriority(PriorityWhich which, int32_t who) { +#if !defined(TARGET_WASI) // GetPriority uses errno 0 to show success to make sure we don't have a stale value errno = 0; #if PRIORITY_REQUIRES_INT_WHO @@ -791,15 +825,22 @@ int32_t SystemNative_GetPriority(PriorityWhich which, int32_t who) #else return getpriority((priorityWhich)which, (id_t)who); #endif +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } int32_t SystemNative_SetPriority(PriorityWhich which, int32_t who, int32_t nice) { +#if !defined(TARGET_WASI) #if PRIORITY_REQUIRES_INT_WHO return setpriority((priorityWhich)which, who, nice); #else return setpriority((priorityWhich)which, (id_t)who, nice); #endif +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } char* SystemNative_GetCwd(char* buffer, int32_t bufferSize) @@ -891,123 +932,3 @@ char* SystemNative_GetProcessPath(void) { return minipal_getexepath(); } - -#else /* TARGET_WASI */ - - -int32_t SystemNative_ForkAndExecProcess(const char* filename, - char* const argv[], - char* const envp[], - const char* cwd, - int32_t redirectStdin, - int32_t redirectStdout, - int32_t redirectStderr, - int32_t setCredentials, - uint32_t userId, - uint32_t groupId, - uint32_t* groups, - int32_t groupsLength, - int32_t* childPid, - int32_t* stdinFd, - int32_t* stdoutFd, - int32_t* stderrFd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetRLimit(RLimitResources resourceType, RLimit* limits) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_SetRLimit(RLimitResources resourceType, const RLimit* limits) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Kill(int32_t pid, int32_t signal) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetPid(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetSid(int32_t pid) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -void SystemNative_SysLog(SysLogPriority priority, const char* message, const char* arg1) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_WaitIdAnyExitedNoHangNoWait(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_WaitPidExitedNoHang(int32_t pid, int32_t* exitCode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int64_t SystemNative_PathConf(const char* path, PathConfName name) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetPriority(PriorityWhich which, int32_t who) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_SetPriority(PriorityWhich which, int32_t who, int32_t nice) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -char* SystemNative_GetCwd(char* buffer, int32_t bufferSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -int32_t SystemNative_SchedSetAffinity(int32_t pid, intptr_t* mask) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - (void)pid; - (void)mask; - errno = ENOTSUP; - return -1; -} - -int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - (void)pid; - (void)mask; - errno = ENOTSUP; - return -1; -} - -char* SystemNative_GetProcessPath(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} -#endif /* TARGET_WASI */ diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 887ee3be5979a..b624b0ee209be 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -367,10 +367,19 @@ check_symbol_exists( ${STATFS_INCLUDES} HAVE_STATFS) +check_symbol_exists( + "kill" + "signal.h" + HAVE_SIGNAL_KILL) + check_include_files( "mntent.h" HAVE_MNTENT_H) +check_include_files( + "sys/resource.h" + HAVE_SYS_RESOURCE_H) + check_type_size( "struct statfs" STATFS_SIZE From f8e0a77e93dd6659906b15b25a4e65c6b2a3c63d Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 13:57:54 +0100 Subject: [PATCH 098/116] pal_threading.c --- src/native/libs/System.Native/pal_threading.c | 98 +++++-------------- 1 file changed, 24 insertions(+), 74 deletions(-) diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index f67c764cdffc0..09d49be20fb07 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -28,14 +28,17 @@ #define _XOPEN_SOURCE #endif -#if !defined(TARGET_WASI) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LowLevelMonitor - Represents a non-recursive mutex and condition struct LowLevelMonitor { +#if !defined(TARGET_WASI) pthread_mutex_t Mutex; pthread_cond_t Condition; +#else /* !TARGET_WASI */ + bool Dummy; +#endif /* !TARGET_WASI */ #ifdef DEBUG bool IsLocked; #endif @@ -59,6 +62,7 @@ LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void) { return NULL; } +#if !defined(TARGET_WASI) int error; @@ -109,12 +113,16 @@ LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void) assert(error == 0); free(monitor); return NULL; +#else /* !TARGET_WASI */ + return monitor; +#endif /* !TARGET_WASI */ } void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor) { assert(monitor != NULL); +#if !defined(TARGET_WASI) int error; error = pthread_cond_destroy(&monitor->Condition); @@ -125,6 +133,7 @@ void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor) (void)error; // unused in release build +#endif /* !TARGET_WASI */ free(monitor); } @@ -132,9 +141,11 @@ void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor) { assert(monitor != NULL); +#if !defined(TARGET_WASI) int error = pthread_mutex_lock(&monitor->Mutex); assert(error == 0); (void)error; // unused in release build +#endif /* !TARGET_WASI */ SetIsLocked(monitor, true); } @@ -145,9 +156,11 @@ void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor) SetIsLocked(monitor, false); +#if !defined(TARGET_WASI) int error = pthread_mutex_unlock(&monitor->Mutex); assert(error == 0); (void)error; // unused in release build +#endif /* !TARGET_WASI */ } void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor) @@ -156,9 +169,11 @@ void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor) SetIsLocked(monitor, false); +#if !defined(TARGET_WASI) int error = pthread_cond_wait(&monitor->Condition, &monitor->Mutex); assert(error == 0); (void)error; // unused in release build +#endif /* !TARGET_WASI */ SetIsLocked(monitor, true); } @@ -169,6 +184,7 @@ int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monitor, int32_t SetIsLocked(monitor, false); +#if !defined(TARGET_WASI) int error; // Calculate the time at which a timeout should occur, and wait. Older versions of OSX don't support clock_gettime with @@ -203,12 +219,16 @@ int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monitor, int32_t SetIsLocked(monitor, true); return error == 0; +#else /* !TARGET_WASI */ + return true; +#endif /* !TARGET_WASI */ } void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor) { assert(monitor != NULL); +#if !defined(TARGET_WASI) int error; error = pthread_cond_signal(&monitor->Condition); @@ -220,11 +240,13 @@ void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor) assert(error == 0); (void)error; // unused in release build +#endif /* !TARGET_WASI */ } int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter) { bool result = false; +#if !defined(TARGET_WASI) pthread_attr_t attrs; int error = pthread_attr_init(&attrs); @@ -265,6 +287,7 @@ int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(voi CreateThreadExit: error = pthread_attr_destroy(&attrs); assert(error == 0); +#endif /* !TARGET_WASI */ return result; } @@ -289,76 +312,3 @@ void SystemNative_Abort(void) { abort(); } - -#else /* TARGET_WASI */ -struct LowLevelMonitor -{ - // TARGET_WASI - bool IsLocked; -}; - -LowLevelMonitor* SystemNative_LowLevelMonitor_Create(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -void SystemNative_LowLevelMonitor_Destroy(LowLevelMonitor* monitor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_LowLevelMonitor_Acquire(LowLevelMonitor* monitor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_LowLevelMonitor_Release(LowLevelMonitor* monitor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_LowLevelMonitor_Wait(LowLevelMonitor* monitor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monitor, int32_t timeoutMilliseconds) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return false; -} - -void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return false; -} - -int32_t SystemNative_SchedGetCpu(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -__attribute__((noreturn)) -void SystemNative_Exit(int32_t exitCode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - assert(false); - abort(); -} - -__attribute__((noreturn)) -void SystemNative_Abort(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - assert(false); - abort(); -} -#endif /* TARGET_WASI */ From 1265ae1f30fea5e720fa0ad8c99a2c0aaaeb0476 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 15:26:38 +0100 Subject: [PATCH 099/116] pal_uid.c --- src/native/libs/System.Native/pal_uid.c | 90 ++++++++++--------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/src/native/libs/System.Native/pal_uid.c b/src/native/libs/System.Native/pal_uid.c index 83a497691b652..e2cf3a24fb321 100644 --- a/src/native/libs/System.Native/pal_uid.c +++ b/src/native/libs/System.Native/pal_uid.c @@ -21,7 +21,7 @@ // Linux c-libraries (glibc, musl) provide a thread-safe getgrouplist. // OSX man page mentions explicitly the implementation is not thread safe, // due to using getgrent. -#ifndef __linux__ +#if !defined(__linux__) && !defined(TARGET_WASI) #define USE_GROUPLIST_LOCK #endif @@ -32,7 +32,6 @@ #endif #if !defined(TARGET_WASI) - static int32_t ConvertNativePasswdToPalPasswd(int error, struct passwd* nativePwd, struct passwd* result, Passwd* pwd) { // positive error number returned -> failure other than entry-not-found @@ -61,6 +60,7 @@ static int32_t ConvertNativePasswdToPalPasswd(int error, struct passwd* nativePw pwd->Shell = nativePwd->pw_shell; return 0; } +#endif /* !TARGET_WASI */ int32_t SystemNative_GetPwUidR(uint32_t uid, Passwd* pwd, char* buf, int32_t buflen) { @@ -71,12 +71,16 @@ int32_t SystemNative_GetPwUidR(uint32_t uid, Passwd* pwd, char* buf, int32_t buf if (buflen < 0) return EINVAL; +#if !defined(TARGET_WASI) struct passwd nativePwd; struct passwd* result; int error; while ((error = getpwuid_r(uid, &nativePwd, buf, Int32ToSizeT(buflen), &result)) == EINTR); return ConvertNativePasswdToPalPasswd(error, &nativePwd, result, pwd); +#else /* !TARGET_WASI */ + return EINVAL; +#endif /* !TARGET_WASI */ } int32_t SystemNative_GetPwNamR(const char* name, Passwd* pwd, char* buf, int32_t buflen) @@ -88,34 +92,50 @@ int32_t SystemNative_GetPwNamR(const char* name, Passwd* pwd, char* buf, int32_t if (buflen < 0) return EINVAL; +#if !defined(TARGET_WASI) struct passwd nativePwd; struct passwd* result; int error; while ((error = getpwnam_r(name, &nativePwd, buf, Int32ToSizeT(buflen), &result)) == EINTR); return ConvertNativePasswdToPalPasswd(error, &nativePwd, result, pwd); +#else /* !TARGET_WASI */ + return EINVAL; +#endif /* !TARGET_WASI */ } uint32_t SystemNative_GetEUid(void) { +#if !defined(TARGET_WASI) return geteuid(); +#else /* !TARGET_WASI */ + return EINVAL; +#endif /* !TARGET_WASI */ } uint32_t SystemNative_GetEGid(void) { +#if !defined(TARGET_WASI) return getegid(); +#else /* !TARGET_WASI */ + return EINVAL; +#endif /* !TARGET_WASI */ } int32_t SystemNative_SetEUid(uint32_t euid) { +#if !defined(TARGET_WASI) return seteuid(euid); +#else /* !TARGET_WASI */ + return EINVAL; +#endif /* !TARGET_WASI */ } #ifdef USE_GROUPLIST_LOCK static pthread_mutex_t s_groupLock = PTHREAD_MUTEX_INITIALIZER; #endif -#if !HAVE_GETGROUPLIST +#if !HAVE_GETGROUPLIST && !defined(TARGET_WASI) int getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *groupCount) { int ngroups = 1; @@ -212,8 +232,10 @@ int32_t SystemNative_GetGroupList(const char* name, uint32_t group, uint32_t* gr #ifdef __APPLE__ // On OSX groups are passed as a signed int. rv = getgrouplist(name, (int)group, (int*)groups, &groupsAvailable); -#else +#elif HAVE_GETGROUPLIST rv = getgrouplist(name, group, groups, &groupsAvailable); +#else + rv = 0; #endif #ifdef USE_GROUPLIST_LOCK @@ -244,10 +266,14 @@ int32_t SystemNative_GetGroups(int32_t ngroups, uint32_t* groups) assert(ngroups >= 0); assert(groups != NULL); +#if !defined(TARGET_WASI) return getgroups(ngroups, groups); +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } -#if !HAVE_GETGRGID_R +#if !HAVE_GETGRGID_R && !defined(TARGET_WASI) // Need to call getgrgid which is not thread-safe, and protect it with a mutex static pthread_mutex_t s_getgrgid_lock = PTHREAD_MUTEX_INITIALIZER; #endif @@ -290,7 +316,7 @@ char* SystemNative_GetGroupName(uint32_t gid) } bufferLength = tmpBufferLength; } -#else +#elif !defined(TARGET_WASI) // Platforms like Android API level < 24 do not have getgrgid_r available int rv = pthread_mutex_lock(&s_getgrgid_lock); if (rv != 0) @@ -308,55 +334,7 @@ char* SystemNative_GetGroupName(uint32_t gid) char* name = strdup(result->gr_name); pthread_mutex_unlock(&s_getgrgid_lock); return name; -#endif -} - -#else /* TARGET_WASI */ -int32_t SystemNative_GetPwUidR(uint32_t uid, Passwd* pwd, char* buf, int32_t buflen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetPwNamR(const char* name, Passwd* pwd, char* buf, int32_t buflen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -uint32_t SystemNative_GetEUid(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0xFFFFFFFF; -} - -uint32_t SystemNative_GetEGid(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0xFFFFFFFF; -} - -int32_t SystemNative_SetEUid(uint32_t euid) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetGroupList(const char* name, uint32_t group, uint32_t* groups, int32_t* ngroups) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetGroups(int32_t ngroups, uint32_t* groups) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -char* SystemNative_GetGroupName(uint32_t gid) -{ - printf ("TODOWASI %s\n", __FUNCTION__); +#else return NULL; +#endif } -#endif /* TARGET_WASI */ From acc7b1a6943e15b23cf915d1a1d05e1978aa76f0 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 15:39:37 +0100 Subject: [PATCH 100/116] pal_signal.c --- src/native/libs/System.Native/CMakeLists.txt | 2 +- src/native/libs/System.Native/pal_signal.c | 90 ++++++++------------ 2 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 5a3fb30fd9d1c..d5037d5557d55 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -1,6 +1,6 @@ project(System.Native C) -if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_WASI) add_definitions(-DHAS_CONSOLE_SIGNALS) endif () diff --git a/src/native/libs/System.Native/pal_signal.c b/src/native/libs/System.Native/pal_signal.c index fc4bf78368f6a..0f74124f8e50f 100644 --- a/src/native/libs/System.Native/pal_signal.c +++ b/src/native/libs/System.Native/pal_signal.c @@ -186,14 +186,6 @@ int32_t SystemNative_GetPlatformSignalNumber(PosixSignal signal) return 0; } -void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler) -{ - assert(signalHandler); - assert(g_posixSignalHandler == NULL || g_posixSignalHandler == signalHandler); - - g_posixSignalHandler = signalHandler; -} - static struct sigaction* OrigActionFor(int sig) { return &g_origSigHandler[sig - 1]; @@ -250,8 +242,21 @@ static void SignalHandler(int sig, siginfo_t* siginfo, void* context) } } +#endif /* TARGET_WASI */ + +void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler) +{ + assert(signalHandler); +#if !defined(TARGET_WASI) + assert(g_posixSignalHandler == NULL || g_posixSignalHandler == signalHandler); + + g_posixSignalHandler = signalHandler; +#endif /* TARGET_WASI */ +} + void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode) { +#if !defined(TARGET_WASI) switch (signalCode) { case SIGCONT: @@ -305,8 +310,10 @@ void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode) kill(g_pid, signalCode); break; } +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) // Entrypoint for the thread that handles signals where our handling // isn't signal-safe. Those signal handlers write the signal to a pipe, // which this loop reads and processes. @@ -477,10 +484,12 @@ static bool InstallSignalHandler(int sig, int flags) *isInstalled = true; return true; } +#endif /* TARGET_WASI */ void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback) { assert(callback != NULL); +#if !defined(TARGET_WASI) assert(g_terminalInvalidationCallback == NULL); bool installed = false; (void)installed; // only used for assert @@ -497,11 +506,13 @@ void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback ca assert(installed); } pthread_mutex_unlock(&lock); +#endif /* TARGET_WASI */ } void SystemNative_RegisterForSigChld(SigChldCallback callback) { assert(callback != NULL); +#if !defined(TARGET_WASI) assert(g_sigChldCallback == NULL); bool installed = false; (void)installed; // only used for assert @@ -514,15 +525,19 @@ void SystemNative_RegisterForSigChld(SigChldCallback callback) assert(installed); } pthread_mutex_unlock(&lock); +#endif /* TARGET_WASI */ } void SystemNative_SetDelayedSigChildConsoleConfigurationHandler(void (*callback)(void)) { +#if !defined(TARGET_WASI) assert(g_sigChldConsoleConfigurationCallback == NULL); g_sigChldConsoleConfigurationCallback = callback; +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static bool CreateSignalHandlerThread(int* readFdPtr) { pthread_attr_t attr; @@ -620,9 +635,11 @@ int32_t InitializeSignalHandlingCore(void) return 1; } +#endif /* TARGET_WASI */ int32_t SystemNative_EnablePosixSignalHandling(int signalCode) { +#if !defined(TARGET_WASI) assert(g_posixSignalHandler != NULL); assert(signalCode > 0 && signalCode <= GetSignalMax()); @@ -636,10 +653,14 @@ int32_t SystemNative_EnablePosixSignalHandling(int signalCode) pthread_mutex_unlock(&lock); return installed ? 1 : 0; +#else /* TARGET_WASI */ + return false; +#endif /* TARGET_WASI */ } void SystemNative_DisablePosixSignalHandling(int signalCode) { +#if !defined(TARGET_WASI) assert(signalCode > 0 && signalCode <= GetSignalMax()); pthread_mutex_lock(&lock); @@ -661,8 +682,10 @@ void SystemNative_DisablePosixSignalHandling(int signalCode) } } pthread_mutex_unlock(&lock); +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) void InstallTTOUHandlerForConsole(ConsoleSigTtouHandler handler) { bool installed; @@ -703,11 +726,13 @@ void UninstallTTOUHandlerForConsole(void) } pthread_mutex_unlock(&lock); } +#endif /* TARGET_WASI */ #ifndef HAS_CONSOLE_SIGNALS int32_t SystemNative_InitializeTerminalAndSignalHandling(void) { +#if !defined(TARGET_WASI) static int32_t initialized = 0; // The Process, Console and PosixSignalRegistration classes call this method for initialization. @@ -721,52 +746,9 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) } return initialized; -} - -#endif - #else /* TARGET_WASI */ - -int32_t SystemNative_GetPlatformSignalNumber(PosixSignal signal) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0; -} - -void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_RegisterForSigChld(SigChldCallback callback) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_SetDelayedSigChildConsoleConfigurationHandler(void (*callback)(void)) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_EnablePosixSignalHandling(int signalCode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0; -} - -void SystemNative_DisablePosixSignalHandling(int signalCode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); + return false; +#endif /* TARGET_WASI */ } -#endif /* TARGET_WASI */ +#endif From 0078da94b4b497dde6fda1dd2b8dfc711eb239db Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 16:16:03 +0100 Subject: [PATCH 101/116] pal_io.c --- src/coreclr/pal/src/config.h.in | 3 + src/coreclr/pal/src/configure.cmake | 3 + src/native/libs/Common/pal_config.h.in | 4 + src/native/libs/System.Native/pal_io.c | 482 +++---------------------- src/native/libs/configure.cmake | 5 + 5 files changed, 71 insertions(+), 426 deletions(-) diff --git a/src/coreclr/pal/src/config.h.in b/src/coreclr/pal/src/config.h.in index 75507804d23a0..5a48d405330de 100644 --- a/src/coreclr/pal/src/config.h.in +++ b/src/coreclr/pal/src/config.h.in @@ -63,6 +63,9 @@ #cmakedefine01 HAS_SYSV_SEMAPHORES #cmakedefine01 HAS_PTHREAD_MUTEXES #cmakedefine HAVE_TTRACE +#cmakedefine01 HAVE_CHMOD +#cmakedefine01 HAVE_FCHMOD +#cmakedefine01 HAVE_PIPE #cmakedefine01 HAVE_PIPE2 #cmakedefine01 HAVE_SCHED_GETAFFINITY #cmakedefine01 HAVE_SCHED_SETAFFINITY diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 4f900a5555ef6..399174a876412 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -135,6 +135,9 @@ check_function_exists(semget HAS_SYSV_SEMAPHORES) check_function_exists(pthread_mutex_init HAS_PTHREAD_MUTEXES) check_function_exists(ttrace HAVE_TTRACE) check_function_exists(pipe2 HAVE_PIPE2) +check_function_exists(pipe HAVE_PIPE) +check_function_exists(chmod HAVE_CHMOD) +check_function_exists(fchmod HAVE_FCHMOD) check_cxx_source_compiles(" #include diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in index 7749490c023b0..464ae1d326607 100644 --- a/src/native/libs/Common/pal_config.h.in +++ b/src/native/libs/Common/pal_config.h.in @@ -8,6 +8,7 @@ #cmakedefine01 HAVE_STATFS_MOUNT #cmakedefine01 HAVE_FLOCK64 #cmakedefine01 HAVE_F_DUPFD_CLOEXEC +#cmakedefine01 HAVE_F_DUPFD #cmakedefine01 HAVE_F_FULLFSYNC #cmakedefine01 HAVE_O_CLOEXEC #cmakedefine01 HAVE_GETIFADDRS @@ -15,6 +16,9 @@ #cmakedefine01 HAVE_STAT64 #cmakedefine01 HAVE_FORK #cmakedefine01 HAVE_VFORK +#cmakedefine01 HAVE_CHMOD +#cmakedefine01 HAVE_FCHMOD +#cmakedefine01 HAVE_PIPE #cmakedefine01 HAVE_PIPE2 #cmakedefine01 HAVE_STAT_BIRTHTIME #cmakedefine01 HAVE_STAT_TIMESPEC diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 694e57f9de1a9..5f8402710547e 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -97,7 +97,6 @@ extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__); #endif -#if !defined(TARGET_WASI) #if HAVE_STAT64 #define stat_ stat64 #define fstat_ fstat64 @@ -108,6 +107,7 @@ extern int getpeereid(int, uid_t *__restrict__, gid_t *__restrict__); #define lstat_ lstat #endif /* HAVE_STAT64 */ +#if !defined(TARGET_WASI) // These numeric values are specified by POSIX. // Validate that our definitions match. c_static_assert(PAL_S_IRWXU == S_IRWXU); @@ -193,7 +193,6 @@ c_static_assert(PAL_IN_EXCL_UNLINK == IN_EXCL_UNLINK); c_static_assert(PAL_IN_ISDIR == IN_ISDIR); #endif // HAVE_INOTIFY -#if !defined(TARGET_WASI) static void ConvertFileStatus(const struct stat_* src, FileStatus* dst) { dst->Dev = (int64_t)src->st_dev; @@ -348,10 +347,13 @@ intptr_t SystemNative_Dup(intptr_t oldfd) int result; #if HAVE_F_DUPFD_CLOEXEC while ((result = fcntl(ToFileDescriptor(oldfd), F_DUPFD_CLOEXEC, 0)) < 0 && errno == EINTR); -#else +#elif HAVE_F_DUPFD while ((result = fcntl(ToFileDescriptor(oldfd), F_DUPFD, 0)) < 0 && errno == EINTR); // do CLOEXEC here too fcntl(result, F_SETFD, FD_CLOEXEC); +#else + // https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-dup + result = oldfd; #endif return result; } @@ -577,7 +579,7 @@ int32_t SystemNative_Pipe(int32_t pipeFds[2], int32_t flags) #if HAVE_PIPE2 // If pipe2 is available, use it. This will handle O_CLOEXEC if it was set. while ((result = pipe2(pipeFds, flags)) < 0 && errno == EINTR); -#else +#elif HAVE_PIPE // Otherwise, use pipe. while ((result = pipe(pipeFds)) < 0 && errno == EINTR); @@ -602,7 +604,9 @@ int32_t SystemNative_Pipe(int32_t pipeFds[2], int32_t flags) errno = tmpErrno; } } -#endif +#else /* HAVE_PIPE */ + result = -1; +#endif /* HAVE_PIPE */ return result; } @@ -702,16 +706,24 @@ int32_t SystemNative_MkDir(const char* path, int32_t mode) int32_t SystemNative_ChMod(const char* path, int32_t mode) { +#if HAVE_CHMOD int32_t result; while ((result = chmod(path, (mode_t)mode)) < 0 && errno == EINTR); return result; +#else /* HAVE_CHMOD */ + return EINTR; +#endif /* HAVE_CHMOD */ } int32_t SystemNative_FChMod(intptr_t fd, int32_t mode) { +#if HAVE_FCHMOD int32_t result; while ((result = fchmod(ToFileDescriptor(fd), (mode_t)mode)) < 0 && errno == EINTR); return result; +#else /* HAVE_FCHMOD */ + return EINTR; +#endif /* HAVE_FCHMOD */ } int32_t SystemNative_FSync(intptr_t fd) @@ -755,12 +767,15 @@ int64_t SystemNative_LSeek(intptr_t fd, int64_t offset, int32_t whence) result = #if HAVE_LSEEK64 lseek64( + ToFileDescriptor(fd), + (off_t)offset, + whence)) < 0 && errno == EINTR); #else lseek( -#endif ToFileDescriptor(fd), (off_t)offset, whence)) < 0 && errno == EINTR); +#endif return result; } @@ -780,32 +795,50 @@ int32_t SystemNative_SymLink(const char* target, const char* linkPath) void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber) { +#if !defined(TARGET_WASI) dev_t castedDev = (dev_t)dev; *majorNumber = (uint32_t)major(castedDev); *minorNumber = (uint32_t)minor(castedDev); +#else /* TARGET_WASI */ + dev_t castedDev = (dev_t)dev; + *majorNumber = 0; + *minorNumber = 0; +#endif /* TARGET_WASI */ } int32_t SystemNative_MkNod(const char* pathName, uint32_t mode, uint32_t major, uint32_t minor) { +#if !defined(TARGET_WASI) dev_t dev = (dev_t)makedev(major, minor); int32_t result; while ((result = mknod(pathName, (mode_t)mode, dev)) < 0 && errno == EINTR); return result; +#else /* TARGET_WASI */ + return EINTR; +#endif /* TARGET_WASI */ } int32_t SystemNative_MkFifo(const char* pathName, uint32_t mode) { +#if !defined(TARGET_WASI) int32_t result; while ((result = mkfifo(pathName, (mode_t)mode)) < 0 && errno == EINTR); return result; +#else /* TARGET_WASI */ + return EINTR; +#endif /* TARGET_WASI */ } char* SystemNative_MkdTemp(char* pathTemplate) { +#if !defined(TARGET_WASI) char* result = NULL; while ((result = mkdtemp(pathTemplate)) == NULL && errno == EINTR); return result; +#else /* TARGET_WASI */ + return NULL; +#endif /* TARGET_WASI */ } intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) @@ -848,7 +881,7 @@ intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) pathTemplate[firstSuffixIndex] = firstSuffixChar; } #elif TARGET_WASI - // TODOWASI + result = -1; #else #error "Cannot find mkstemps nor mkstemp on this platform" #endif @@ -1154,7 +1187,9 @@ int32_t SystemNative_RmDir(const char* path) void SystemNative_Sync(void) { +#if !defined(TARGET_WASI) sync(); +#endif /* TARGET_WASI */ } int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize) @@ -1378,6 +1413,7 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t return -1; } +#if HAVE_FCHMOD // Copy permissions. // Even though managed code created the file with permissions matching those of the source file, // we need to copy permissions because the open permissions may be filtered by 'umask'. @@ -1386,6 +1422,7 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t { return -1; } +#endif /* HAVE_FCHMOD */ return 0; #endif // HAVE_FCOPYFILE @@ -1467,9 +1504,14 @@ int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid) char* SystemNative_RealPath(const char* path) { assert(path != NULL); +#if !defined(TARGET_WASI) return realpath(path, NULL); +#else /* TARGET_WASI */ + return NULL; +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static int16_t ConvertLockType(int16_t managedLockType) { // the managed enum Interop.Sys.LockType has no 1:1 mapping with corresponding Unix values @@ -1623,6 +1665,7 @@ static uint32_t MapFileSystemNameToEnum(const char* fileSystemName) return result; } #endif +#endif /* TARGET_WASI */ uint32_t SystemNative_GetFileSystemType(intptr_t fd) { @@ -1643,6 +1686,8 @@ uint32_t SystemNative_GetFileSystemType(intptr_t fd) uint32_t result = (uint32_t)statfsArgs.f_type; return result; #endif +#elif defined(TARGET_WASI) + return EINTR; #elif !HAVE_NON_LEGACY_STATFS int statfsRes; struct statvfs statfsArgs; @@ -1657,6 +1702,7 @@ uint32_t SystemNative_GetFileSystemType(intptr_t fd) int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType) { +#if !defined(TARGET_WASI) int16_t unixLockType = ConvertLockType(lockType); if (offset < 0 || length < 0) { @@ -1686,6 +1732,9 @@ int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int32_t ret; while ((ret = fcntl (ToFileDescriptor(fd), command, &lockArgs)) < 0 && errno == EINTR); return ret; +#else /* TARGET_WASI */ + return EINTR; +#endif /* TARGET_WASI */ } int32_t SystemNative_LChflags(const char* path, uint32_t flags) @@ -1866,422 +1915,3 @@ int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount return count; } -#else /* TARGET_WASI */ - -int32_t SystemNative_Link(const char* source, const char* linkTarget) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Stat(const char* path, FileStatus* output) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FStat(intptr_t fd, FileStatus* output) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_LStat(const char* path, FileStatus* output) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -intptr_t SystemNative_Open(const char* path, int32_t flags, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Close(intptr_t fd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -intptr_t SystemNative_Dup(intptr_t oldfd) -{ - // https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-dup - return oldfd; -} - -int32_t SystemNative_Unlink(const char* path) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -intptr_t SystemNative_ShmOpen(const char* name, int32_t flags, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ShmUnlink(const char* name) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetReadDirRBufferSize(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ReadDirR(DIR* dir, uint8_t* buffer, int32_t bufferSize, DirectoryEntry* outputEntry) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -DIR* SystemNative_OpenDir(const char* path) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -int32_t SystemNative_CloseDir(DIR* dir) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Pipe(int32_t pipeFds[2], int32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlSetFD(intptr_t fd, int32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlGetFD(intptr_t fd) -{ - printf("TODOSystemNative_FcntlGetFDWASI\n"); - return -1; -} - -int32_t SystemNative_FcntlCanGetSetPipeSz(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlGetPipeSz(intptr_t fd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlSetPipeSz(intptr_t fd, int32_t size) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlSetIsNonBlocking(intptr_t fd, int32_t isNonBlocking) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FcntlGetIsNonBlocking(intptr_t fd, int32_t* isNonBlocking) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_MkDir(const char* path, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ChMod(const char* path, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FChMod(intptr_t fd, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FSync(intptr_t fd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FLock(intptr_t fd, int32_t operation) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ChDir(const char* path) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Access(const char* path, int32_t mode) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int64_t SystemNative_LSeek(intptr_t fd, int64_t offset, int32_t whence) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_SymLink(const char* target, const char* linkPath) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_MkNod(const char* pathName, uint32_t mode, uint32_t major, uint32_t minor) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_MkFifo(const char* pathName, uint32_t mode) -{ - return -1; -} - -char* SystemNative_MkdTemp(char* pathTemplate) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -intptr_t SystemNative_MksTemps(char* pathTemplate, int32_t suffixLength) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -void* SystemNative_MMap(void* address, - uint64_t length, - int32_t protection, // bitwise OR of PAL_PROT_* - int32_t flags, // bitwise OR of PAL_MAP_*, but PRIVATE and SHARED are mutually exclusive. - intptr_t fd, - int64_t offset) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -int32_t SystemNative_MUnmap(void* address, uint64_t length) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_MSync(void* address, uint64_t length, int32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int64_t SystemNative_SysConf(int32_t name) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FTruncate(intptr_t fd, int64_t length) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t milliseconds, uint32_t* triggered) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_PosixFAdvise(intptr_t fd, int64_t offset, int64_t length, int32_t advice) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FAllocate(intptr_t fd, int64_t offset, int64_t length) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Read(intptr_t fd, void* buffer, int32_t bufferSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ReadLink(const char* path, char* buffer, int32_t bufferSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Rename(const char* oldPath, const char* newPath) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_RmDir(const char* path) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -void SystemNative_Sync(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_Write(intptr_t fd, const void* buffer, int32_t bufferSize) -{ - // the same - return Common_Write(fd, buffer, bufferSize); -} - -int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t sourceLength) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -intptr_t SystemNative_INotifyInit(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_INotifyAddWatch(intptr_t fd, const char* pathName, uint32_t mask) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_INotifyRemoveWatch(intptr_t fd, int32_t wd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -char* SystemNative_RealPath(const char* path) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -uint32_t SystemNative_GetFileSystemType(intptr_t fd) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0xFFFFFFFF; -} - -int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_LChflags(const char* path, uint32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_FChflags(intptr_t fd, uint32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_LChflagsCanSetHiddenFlag(void) -{ -#if HAVE_LCHFLAGS - return SystemNative_CanGetHiddenFlag(); -#else - return false; -#endif -} - -int32_t SystemNative_CanGetHiddenFlag(void) -{ -#if HAVE_STAT_FLAGS && defined(UF_HIDDEN) - return true; -#else - return false; -#endif -} - -int32_t SystemNative_ReadProcessStatusInfo(pid_t pid, ProcessStatus* processStatus) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_PRead(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_PWrite(intptr_t fd, void* buffer, int32_t bufferSize, int64_t fileOffset) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int64_t SystemNative_PReadV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int64_t SystemNative_PWriteV(intptr_t fd, IOVector* vectors, int32_t vectorCount, int64_t fileOffset) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -#endif /* TARGET_WASI */ diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index b624b0ee209be..a5a939295c9e3 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -131,6 +131,11 @@ check_symbol_exists( fcntl.h HAVE_F_DUPFD_CLOEXEC) +check_symbol_exists( + F_DUPFD + fcntl.h + HAVE_F_DUPFD) + check_symbol_exists( F_FULLFSYNC fcntl.h From bdd5399c615d1706581809ad559dc34f6a0f0609 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 16:20:06 +0100 Subject: [PATCH 102/116] pal_dynamicload.c --- .../libs/System.Native/pal_dynamicload.c | 45 ++++++------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/native/libs/System.Native/pal_dynamicload.c b/src/native/libs/System.Native/pal_dynamicload.c index 646ec3544f0ba..c59f486c8ba68 100644 --- a/src/native/libs/System.Native/pal_dynamicload.c +++ b/src/native/libs/System.Native/pal_dynamicload.c @@ -14,9 +14,9 @@ #include #endif -#if !defined(TARGET_WASI) void* SystemNative_LoadLibrary(const char* filename) { +#if !defined(TARGET_WASI) // Check whether we have been requested to load 'libc'. If that's the case, then: // * For Linux, use the full name of the library that is defined in by the // LIBC_SO constant. The problem is that calling dlopen("libc.so") will fail for libc even @@ -40,59 +40,42 @@ void* SystemNative_LoadLibrary(const char* filename) } return dlopen(filename, RTLD_LAZY); +#else /* TARGET_WASI */ + return NULL; +#endif /* TARGET_WASI */ } void* SystemNative_GetLoadLibraryError(void) { +#if !defined(TARGET_WASI) return dlerror(); +#else /* TARGET_WASI */ + return NULL; +#endif /* TARGET_WASI */ } void* SystemNative_GetProcAddress(void* handle, const char* symbol) { +#if !defined(TARGET_WASI) // We're not trying to disambiguate between "symbol was not found" and "symbol found, but // the value is null". .NET does not define a behavior for DllImports of null entrypoints, // so we might as well take the "not found" path on the managed side. return dlsym(handle, symbol); -} - -void SystemNative_FreeLibrary(void* handle) -{ - dlclose(handle); -} #else /* TARGET_WASI */ -void* SystemNative_LoadLibrary(const char* filename) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -void* SystemNative_GetLoadLibraryError(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -void* SystemNative_GetProcAddress(void* handle, const char* symbol) -{ - printf ("TODOWASI %s\n", __FUNCTION__); return NULL; +#endif /* TARGET_WASI */ } void SystemNative_FreeLibrary(void* handle) { - printf ("TODOWASI %s\n", __FUNCTION__); -} +#if !defined(TARGET_WASI) + dlclose(handle); #endif /* TARGET_WASI */ - -#if defined TARGET_ANDROID -void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) -{ - return NULL; } -#elif defined TARGET_WASI + +#if defined TARGET_ANDROID || TARGET_WASI void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) { - printf ("TODOWASI %s\n", __FUNCTION__); return NULL; } #else From 8ba9b1e176c0ef0bc68eedaecd47512f75db3fa7 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 16:35:50 +0100 Subject: [PATCH 103/116] pal_console.c --- src/native/libs/System.Native/pal_console.c | 109 +++++--------------- 1 file changed, 27 insertions(+), 82 deletions(-) diff --git a/src/native/libs/System.Native/pal_console.c b/src/native/libs/System.Native/pal_console.c index 613a2dd8b4501..e7ce2a7e13a7c 100644 --- a/src/native/libs/System.Native/pal_console.c +++ b/src/native/libs/System.Native/pal_console.c @@ -23,7 +23,6 @@ #endif #include -#if !defined(TARGET_WASI) int32_t SystemNative_GetWindowSize(WinSize* windowSize) { assert(windowSize != NULL); @@ -92,6 +91,7 @@ void SystemNative_SetKeypadXmit(const char* terminfoString) WriteKeypadXmit(); } +#if !defined(TARGET_WASI) static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; // prevents races when initializing and changing the terminal. static bool g_signalForBreak = true; // tracks whether the terminal should send signals for breaks, such that attributes have been changed @@ -230,9 +230,11 @@ void UninitializeTerminal(void) pthread_mutex_unlock(&g_lock); } } +#endif /* TARGET_WASI */ void SystemNative_InitializeConsoleBeforeRead(uint8_t minChars, uint8_t decisecondsTimeout) { +#if !defined(TARGET_WASI) if (pthread_mutex_lock(&g_lock) == 0) { g_reading = true; @@ -241,20 +243,24 @@ void SystemNative_InitializeConsoleBeforeRead(uint8_t minChars, uint8_t deciseco pthread_mutex_unlock(&g_lock); } +#endif /* TARGET_WASI */ } void SystemNative_UninitializeConsoleAfterRead(void) { +#if !defined(TARGET_WASI) if (pthread_mutex_lock(&g_lock) == 0) { g_reading = false; pthread_mutex_unlock(&g_lock); } +#endif /* TARGET_WASI */ } void SystemNative_ConfigureTerminalForChildProcess(int32_t childUsesTerminal) { +#if !defined(TARGET_WASI) assert(childUsesTerminal == 0 || childUsesTerminal == 1); if (pthread_mutex_lock(&g_lock) == 0) @@ -286,8 +292,10 @@ void SystemNative_ConfigureTerminalForChildProcess(int32_t childUsesTerminal) pthread_mutex_unlock(&g_lock); } +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static int TranslatePalControlCharacterName(int name) { switch (name) @@ -346,6 +354,7 @@ static int TranslatePalControlCharacterName(int name) default: return -1; } } +#endif /* TARGET_WASI */ void SystemNative_GetControlCharacters( int32_t* controlCharacterNames, uint8_t* controlCharacterValues, int32_t controlCharacterLength, @@ -364,6 +373,7 @@ void SystemNative_GetControlCharacters( memset(controlCharacterValues, *posixDisableValue, sizeof(uint8_t) * Int32ToSizeT(controlCharacterLength)); +#if HAVE_TERMIOS_H if (controlCharacterLength > 0) { struct termios newTermios; @@ -381,6 +391,7 @@ void SystemNative_GetControlCharacters( } } } +#endif } int32_t SystemNative_StdinReady(void) @@ -410,13 +421,18 @@ int32_t SystemNative_ReadStdin(void* buffer, int32_t bufferSize) int32_t SystemNative_GetSignalForBreak(void) { +#if !defined(TARGET_WASI) return g_signalForBreak; +#else /* TARGET_WASI */ + return false; +#endif /* TARGET_WASI */ } int32_t SystemNative_SetSignalForBreak(int32_t signalForBreak) { assert(signalForBreak == 0 || signalForBreak == 1); +#if !defined(TARGET_WASI) int rv = 0; if (pthread_mutex_lock(&g_lock) == 0) @@ -431,6 +447,9 @@ int32_t SystemNative_SetSignalForBreak(int32_t signalForBreak) } return rv; +#else /* TARGET_WASI */ + return 0; +#endif /* TARGET_WASI */ } void ReinitializeTerminal(void) @@ -438,6 +457,7 @@ void ReinitializeTerminal(void) // Restores the state of the terminal after being suspended. // pal_signal.cpp calls this on SIGCONT from the signal handling thread. +#if !defined(TARGET_WASI) if (pthread_mutex_lock(&g_lock) == 0) { if (!g_childUsesTerminal) @@ -452,8 +472,10 @@ void ReinitializeTerminal(void) pthread_mutex_unlock(&g_lock); } +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static void InitializeTerminalCore(void) { bool haveInitTermios = tcgetattr(STDIN_FILENO, &g_initTermios) >= 0; @@ -472,9 +494,11 @@ static void InitializeTerminalCore(void) g_signalForBreak = true; } } +#endif /* TARGET_WASI */ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) { +#if !defined(TARGET_WASI) static int32_t initialized = 0; // The Process, Console and PosixSignalRegistration classes call this method for initialization. @@ -489,86 +513,7 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) } return initialized; -} - #else /* TARGET_WASI */ - -int32_t SystemNative_GetWindowSize(WinSize* windowSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - memset(windowSize, 0, sizeof(WinSize)); // managed out param must be initialized - errno = ENOTSUP; - return -1; -} - -int32_t SystemNative_SetWindowSize(WinSize* windowSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - errno = ENOTSUP; - return -1; -} - -int32_t SystemNative_IsATty(intptr_t fd) -{ - // the same - return isatty(ToFileDescriptor(fd)); -} - -void SystemNative_SetKeypadXmit(const char* terminfoString) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_InitializeConsoleBeforeRead(uint8_t minChars, uint8_t decisecondsTimeout) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_UninitializeConsoleAfterRead(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_ConfigureTerminalForChildProcess(int32_t childUsesTerminal) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -void SystemNative_GetControlCharacters( - int32_t* controlCharacterNames, uint8_t* controlCharacterValues, int32_t controlCharacterLength, - uint8_t* posixDisableValue) -{ - printf ("TODOWASI %s\n", __FUNCTION__); -} - -int32_t SystemNative_StdinReady(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_ReadStdin(void* buffer, int32_t bufferSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_GetSignalForBreak(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_SetSignalForBreak(int32_t signalForBreak) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_InitializeTerminalAndSignalHandling(void) -{ - // No termios and signals on WASI - return 1; -} - + return true; #endif /* TARGET_WASI */ +} From 26418e3143bbf8f2cb33255186f7ee3be35ff979 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 18 Nov 2022 19:13:15 +0100 Subject: [PATCH 104/116] pal_networking.c --- src/native/libs/CMakeLists.txt | 1 + .../libs/System.Native/pal_networking.c | 610 +++++++----------- 2 files changed, 229 insertions(+), 382 deletions(-) diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 619419298cea3..00b0844136061 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -58,6 +58,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) add_compile_options(-I${CLR_REPO_ROOT_DIR}/src/mono/wasi/libs-include/) add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-parameter) + add_compile_options(-Wno-gnu-statement-expression) add_compile_options(-D_WASI_EMULATED_PROCESS_CLOCKS) add_compile_options(-D_WASI_EMULATED_SIGNAL) add_compile_options(-D_WASI_EMULATED_MMAN) diff --git a/src/native/libs/System.Native/pal_networking.c b/src/native/libs/System.Native/pal_networking.c index 1e4b2d2801441..79b6dd9ca96f3 100644 --- a/src/native/libs/System.Native/pal_networking.c +++ b/src/native/libs/System.Native/pal_networking.c @@ -118,9 +118,7 @@ static uint16_t GetKeventFlags(uint32_t flags) #endif #endif -#if !defined(TARGET_WASI) - -#if !HAVE_IN_PKTINFO +#if !HAVE_IN_PKTINFO && !IP_PKTINFO // On platforms, such as FreeBSD, where in_pktinfo // is not available, fallback to custom definition // with required members. @@ -139,6 +137,7 @@ struct in_pktinfo #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP #endif +#if !defined(TARGET_WASI) enum { #if defined(__APPLE__) && __APPLE__ @@ -147,18 +146,21 @@ enum LINGER_OPTION_NAME = SO_LINGER, #endif }; +#endif /* TARGET_WASI */ enum { INET6_ADDRSTRLEN_MANAGED = 65 // Managed code has a longer max IPv6 string length }; +#if !defined(TARGET_WASI) c_static_assert(GetHostErrorCodes_HOST_NOT_FOUND == HOST_NOT_FOUND); c_static_assert(GetHostErrorCodes_TRY_AGAIN == TRY_AGAIN); c_static_assert(GetHostErrorCodes_NO_RECOVERY == NO_RECOVERY); c_static_assert(GetHostErrorCodes_NO_DATA == NO_DATA); c_static_assert(GetHostErrorCodes_NO_ADDRESS == NO_ADDRESS); c_static_assert(sizeof(uint8_t) == sizeof(char)); // We make casts from uint8_t to char so make sure it's legal +#endif /* TARGET_WASI */ // sizeof_member(struct foo, bar) is not valid C++. // The fix is to remove struct. That is not valid C. @@ -270,6 +272,7 @@ static void ConvertByteArrayToSockAddrIn6(struct sockaddr_in6* addr, const uint8 // Mark that this is INET6 addr->sin6_family = AF_INET6; } +#if !defined(TARGET_WASI) static void ConvertByteArrayToInAddr(struct in_addr* addr, const uint8_t* buffer, int32_t bufferLength) { @@ -351,6 +354,7 @@ static int32_t CopySockAddrToIPAddress(sockaddr* addr, sa_family_t family, IPAdd return -1; } +#endif /* TARGET_WASI */ int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t addressFamily, HostEntry* entry) { @@ -358,6 +362,7 @@ int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t address { return GetAddrInfoErrorFlags_EAI_BADARG; } +#if !defined(TARGET_WASI) int32_t ret = GetAddrInfoErrorFlags_EAI_SUCCESS; @@ -534,6 +539,9 @@ int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t address } return ret; +#else /* TARGET_WASI */ + return -1; +#endif /* TARGET_WASI */ } void SystemNative_FreeHostEntry(HostEntry* entry) @@ -556,6 +564,7 @@ typedef int32_t NativeFlagsType; typedef uint32_t NativeFlagsType; #endif +#if !defined(TARGET_WASI) static inline NativeFlagsType ConvertGetNameInfoFlagsToNative(int32_t flags) { NativeFlagsType outFlags = 0; @@ -570,6 +579,7 @@ static inline NativeFlagsType ConvertGetNameInfoFlagsToNative(int32_t flags) return outFlags; } +#endif int32_t SystemNative_GetNameInfo(const uint8_t* address, int32_t addressLength, @@ -585,6 +595,7 @@ int32_t SystemNative_GetNameInfo(const uint8_t* address, assert((host != NULL) || (service != NULL)); assert((hostLength > 0) || (serviceLength > 0)); +#if !defined(TARGET_WASI) NativeFlagsType nativeFlags = ConvertGetNameInfoFlagsToNative(flags); int32_t result; @@ -616,6 +627,9 @@ int32_t SystemNative_GetNameInfo(const uint8_t* address, } return ConvertGetAddrInfoAndGetNameInfoErrorsToPal(result); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetDomainName(uint8_t* name, int32_t nameLength) @@ -915,6 +929,7 @@ SystemNative_SetIPv6Address(uint8_t* socketAddress, int32_t socketAddressLen, ui return Error_SUCCESS; } +#if !defined(TARGET_WASI) static int8_t IsStreamSocket(int socket) { int type; @@ -941,15 +956,21 @@ static void ConvertMessageHeaderToMsghdr(struct msghdr* header, const MessageHea header->msg_controllen = (uint32_t)messageHeader->ControlBufferLen; header->msg_flags = 0; } +#endif /* TARGET_WASI */ int32_t SystemNative_GetControlMessageBufferSize(int32_t isIPv4, int32_t isIPv6) { +#if defined(CMSG_SPACE) // Note: it is possible that the address family of the socket is neither // AF_INET nor AF_INET6. In this case both inputs will be 0 and // the control message buffer size should be zero. return (isIPv4 != 0 ? CMSG_SPACE(sizeof(struct in_pktinfo)) : 0) + (isIPv6 != 0 ? CMSG_SPACE(sizeof(struct in6_pktinfo)) : 0); +#else /* CMSG_SPACE */ + return Error_EINVAL; +#endif /* CMSG_SPACE */ } +#if !defined(TARGET_WASI) static int32_t GetIPv4PacketInformation(struct cmsghdr* controlMessage, IPPacketInformation* packetInfo) { assert(controlMessage != NULL); @@ -1028,6 +1049,7 @@ static struct cmsghdr* GET_CMSG_NXTHDR(struct msghdr* mhdr, struct cmsghdr* cmsg #pragma clang diagnostic pop #endif } +#endif /* TARGET_WASI */ int32_t SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isIPv4, IPPacketInformation* packetInfo) @@ -1037,6 +1059,7 @@ SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isI return 0; } +#if !defined(TARGET_WASI) struct msghdr header; ConvertMessageHeaderToMsghdr(&header, messageHeader, -1); @@ -1065,6 +1088,9 @@ SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isI } return 0; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } static int8_t GetMulticastOptionName(int32_t multicastOption, int8_t isIPv6, int* optionName) @@ -1134,6 +1160,7 @@ int32_t SystemNative_SetIPv4MulticastOption(intptr_t socket, int32_t multicastOp return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int optionName; @@ -1160,6 +1187,9 @@ int32_t SystemNative_SetIPv4MulticastOption(intptr_t socket, int32_t multicastOp #endif int err = setsockopt(fd, IPPROTO_IP, optionName, &opt, sizeof(opt)); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) @@ -1196,6 +1226,7 @@ int32_t SystemNative_SetIPv6MulticastOption(intptr_t socket, int32_t multicastOp { return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); @@ -1219,8 +1250,12 @@ int32_t SystemNative_SetIPv6MulticastOption(intptr_t socket, int32_t multicastOp int err = setsockopt(fd, IPPROTO_IPV6, optionName, &opt, sizeof(opt)); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) #if defined(__APPLE__) && __APPLE__ static int32_t GetMaxLingerTime(void) { @@ -1257,6 +1292,7 @@ static int32_t GetMaxLingerTime(void) return Min(65535U, (1U << (sizeof_member(linger, l_linger) * 8 - 1)) - 1); } #endif +#endif /* TARGET_WASI */ int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) { @@ -1265,6 +1301,7 @@ int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); struct linger opt; @@ -1279,6 +1316,10 @@ int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) option->OnOff = opt.l_onoff; option->Seconds = opt.l_linger; return Error_SUCCESS; +#else /* TARGET_WASI */ + memset(option, 0, sizeof(LingerOption)); + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) @@ -1288,6 +1329,7 @@ int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) return Error_EFAULT; } +#if !defined(TARGET_WASI) if (option->OnOff != 0 && (option->Seconds < 0 || option->Seconds > GetMaxLingerTime())) { return Error_EINVAL; @@ -1312,8 +1354,12 @@ int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) #endif return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static int32_t SetTimeoutOption(int32_t socket, int32_t millisecondsTimeout, int optionName) { if (millisecondsTimeout < 0) @@ -1328,15 +1374,24 @@ static int32_t SetTimeoutOption(int32_t socket, int32_t millisecondsTimeout, int int err = setsockopt(socket, SOL_SOCKET, optionName, &timeout, sizeof(timeout)); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); } +#endif /* TARGET_WASI */ int32_t SystemNative_SetReceiveTimeout(intptr_t socket, int32_t millisecondsTimeout) { +#if !defined(TARGET_WASI) return SetTimeoutOption(ToFileDescriptor(socket), millisecondsTimeout, SO_RCVTIMEO); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_SetSendTimeout(intptr_t socket, int32_t millisecondsTimeout) { +#if !defined(TARGET_WASI) return SetTimeoutOption(ToFileDescriptor(socket), millisecondsTimeout, SO_SNDTIMEO); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } static int8_t ConvertSocketFlagsPalToPlatform(int32_t palFlags, int* platformFlags) @@ -1348,26 +1403,44 @@ static int8_t ConvertSocketFlagsPalToPlatform(int32_t palFlags, int* platformFla return false; } - *platformFlags = ((palFlags & SocketFlags_MSG_OOB) == 0 ? 0 : MSG_OOB) | + *platformFlags = +#ifdef MSG_OOB + ((palFlags & SocketFlags_MSG_OOB) == 0 ? 0 : MSG_OOB) | +#endif /* MSG_OOB */ ((palFlags & SocketFlags_MSG_PEEK) == 0 ? 0 : MSG_PEEK) | +#ifdef MSG_DONTROUTE ((palFlags & SocketFlags_MSG_DONTROUTE) == 0 ? 0 : MSG_DONTROUTE) | +#endif /* MSG_DONTROUTE */ +#if defined(MSG_TRUNC) && !defined(TARGET_WASI) // https://github.com/WebAssembly/wasi-libc/issues/305 ((palFlags & SocketFlags_MSG_TRUNC) == 0 ? 0 : MSG_TRUNC) | - ((palFlags & SocketFlags_MSG_CTRUNC) == 0 ? 0 : MSG_CTRUNC); +#endif /* MSG_TRUNC */ +#ifdef MSG_CTRUNC + ((palFlags & SocketFlags_MSG_CTRUNC) == 0 ? 0 : MSG_CTRUNC) | +#endif /* MSG_CTRUNC */ + (0); return true; } +#if !defined(TARGET_WASI) static int32_t ConvertSocketFlagsPlatformToPal(int platformFlags) { - const int SupportedFlagsMask = MSG_OOB | MSG_DONTROUTE | MSG_TRUNC | MSG_CTRUNC; - - platformFlags &= SupportedFlagsMask; - - return ((platformFlags & MSG_OOB) == 0 ? 0 : SocketFlags_MSG_OOB) | + return +#ifdef MSG_OOB + ((platformFlags & MSG_OOB) == 0 ? 0 : SocketFlags_MSG_OOB) | +#endif /* MSG_OOB */ +#ifdef MSG_DONTROUTE ((platformFlags & MSG_DONTROUTE) == 0 ? 0 : SocketFlags_MSG_DONTROUTE) | +#endif /* MSG_DONTROUTE */ +#if defined(MSG_TRUNC) && !defined(TARGET_WASI) // https://github.com/WebAssembly/wasi-libc/issues/305 ((platformFlags & MSG_TRUNC) == 0 ? 0 : SocketFlags_MSG_TRUNC) | - ((platformFlags & MSG_CTRUNC) == 0 ? 0 : SocketFlags_MSG_CTRUNC); +#endif /* MSG_TRUNC */ +#ifdef MSG_CTRUNC + ((platformFlags & MSG_CTRUNC) == 0 ? 0 : SocketFlags_MSG_CTRUNC) | +#endif /* MSG_CTRUNC */ + (0); } +#endif /* TARGET_WASI */ int32_t SystemNative_Receive(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* received) { @@ -1405,6 +1478,7 @@ int32_t SystemNative_ReceiveMessage(intptr_t socket, MessageHeader* messageHeade return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int socketFlags; @@ -1438,6 +1512,9 @@ int32_t SystemNative_ReceiveMessage(intptr_t socket, MessageHeader* messageHeade *received = 0; return SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* sent) @@ -1447,6 +1524,7 @@ int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int3 return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int socketFlags; @@ -1473,6 +1551,9 @@ int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int3 *sent = 0; return SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* sent) @@ -1483,6 +1564,7 @@ int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int socketFlags; @@ -1512,6 +1594,9 @@ int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, *sent = 0; return SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_Accept(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen, intptr_t* acceptedSocket) @@ -1572,6 +1657,7 @@ int32_t SystemNative_Bind(intptr_t socket, int32_t protocolType, uint8_t* socket return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); // On Windows, Bind during TCP_WAIT is allowed. @@ -1588,6 +1674,9 @@ int32_t SystemNative_Bind(intptr_t socket, int32_t protocolType, uint8_t* socket (socklen_t)socketAddressLen); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_Connect(intptr_t socket, uint8_t* socketAddress, int32_t socketAddressLen) @@ -1597,11 +1686,15 @@ int32_t SystemNative_Connect(intptr_t socket, uint8_t* socketAddress, int32_t so return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int err; while ((err = connect(fd, (struct sockaddr*)socketAddress, (socklen_t)socketAddressLen)) < 0 && errno == EINTR); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) @@ -1611,6 +1704,7 @@ int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_ return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); socklen_t addrLen = (socklen_t)*socketAddressLen; @@ -1622,6 +1716,9 @@ int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_ *socketAddressLen = (int32_t)addrLen; return Error_SUCCESS; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) @@ -1631,6 +1728,7 @@ int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_ return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); socklen_t addrLen = (socklen_t)*socketAddressLen; @@ -1643,13 +1741,20 @@ int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_ assert(addrLen <= (socklen_t)*socketAddressLen); *socketAddressLen = (int32_t)addrLen; return Error_SUCCESS; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_Listen(intptr_t socket, int32_t backlog) { +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int err = listen(fd, backlog); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_Shutdown(intptr_t socket, int32_t socketShutdown) @@ -1664,6 +1769,7 @@ int32_t SystemNative_GetSocketErrorOption(intptr_t socket, int32_t* error) return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int socketErrno; @@ -1677,6 +1783,9 @@ int32_t SystemNative_GetSocketErrorOption(intptr_t socket, int32_t* error) assert(optLen == sizeof(socketErrno)); *error = SystemNative_ConvertErrorPlatformToPal(socketErrno); return Error_SUCCESS; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } static bool TryGetPlatformSocketOption(int32_t socketOptionLevel, int32_t socketOptionName, int* optLevel, int* optName) @@ -1688,75 +1797,107 @@ static bool TryGetPlatformSocketOption(int32_t socketOptionLevel, int32_t socket switch (socketOptionName) { +#ifdef SO_DEBUG case SocketOptionName_SO_DEBUG: *optName = SO_DEBUG; return true; +#endif +#ifdef SO_ACCEPTCONN case SocketOptionName_SO_ACCEPTCONN: *optName = SO_ACCEPTCONN; return true; +#endif +#ifdef SO_REUSEADDR case SocketOptionName_SO_REUSEADDR: *optName = SO_REUSEADDR; return true; +#endif +#ifdef SO_KEEPALIVE case SocketOptionName_SO_KEEPALIVE: *optName = SO_KEEPALIVE; return true; +#endif +#ifdef SO_DONTROUTE case SocketOptionName_SO_DONTROUTE: *optName = SO_DONTROUTE; return true; +#endif +#ifdef SO_BROADCAST case SocketOptionName_SO_BROADCAST: *optName = SO_BROADCAST; return true; +#endif // case SocketOptionName_SO_USELOOPBACK: +#ifdef SO_LINGER case SocketOptionName_SO_LINGER: *optName = SO_LINGER; return true; +#endif +#ifdef SO_OOBINLINE case SocketOptionName_SO_OOBINLINE: *optName = SO_OOBINLINE; return true; +#endif // case SocketOptionName_SO_DONTLINGER: // case SocketOptionName_SO_EXCLUSIVEADDRUSE: +#ifdef SO_SNDBUF case SocketOptionName_SO_SNDBUF: *optName = SO_SNDBUF; return true; +#endif +#ifdef SO_RCVBUF case SocketOptionName_SO_RCVBUF: *optName = SO_RCVBUF; return true; +#endif +#ifdef SO_SNDLOWAT case SocketOptionName_SO_SNDLOWAT: *optName = SO_SNDLOWAT; return true; +#endif +#ifdef SO_RCVLOWAT case SocketOptionName_SO_RCVLOWAT: *optName = SO_RCVLOWAT; return true; +#endif +#ifdef SO_SNDTIMEO case SocketOptionName_SO_SNDTIMEO: *optName = SO_SNDTIMEO; return true; +#endif +#ifdef SO_RCVTIMEO case SocketOptionName_SO_RCVTIMEO: *optName = SO_RCVTIMEO; return true; +#endif +#ifdef SO_ERROR case SocketOptionName_SO_ERROR: *optName = SO_ERROR; return true; +#endif +#ifdef SO_TYPE case SocketOptionName_SO_TYPE: *optName = SO_TYPE; return true; +#endif // case SocketOptionName_SO_MAXCONN: @@ -1948,10 +2089,11 @@ static bool TryConvertSocketTypePlatformToPal(int platformSocketType, int32_t* p case SOCK_DGRAM: *palSocketType = SocketType_SOCK_DGRAM; return true; - +#ifdef SOCK_RAW case SOCK_RAW: *palSocketType = SocketType_SOCK_RAW; return true; +#endif #ifdef SOCK_RDM case SOCK_RDM: @@ -1959,9 +2101,11 @@ static bool TryConvertSocketTypePlatformToPal(int platformSocketType, int32_t* p return true; #endif +#ifdef SOCK_SEQPACKET case SOCK_SEQPACKET: *palSocketType = SocketType_SOCK_SEQPACKET; return true; +#endif default: *palSocketType = (int32_t)platformSocketType; @@ -2117,6 +2261,7 @@ SystemNative_SetSockOpt(intptr_t socket, int32_t socketOptionLevel, int32_t sock return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); // @@ -2193,6 +2338,9 @@ SystemNative_SetSockOpt(intptr_t socket, int32_t socketOptionLevel, int32_t sock int err = setsockopt(fd, optLevel, optName, optionValue, (socklen_t)optionLen); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_SetRawSockOpt( @@ -2203,10 +2351,15 @@ int32_t SystemNative_SetRawSockOpt( return Error_EFAULT; } +#if !defined(TARGET_WASI) int err = setsockopt(ToFileDescriptor(socket), socketOptionLevel, socketOptionName, optionValue, (socklen_t)optionLen); return err == 0 ? Error_SUCCESS : SystemNative_ConvertErrorPlatformToPal(errno); +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } +#if !defined(TARGET_WASI) static bool TryConvertSocketTypePalToPlatform(int32_t palSocketType, int* platformSocketType) { assert(platformSocketType != NULL); @@ -2221,9 +2374,11 @@ static bool TryConvertSocketTypePalToPlatform(int32_t palSocketType, int* platfo *platformSocketType = SOCK_DGRAM; return true; +#ifdef SOCK_RAW case SocketType_SOCK_RAW: *platformSocketType = SOCK_RAW; return true; +#endif #ifdef SOCK_RDM case SocketType_SOCK_RDM: @@ -2231,9 +2386,11 @@ static bool TryConvertSocketTypePalToPlatform(int32_t palSocketType, int* platfo return true; #endif +#ifdef SOCK_SEQPACKET case SocketType_SOCK_SEQPACKET: *platformSocketType = SOCK_SEQPACKET; return true; +#endif default: *platformSocketType = (int)palSocketType; @@ -2288,10 +2445,11 @@ static bool TryConvertProtocolTypePalToPlatform(int32_t palAddressFamily, int32_ case ProtocolType_PT_UDP: *platformProtocolType = IPPROTO_UDP; return true; - +#ifdef IPPROTO_IGMP case ProtocolType_PT_IGMP: *platformProtocolType = IPPROTO_IGMP; return true; +#endif case ProtocolType_PT_RAW: *platformProtocolType = IPPROTO_RAW; @@ -2309,10 +2467,12 @@ static bool TryConvertProtocolTypePalToPlatform(int32_t palAddressFamily, int32_ *platformProtocolType = 0; return true; +#ifdef IPPROTO_ICMPV6 case ProtocolType_PT_ICMPV6: case ProtocolType_PT_ICMP: *platformProtocolType = IPPROTO_ICMPV6; return true; +#endif case ProtocolType_PT_TCP: *platformProtocolType = IPPROTO_TCP; @@ -2322,29 +2482,39 @@ static bool TryConvertProtocolTypePalToPlatform(int32_t palAddressFamily, int32_ *platformProtocolType = IPPROTO_UDP; return true; +#ifdef IPPROTO_IGMP case ProtocolType_PT_IGMP: *platformProtocolType = IPPROTO_IGMP; return true; +#endif case ProtocolType_PT_RAW: *platformProtocolType = IPPROTO_RAW; return true; +#ifdef IPPROTO_DSTOPTS case ProtocolType_PT_DSTOPTS: *platformProtocolType = IPPROTO_DSTOPTS; return true; +#endif +#ifdef IPPROTO_NONE case ProtocolType_PT_NONE: *platformProtocolType = IPPROTO_NONE; return true; +#endif +#ifdef IPPROTO_ROUTING case ProtocolType_PT_ROUTING: *platformProtocolType = IPPROTO_ROUTING; return true; +#endif +#ifdef IPPROTO_FRAGMENT case ProtocolType_PT_FRAGMENT: *platformProtocolType = IPPROTO_FRAGMENT; return true; +#endif default: *platformProtocolType = (int)palProtocolType; @@ -2412,9 +2582,11 @@ static bool TryConvertProtocolTypePlatformToPal(int32_t palAddressFamily, int pl *palProtocolType = ProtocolType_PT_UDP; return true; +#ifdef IPPROTO_IGMP case IPPROTO_IGMP: *palProtocolType = ProtocolType_PT_IGMP; return true; +#endif case IPPROTO_RAW: *palProtocolType = ProtocolType_PT_RAW; @@ -2432,9 +2604,11 @@ static bool TryConvertProtocolTypePlatformToPal(int32_t palAddressFamily, int pl *palProtocolType = ProtocolType_PT_UNSPECIFIED; return true; +#ifdef IPPROTO_ICMPV6 case IPPROTO_ICMPV6: *palProtocolType = ProtocolType_PT_ICMPV6; return true; +#endif case IPPROTO_TCP: *palProtocolType = ProtocolType_PT_TCP; @@ -2444,29 +2618,39 @@ static bool TryConvertProtocolTypePlatformToPal(int32_t palAddressFamily, int pl *palProtocolType = ProtocolType_PT_UDP; return true; +#ifdef IPPROTO_IGMP case IPPROTO_IGMP: *palProtocolType = ProtocolType_PT_IGMP; return true; +#endif case IPPROTO_RAW: *palProtocolType = ProtocolType_PT_RAW; return true; +#ifdef IPPROTO_DSTOPTS case IPPROTO_DSTOPTS: *palProtocolType = ProtocolType_PT_DSTOPTS; return true; +#endif +#ifdef IPPROTO_NONE case IPPROTO_NONE: *palProtocolType = ProtocolType_PT_NONE; return true; +#endif +#ifdef IPPROTO_ROUTING case IPPROTO_ROUTING: *palProtocolType = ProtocolType_PT_ROUTING; return true; +#endif +#ifdef IPPROTO_FRAGMENT case IPPROTO_FRAGMENT: *palProtocolType = ProtocolType_PT_FRAGMENT; return true; +#endif default: *palProtocolType = (int)platformProtocolType; @@ -2485,6 +2669,7 @@ static bool TryConvertProtocolTypePlatformToPal(int32_t palAddressFamily, int pl } } } +#endif /* TARGET_WASI */ int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t protocolType, intptr_t* createdSocket) { @@ -2493,6 +2678,7 @@ int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t p return Error_EFAULT; } +#if !defined(TARGET_WASI) sa_family_t platformAddressFamily; int platformSocketType, platformProtocolType; @@ -2527,6 +2713,9 @@ int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t p fcntl(ToFileDescriptor(*createdSocket), F_SETFD, FD_CLOEXEC); // ignore any failures; this is best effort #endif return Error_SUCCESS; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int32_t* socketType, int32_t* protocolType, int32_t* isListening) @@ -2594,6 +2783,7 @@ int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int3 int listeningValue; socklen_t listeningLength = sizeof(int); +#ifdef SO_ACCEPTCONN if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &listeningValue, &listeningLength) == 0) { *isListening = (listeningValue != 0); @@ -2602,6 +2792,9 @@ int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int3 { *isListening = 0; } +#else + *isListening = 0; +#endif #endif return Error_SUCCESS; } @@ -2613,6 +2806,7 @@ int32_t SystemNative_GetAtOutOfBandMark(intptr_t socket, int32_t* atMark) return Error_EFAULT; } +#if !defined(TARGET_WASI) int fd = ToFileDescriptor(socket); int result; @@ -2626,6 +2820,9 @@ int32_t SystemNative_GetAtOutOfBandMark(intptr_t socket, int32_t* atMark) *atMark = (int32_t)result; return Error_SUCCESS; +#else /* TARGET_WASI */ + return Error_EINVAL; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetBytesAvailable(intptr_t socket, int32_t* available) @@ -2945,10 +3142,13 @@ static int32_t WaitForSocketEventsInner(int32_t port, SocketEvent* buffer, int32 #else static const size_t SocketEventBufferElementSize = 0; +#if !defined(TARGET_WASI) static SocketEvents GetSocketEvents(int16_t filter, uint16_t flags) { return SocketEvents_SA_NONE; } +#endif /* TARGET_WASI */ + static int32_t CloseSocketEventPortInner(int32_t port) { return Error_ENOSYS; @@ -3054,6 +3254,7 @@ int32_t SystemNative_PlatformSupportsDualModeIPv4PacketInfo(void) #endif } +#if !defined(TARGET_WASI) static char* GetNameFromUid(uid_t uid) { size_t bufferLength = 512; @@ -3090,17 +3291,23 @@ static char* GetNameFromUid(uid_t uid) bufferLength = tmpBufferLength; } } +#endif /* TARGET_WASI */ char* SystemNative_GetPeerUserName(intptr_t socket) { +#if !defined(TARGET_WASI) uid_t euid; return SystemNative_GetPeerID(socket, &euid) == 0 ? GetNameFromUid(euid) : NULL; +#else /* TARGET_WASI */ + return NULL; +#endif /* TARGET_WASI */ } void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, int32_t* addressSize) { +#if !defined(TARGET_WASI) assert(pathOffset != NULL); assert(pathSize != NULL); assert(addressSize != NULL); @@ -3110,6 +3317,11 @@ void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, i *pathOffset = offsetof(struct sockaddr_un, sun_path); *pathSize = sizeof(domainSocket.sun_path); *addressSize = sizeof(domainSocket); +#else /* TARGET_WASI */ + *pathOffset = -1; + *pathSize = -1; + *addressSize = -1; +#endif /* TARGET_WASI */ } int32_t SystemNative_GetMaximumAddressSize(void) @@ -3284,378 +3496,12 @@ int32_t SystemNative_SendFile(intptr_t out_fd, intptr_t in_fd, int64_t offset, i uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) { assert(interfaceName != NULL); +#if !defined(TARGET_WASI) if (interfaceName[0] == '%') interfaceName++; return if_nametoindex(interfaceName); -} #else /* TARGET_WASI */ - -int32_t SystemNative_GetHostEntryForName(const uint8_t* address, int32_t addressFamily, HostEntry* entry) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -void SystemNative_FreeHostEntry(HostEntry* entry) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - if (entry != NULL) - { - free(entry->CanonicalName); - free(entry->IPAddressList); - - entry->CanonicalName = NULL; - entry->IPAddressList = NULL; - entry->IPAddressCount = 0; - } -} - -int32_t SystemNative_GetNameInfo(const uint8_t* address, - int32_t addressLength, - int8_t isIPv6, - uint8_t* host, - int32_t hostLength, - uint8_t* service, - int32_t serviceLength, - int32_t flags) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetDomainName(uint8_t* name, int32_t nameLength) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetHostName(uint8_t* name, int32_t nameLength) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetIPSocketAddressSizes(int32_t* ipv4SocketAddressSize, int32_t* ipv6SocketAddressSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetAddressFamily(const uint8_t* socketAddress, int32_t socketAddressLen, int32_t* addressFamily) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetAddressFamily(uint8_t* socketAddress, int32_t socketAddressLen, int32_t addressFamily) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetPort(const uint8_t* socketAddress, int32_t socketAddressLen, uint16_t* port) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetPort(uint8_t* socketAddress, int32_t socketAddressLen, uint16_t port) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetIPv4Address(const uint8_t* socketAddress, int32_t socketAddressLen, uint32_t* address) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetIPv4Address(uint8_t* socketAddress, int32_t socketAddressLen, uint32_t address) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetIPv6Address( - const uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t* scopeId) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t -SystemNative_SetIPv6Address(uint8_t* socketAddress, int32_t socketAddressLen, uint8_t* address, int32_t addressLen, uint32_t scopeId) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetControlMessageBufferSize(int32_t isIPv4, int32_t isIPv6) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t -SystemNative_TryGetIPPacketInformation(MessageHeader* messageHeader, int32_t isIPv4, IPPacketInformation* packetInfo) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetIPv4MulticastOption(intptr_t socket, int32_t multicastOption, IPv4MulticastOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetIPv6MulticastOption(intptr_t socket, int32_t multicastOption, IPv6MulticastOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetLingerOption(intptr_t socket, LingerOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetLingerOption(intptr_t socket, LingerOption* option) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetReceiveTimeout(intptr_t socket, int32_t millisecondsTimeout) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetSendTimeout(intptr_t socket, int32_t millisecondsTimeout) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Receive(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* received) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_ReceiveMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* received) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Send(intptr_t socket, void* buffer, int32_t bufferLen, int32_t flags, int32_t* sent) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SendMessage(intptr_t socket, MessageHeader* messageHeader, int32_t flags, int64_t* sent) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Accept(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen, intptr_t* acceptedSocket) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Bind(intptr_t socket, int32_t protocolType, uint8_t* socketAddress, int32_t socketAddressLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Connect(intptr_t socket, uint8_t* socketAddress, int32_t socketAddressLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetPeerName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetSockName(intptr_t socket, uint8_t* socketAddress, int32_t* socketAddressLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Listen(intptr_t socket, int32_t backlog) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Shutdown(intptr_t socket, int32_t socketShutdown) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetSocketErrorOption(intptr_t socket, int32_t* error) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetSockOpt( - intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetRawSockOpt( - intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t* optionLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t -SystemNative_SetSockOpt(intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_SetRawSockOpt( - intptr_t socket, int32_t socketOptionLevel, int32_t socketOptionName, uint8_t* optionValue, int32_t optionLen) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_Socket(int32_t addressFamily, int32_t socketType, int32_t protocolType, intptr_t* createdSocket) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetSocketType(intptr_t socket, int32_t* addressFamily, int32_t* socketType, int32_t* protocolType, int32_t* isListening) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetAtOutOfBandMark(intptr_t socket, int32_t* atMark) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_GetBytesAvailable(intptr_t socket, int32_t* available) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_CreateSocketEventPort(intptr_t* port) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_CloseSocketEventPort(intptr_t port) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_CreateSocketEventBuffer(int32_t count, SocketEvent** buffer) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_FreeSocketEventBuffer(SocketEvent* buffer) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - free(buffer); - return Error_SUCCESS; -} - -int32_t -SystemNative_TryChangeSocketEventRegistration(intptr_t port, intptr_t socket, int32_t currentEvents, int32_t newEvents, uintptr_t data) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_WaitForSocketEvents(intptr_t port, SocketEvent* buffer, int32_t* count) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return Error_EFAULT; -} - -int32_t SystemNative_PlatformSupportsDualModeIPv4PacketInfo(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0; -} - -char* SystemNative_GetPeerUserName(intptr_t socket) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return NULL; -} - -void SystemNative_GetDomainSocketSizes(int32_t* pathOffset, int32_t* pathSize, int32_t* addressSize) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - *pathOffset = 0; - *pathSize = 0; - *addressSize = 0; -} - -int32_t SystemNative_GetMaximumAddressSize(void) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_Disconnect(intptr_t socket) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -int32_t SystemNative_SendFile(intptr_t out_fd, intptr_t in_fd, int64_t offset, int64_t count, int64_t* sent) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return -1; -} - -uint32_t SystemNative_InterfaceNameToIndex(char* interfaceName) -{ - printf ("TODOWASI %s\n", __FUNCTION__); - return 0xFFFFFFFF; + return Error_EINVAL; +#endif /* TARGET_WASI */ } -#endif /* TARGET_WASI */ From 52fc57a96dfd3bc47aa29c516c8e3e9ed55506cd Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 21 Nov 2022 12:11:22 +0100 Subject: [PATCH 105/116] fix --- src/native/libs/CMakeLists.txt | 1 + src/native/libs/System.Native/pal_io.c | 10 +++++++++- src/native/libs/System.Native/pal_signal.c | 8 ++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index 00b0844136061..13c06f11493d7 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -62,6 +62,7 @@ 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_link_options(-Wl,-z,stack-size=1048576,--initial-memory=5242880,--max-memory=52428800,-lwasi-emulated-process-clocks,-lwasi-emulated-signal,-lwasi-emulated-mman) endif () if (CLR_CMAKE_TARGET_TVOS) diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 5f8402710547e..f696e3cba0ab6 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -744,7 +744,11 @@ int32_t SystemNative_FSync(intptr_t fd) int32_t SystemNative_FLock(intptr_t fd, int32_t operation) { int32_t result; +#if !defined(TARGET_WASI) while ((result = flock(ToFileDescriptor(fd), operation)) < 0 && errno == EINTR); +#else /* TARGET_WASI */ + result = EINTR; +#endif /* TARGET_WASI */ return result; } @@ -1018,7 +1022,7 @@ int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice) switch (advice) { case PAL_MADV_DONTFORK: -#ifdef MADV_DONTFORK +#if defined(MADV_DONTFORK) && !defined(TARGET_WASI) return madvise(address, (size_t)length, MADV_DONTFORK); #else (void)address, (void)length, (void)advice; @@ -1047,7 +1051,11 @@ int32_t SystemNative_MSync(void* address, uint64_t length, int32_t flags) return -1; } +#if !defined(TARGET_WASI) return msync(address, (size_t)length, flags); +#else + return -1; +#endif } int64_t SystemNative_SysConf(int32_t name) diff --git a/src/native/libs/System.Native/pal_signal.c b/src/native/libs/System.Native/pal_signal.c index 0f74124f8e50f..f09b45ff33f0b 100644 --- a/src/native/libs/System.Native/pal_signal.c +++ b/src/native/libs/System.Native/pal_signal.c @@ -726,13 +726,11 @@ void UninstallTTOUHandlerForConsole(void) } pthread_mutex_unlock(&lock); } -#endif /* TARGET_WASI */ #ifndef HAS_CONSOLE_SIGNALS int32_t SystemNative_InitializeTerminalAndSignalHandling(void) { -#if !defined(TARGET_WASI) static int32_t initialized = 0; // The Process, Console and PosixSignalRegistration classes call this method for initialization. @@ -746,9 +744,7 @@ int32_t SystemNative_InitializeTerminalAndSignalHandling(void) } return initialized; -#else /* TARGET_WASI */ - return false; -#endif /* TARGET_WASI */ } -#endif +#endif /* !HAS_CONSOLE_SIGNALS */ +#endif /* !TARGET_WASI */ From 3ac17c76cb446599a618128b0865861228f5fa82 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 22 Nov 2022 17:18:08 +0100 Subject: [PATCH 106/116] provision windows --- src/mono/mono.proj | 6 +++++- src/mono/wasi/provision.ps1 | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/mono/wasi/provision.ps1 diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 1ef30c4d58541..cea6bb7c32a0f 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -179,6 +179,7 @@ %(_VersionLines.Identity) https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz + https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-mingw.tar.gz @@ -187,7 +188,10 @@ WorkingDirectory="$(WasiLocalPath)" IgnoreStandardErrorWarningFormat="true" /> - + diff --git a/src/mono/wasi/provision.ps1 b/src/mono/wasi/provision.ps1 new file mode 100644 index 0000000000000..f20fcbdb888dd --- /dev/null +++ b/src/mono/wasi/provision.ps1 @@ -0,0 +1,14 @@ +param( + [Parameter()] + [string]$WasiSdkUrl, + [Parameter()] + [string]$WasiSdkVersion +) + +Remove-Item ./wasi-sdk/ -r -fo -ErrorAction SilentlyContinue +Remove-Item ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -fo +Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz +tar -xvzf ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz +Remove-Item ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -fo +Move-Item ./wasi-sdk-$WasiSdkVersion.*/ ./wasi-sdk/ +Copy-Item ./wasi-sdk-version.txt ./wasi-sdk/wasi-sdk-version.txt From 2ae615f33365971d5aff5c5bd7acb701cba36ecb Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 22 Nov 2022 18:22:04 +0100 Subject: [PATCH 107/116] wip --- src/mono/mono.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index cea6bb7c32a0f..29f290dc52023 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -400,7 +400,6 @@ <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> <_MonoCMakeArgs Condition="'$(TargetsWasi)' != 'true'" Include="-DENABLE_LLVM_RUNTIME=1"/> - <_MonoCMakeArgs Include="-DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm"/> <_MonoCFLAGS Include="-fexceptions"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> @@ -559,7 +558,8 @@ <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> - + + <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT=1"/> <_MonoCMakeArgs Include="-DFEATURE_PERFTRACING_DISABLE_CONNECT_PORTS=1" /> From 2fd6d22beadc9aea4d78ce1d1ee16ff6787bb1b9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 22 Nov 2022 20:44:14 +0100 Subject: [PATCH 108/116] wip on windows --- eng/native/gen-buildsys.cmd | 17 +++++++++++++---- .../System.Console/src/System.Console.csproj | 2 ++ .../System.Net.Mail/src/System.Net.Mail.csproj | 2 ++ .../src/System.Security.Cryptography.csproj | 2 ++ src/libraries/shims/src/System.forwards.cs | 8 ++++---- src/mono/mono.proj | 4 ++-- src/mono/wasi/wasi.proj | 2 +- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index b97b8125e0f8c..ed87ef0ad52ee 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -48,12 +48,12 @@ if /i "%__Arch%" == "wasm" ( ) if /i "%__Os%" == "Browser" ( if "%EMSDK_PATH%" == "" ( - if not exist "%__repoRoot%src\mono\wasm\emsdk" ( + if not exist "%__repoRoot%\src\mono\wasm\emsdk" ( echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root. exit /B 1 ) - set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk + set EMSDK_PATH=%__repoRoot%\src\mono\wasm\emsdk set EMSDK_PATH=!EMSDK_PATH:\=/! ) @@ -61,8 +61,17 @@ if /i "%__Arch%" == "wasm" ( set __UseEmcmake=1 ) if /i "%__Os%" == "wasi" ( - echo Error: WASI build not implemented on Windows yet - exit /B 1 + if "%WASI_SDK_PATH%" == "" ( + if not exist "%__repoRoot%\src\mono\wasi\wasi-sdk" ( + echo Error: Should set WASI_SDK_PATH environment variable pointing to emsdk root. + exit /B 1 + ) + + set WASI_SDK_PATH=%__repoRoot%src\mono\wasi\wasi-sdk + 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.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!/share/wasi-sysroot" ) ) else ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0" diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 43f8f2241e157..9d7d915a3583d 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -7,6 +7,8 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole + wasi + $(NoWarn);CA1418;CA1416 $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 61e9001c00834..67f36463eef3a 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -7,6 +7,8 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetMail + wasi + $(NoWarn);CA1418;CA1416 diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index 37f3691de7cbd..1681f51e25f42 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -17,6 +17,8 @@ true true true + wasi + $(NoWarn);CA1418;CA1416 diff --git a/src/libraries/shims/src/System.forwards.cs b/src/libraries/shims/src/System.forwards.cs index 19fac75cffcfc..30b661dec889d 100644 --- a/src/libraries/shims/src/System.forwards.cs +++ b/src/libraries/shims/src/System.forwards.cs @@ -4,7 +4,7 @@ // Add any internal types that we need to forward from System. // These types are required for Desktop to Core serialization as they are not covered by GenFacades because they are marked as internal. -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] -[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] +//TODOWASI [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.TreeSet<>))] +//TODOWASI [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.IO.Compression.ZLibException))] +//TODOWASI [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.CookieVariant))] +//TODOWASI [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Net.PathList))] diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 29f290dc52023..8409ab2e2a668 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -406,6 +406,8 @@ <_MonoCXXFLAGS Include="-fexceptions"/> <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> + + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> @@ -421,7 +423,6 @@ --> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> @@ -600,7 +601,6 @@ <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' != 'windows'">@(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeBuildCommand) <_MonoCMakeBuildCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && $(_MonoCMakeBuildCommand) - <_MonoCMakeBuildCommand Condition="'$(TargetsWasi)' == 'true' and '$(HostOS)' == 'windows'">echo TODOWASI building with cmake is not implemented on windows diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 90d02d60269cd..c0539894978b1 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -16,6 +16,7 @@ <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp false + \" @@ -97,7 +98,6 @@ <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)'))$(EscapedQuoteW)"/> <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> From 5d6c6c7e17742e51bd251f3aecaf83c34717639a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 23 Nov 2022 10:04:50 +0100 Subject: [PATCH 109/116] from @radical --- src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs | 5 +++++ src/mono/cmake/configure.cmake | 5 +++++ src/native/libs/System.Native/pal_time.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs index 9455ff312b307..a5757bc599a18 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Guid.Unix.cs @@ -12,10 +12,15 @@ public static unsafe Guid NewGuid() { Guid g; +#if !TARGET_WASI // Guid.NewGuid is often used as a cheap source of random data that are sometimes used for security purposes. // Windows implementation uses secure RNG to implement it. We use secure RNG for Unix too to avoid subtle security // vulnerabilities in applications that depend on it. See https://github.com/dotnet/runtime/issues/42752 for details. Interop.GetCryptographicallySecureRandomBytes((byte*)&g, sizeof(Guid)); +#else + // TODOWASI: crypto secure random bytes + Interop.GetRandomBytes((byte*)&g, sizeof(Guid)); +#endif const ushort VersionMask = 0xF000; const ushort RandomGuidVersion = 0x4000; diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 9939983f0e089..b74204108105e 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -92,6 +92,11 @@ else () check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H) endif() +if (HOST_WASI) + # sysctl is deprecated on Linux and doesn't work on Browser + set(HAVE_GETRUSAGE 0) +endif() + check_include_files("sys/types.h;sys/user.h" HAVE_SYS_USER_H) if(NOT HOST_DARWIN) diff --git a/src/native/libs/System.Native/pal_time.c b/src/native/libs/System.Native/pal_time.c index 04ffd55865d30..76786b9ca8ee8 100644 --- a/src/native/libs/System.Native/pal_time.c +++ b/src/native/libs/System.Native/pal_time.c @@ -121,6 +121,7 @@ int64_t SystemNative_GetBootTimeTicks(void) double SystemNative_GetCpuUtilization(ProcessCpuInformation* previousCpuInfo) { +#ifdef HAVE_GETRUSAGE uint64_t kernelTime = 0; uint64_t userTime = 0; @@ -169,4 +170,8 @@ double SystemNative_GetCpuUtilization(ProcessCpuInformation* previousCpuInfo) previousCpuInfo->lastRecordedKernelTime = kernelTime; return cpuUtilization; +#else + assert(false); + return 0; +#endif } From f3c3e06bf0b7675ad1db2afc3b6551ffdb41927a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 23 Nov 2022 12:57:32 +0100 Subject: [PATCH 110/116] browser container image --- eng/pipelines/common/platform-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 811313008da47..5bd0c98d18c35 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -387,7 +387,7 @@ jobs: targetRid: wasi-wasm platform: wasi_wasm shouldContinueOnError: ${{ parameters.shouldContinueOnError }} - container: Linux_x64 + container: Browser_wasm jobParameters: hostedOs: Linux runtimeFlavor: ${{ parameters.runtimeFlavor }} From e5a2cb463cf18c1b2fc5991fe0718aa7231db7d7 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 23 Nov 2022 13:54:05 +0100 Subject: [PATCH 111/116] windows build --- src/mono/wasi/wasi.proj | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index c0539894978b1..5ec5c4cc121fe 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -16,7 +16,6 @@ <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp false - \" @@ -94,12 +93,12 @@ <_WasiFlags Include="@(_WasiCommonFlags)" /> - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_WasiCompileFlags Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include').Replace('\','/'))"/> + <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include').Replace('\','/'))"/> + <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include').Replace('\','/'))"/> + <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include').Replace('\','/'))"/> + <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public').Replace('\','/'))"/> + <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib').Replace('\','/'))"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_SIGNAL"/> <_WasiCompileFlags Include="-D_WASI_EMULATED_MMAN"/> @@ -163,6 +162,7 @@ -O2 cmake $(MSBuildThisFileDirectory)runtime + cmake -G Ninja $(MSBuildThisFileDirectory)runtime $(CMakeBuildRuntimeConfigureCmd) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot @@ -182,12 +182,10 @@ $(CMakeBuildRuntimeConfigureCmd) -DWASM_OPT_ADDITIONAL_FLAGS="--enable-simd" $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_WASM_USER_THREADS=1 - - + call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" wasm && $(CMakeBuildRuntimeConfigureCmd) -v cmake --build . --config $(Configuration) $(CmakeOptions) - echo not implemented for WASI on Windows From 753ca359cae519b7d6be1fe83dac12d7671e9514 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 23 Nov 2022 19:12:37 +0100 Subject: [PATCH 112/116] windows run --- src/mono/sample/wasi/Directory.Build.targets | 4 +++- src/mono/wasi/wasmtime-version.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index a8c8e9a1c55f8..81e6cdb738675 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -47,6 +47,7 @@ %(_VersionLines.Identity) https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-linux.tar.xz https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-macos.tar.xz + https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-x86_64-windows.zip @@ -54,7 +55,8 @@ - + + diff --git a/src/mono/wasi/wasmtime-version.txt b/src/mono/wasi/wasmtime-version.txt index f93ea0ca33305..56fea8a08d2fa 100644 --- a/src/mono/wasi/wasmtime-version.txt +++ b/src/mono/wasi/wasmtime-version.txt @@ -1 +1 @@ -2.0.2 \ No newline at end of file +3.0.0 \ No newline at end of file From 5498e410b8e1fc54f3a00a7dafebeb733c59af81 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 23 Nov 2022 19:36:45 +0100 Subject: [PATCH 113/116] fix case sensitive wasi os --- eng/build.ps1 | 4 ++++ src/libraries/System.Console/src/System.Console.csproj | 2 -- src/libraries/System.Net.Mail/src/System.Net.Mail.csproj | 2 -- .../src/System.Security.Cryptography.csproj | 2 -- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 9382d460248af..e3e009d12da47 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -241,6 +241,10 @@ if ($PSBoundParameters.ContainsKey('os') -and $PSBoundParameters['os'] -eq "Brow # make sure it is capitalized $PSBoundParameters['os'] = "Browser" } +if ($PSBoundParameters.ContainsKey('os') -and $PSBoundParameters['os'] -eq "wasi") { + # make sure it is not capitalized + $PSBoundParameters['os'] = "wasi" +} foreach ($argument in $PSBoundParameters.Keys) { diff --git a/src/libraries/System.Console/src/System.Console.csproj b/src/libraries/System.Console/src/System.Console.csproj index 9d7d915a3583d..43f8f2241e157 100644 --- a/src/libraries/System.Console/src/System.Console.csproj +++ b/src/libraries/System.Console/src/System.Console.csproj @@ -7,8 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_SystemConsole - wasi - $(NoWarn);CA1418;CA1416 $(DefineConstants);TARGET_WASI diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index 67f36463eef3a..61e9001c00834 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -7,8 +7,6 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetMail - wasi - $(NoWarn);CA1418;CA1416 diff --git a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj index 1681f51e25f42..37f3691de7cbd 100644 --- a/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj +++ b/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj @@ -17,8 +17,6 @@ true true true - wasi - $(NoWarn);CA1418;CA1416 From c7fefaaf74b8bb725325c3e33ca1bb01a9b0471d Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 24 Nov 2022 19:14:43 +0100 Subject: [PATCH 114/116] fix wasmtime provisioning on unix --- src/mono/sample/wasi/Directory.Build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/sample/wasi/Directory.Build.targets b/src/mono/sample/wasi/Directory.Build.targets index 81e6cdb738675..df21a15d0a545 100644 --- a/src/mono/sample/wasi/Directory.Build.targets +++ b/src/mono/sample/wasi/Directory.Build.targets @@ -56,7 +56,7 @@ - + From a97a4b72a21d72a89d4f8f1b83a127cef897bba3 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 29 Nov 2022 04:42:04 -0500 Subject: [PATCH 115/116] Update pal_dynamicload.c --- src/native/libs/System.Native/pal_dynamicload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/native/libs/System.Native/pal_dynamicload.c b/src/native/libs/System.Native/pal_dynamicload.c index 004da033e3277..9025b10f43f16 100644 --- a/src/native/libs/System.Native/pal_dynamicload.c +++ b/src/native/libs/System.Native/pal_dynamicload.c @@ -73,7 +73,7 @@ void SystemNative_FreeLibrary(void* handle) #endif /* TARGET_WASI */ } -#if defined TARGET_ANDROID || TARGET_WASI +#if defined TARGET_WASI void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) { return NULL; @@ -99,3 +99,4 @@ void* SystemNative_GetDefaultSearchOrderPseudoHandle(void) } return defaultSearchOrderPseudoHandle; } +#endif From 0923b99b82ed6f2f968cb335954ff847d34bd59a Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 29 Nov 2022 13:23:24 +0100 Subject: [PATCH 116/116] fix windows paths --- src/mono/mono.proj | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 8409ab2e2a668..32bb8cc615ea0 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -255,7 +255,7 @@ <_MonoCMakeArgs Condition="'$(_MonoUseNinja)' == 'true'" Include="-G Ninja"/> - <_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX="$(MonoObjDir)out""/> + <_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX="$(MonoObjDir.Replace('\','/'))out""/> <_MonoCMakeArgs Include="-DCMAKE_INSTALL_LIBDIR=lib"/> <_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/> <_MonoCMakeArgs Condition="'$(CMakeArgs)' != ''" Include="$(CMakeArgs)"/> @@ -408,8 +408,8 @@ <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> @@ -421,16 +421,16 @@ sockets,eventpipe Ninja ? --> - <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'mono-include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'mono', 'eglib').Replace('\','/'))$(EscapedQuoteW)"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_SIGNAL"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_MMAN"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/>