Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e4e1cc3
Add stubbed browser WASM NativeAOT CoreLib
jtschuster Sep 17, 2026
9cfab06
remove extra stuff
jtschuster Sep 17, 2026
f87741c
Tighten browser WASM CoreLib stubs
jtschuster Sep 18, 2026
b71f149
Simplify browser WASM CoreLib configuration
jtschuster Sep 18, 2026
9d47d3b
Enable clr.nativeaotlibs subset for browser-wasm
jtschuster Sep 18, 2026
da4f8bb
Fix RhpThrow* helpers and remove unnecessary comment
jtschuster Sep 18, 2026
0159f79
Match clr.featuredefines.props and coalesce setting the same property…
jtschuster Sep 18, 2026
e33dd4d
Remove Browser filter on shared wasm msbuild confitions, remove NoInl…
jtschuster Sep 22, 2026
0926af3
Add TARGET_WASI, rename *.Browser.cs to *.Wasm.cs
jtschuster Sep 23, 2026
7c1dc98
Update comments to remove 'Browser-' prefix for WASM
jtschuster Sep 23, 2026
b1069b0
Merge branch 'main' of https://github.com/dotnet/runtime into nativea…
jtschuster Sep 24, 2026
8d2cb42
Merge branch 'nativeaot-wasm-runtime-pack' of https://github.com/jtsc…
jtschuster Sep 24, 2026
b833d39
Address PR feedback
jtschuster Sep 24, 2026
94f8ffe
Address feedback
jtschuster Sep 25, 2026
eda7efc
Condition ComAwareWeakReference on FeatureComInterop || FeatureComWra…
jtschuster Sep 25, 2026
f72ffd3
Make RuntimeImports use (!)TARGET_WINDOWS instead of TARGET_UNIX
jtschuster Sep 25, 2026
1f54ed1
Use !TARGET_WINDOWS in Thread.NativeAot.cs
jtschuster Sep 25, 2026
eb9b2e7
Remove FeatureComInterop condition for ComAwareWeakReference
jtschuster Oct 3, 2026
830484f
Merge branch 'main' of https://github.com/dotnet/runtime into nativea…
jtschuster Oct 3, 2026
7c95ee1
Let ifdef's exclude ComWrappers source, not msbuild conditions
jtschuster Oct 5, 2026
e3cc912
Remove arg from CreateThunksHeap
jtschuster Oct 5, 2026
54e29f3
Merge branch 'main' of https://github.com/dotnet/runtime into nativea…
jtschuster Oct 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@
<ItemGroup Condition="$(_subset.Contains('+clr.nativeaotlibs+')) and '$(NativeAotSupported)' == 'true'">
<ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\**\src\*.csproj" Category="clr" />
</ItemGroup>
<ItemGroup Condition="$(_subset.Contains('+clr.nativeaotlibs+')) and '$(TargetsWasm)' == 'true'">
<!-- Test.CoreLib fails to build with the stubbed out nativeaot corelib -->
<ProjectToBuild Remove="$(CoreClrProjectRoot)nativeaot\Test.CoreLib\src\Test.CoreLib.csproj" />
</ItemGroup>

<!-- Mono sets -->
<ItemGroup Condition="$(_subset.Contains('+mono.llvm+')) or $(_subset.Contains('+mono.aotcross+')) or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'android' or '$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi' or '$(TargetsLinuxBionic)' == 'true'">
Expand Down
2 changes: 0 additions & 2 deletions eng/common/native/NativeAotSupported.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<!-- Reject unsupported OS via RID prefix match -->
<_NativeAotSupportedOS Condition="
'$(TargetOS)' != 'browser' and
'$(TargetOS)' != 'haiku' and
Comment on lines 5 to 6

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid feedback

@am11 am11 Sep 20, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create additional PR upstream so overwriting doesn’t revert it, without dropping the changes here. It’s not exactly prohibited.

'$(TargetOS)' != 'illumos' and
'$(TargetOS)' != 'netbsd' and
Expand All @@ -12,7 +11,6 @@

<!-- Reject unsupported architectures via RID suffix match -->
<_NativeAotSupportedArch Condition="
'$(TargetArchitecture)' != 'wasm' and
'$(TargetArchitecture)' != 's390x' and
'$(TargetArchitecture)' != 'ppc64le' and
('$(TargetArchitecture)' != 'x86' or '$(TargetOS)' == 'windows')
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<OutputPath Condition="$(MSBuildProjectName.StartsWith('System.Private.'))">$(RuntimeBinDir)/aotsdk/</OutputPath>
<Configurations>Debug;Release;Checked</Configurations>
<Platforms>x64;x86;arm;arm64</Platforms>
<Platforms>x64;x86;arm;arm64;wasm</Platforms>

<Platform Condition=" '$(Platform)' == '' ">$(TargetArchitecture)</Platform>
<Platform Condition=" '$(Platform)' == 'armel' ">arm</Platform>
Expand Down Expand Up @@ -56,6 +56,7 @@
</PropertyGroup>
<PropertyGroup>
<FeatureComWrappers>true</FeatureComWrappers>
<FeatureComWrappers Condition="'$(TargetsWasm)' == 'true'">false</FeatureComWrappers>
<DefineConstants Condition="'$(FeatureComWrappers)' == 'true'">FEATURE_COMWRAPPERS;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -77,6 +78,9 @@
</PropertyGroup>

<!-- Platform specific properties -->
<PropertyGroup Condition="'$(Platform)' == 'wasm'">
<DefineConstants>TARGET_32BIT;TARGET_WASM;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<DefineConstants>TARGET_64BIT;TARGET_AMD64;$(DefineConstants)</DefineConstants>
</PropertyGroup>
Expand All @@ -99,6 +103,8 @@
<PropertyGroup>
<DefineConstants Condition="'$(TargetsWindows)'=='true'">TARGET_WINDOWS;$(DefineConstants)</DefineConstants>
<DefineConstants Condition="'$(TargetsUnix)'=='true'">TARGET_UNIX;$(DefineConstants)</DefineConstants>
<DefineConstants Condition="'$(TargetsBrowser)'=='true'">TARGET_BROWSER;$(DefineConstants)</DefineConstants>
<DefineConstants Condition="'$(TargetsWasi)'=='true'">TARGET_WASI;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<!-- Configuration specific properties -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;

using Internal.Runtime;

namespace System.Runtime
{
// These exports preserve the WASM compiler/runtime ABI while exception dispatch
// remains unimplemented.
internal static unsafe partial class EH
{
internal struct ExInfo
{
}

[RuntimeExport("RhpThrowEx")]
private static void RhpThrowEx(object exception)
{
FallbackFailFast(RhFailFastReason.InternalError, exception);
}

[RuntimeExport("RhpThrowExact")]
private static void RhpThrowExact(object exception)
{
FallbackFailFast(RhFailFastReason.InternalError, exception);
}

[RuntimeExport("RhpRethrow")]
private static void RhpRethrow()
{
FallbackFailFast(RhFailFastReason.InternalError, null);
}

[RuntimeExport("RhpHandleExceptionWasmCatch")]
private static object RhpHandleExceptionWasmCatch(nuint catchUnwindIndex)
{
_ = catchUnwindIndex;
FallbackFailFast(RhFailFastReason.InternalError, null);
return null!;
}

[RuntimeExport("RhpPopUnwoundSparseVirtualFrames")]
private static void RhpPopUnwoundSparseVirtualFrames()
{
}

[RuntimeExport("RhpHandleUnhandledException")]
private static void RhpHandleUnhandledException(object exception)
{
FallbackFailFast(RhFailFastReason.UnhandledException, exception);
}

[RuntimeExport("RhGetCurrentThreadStackTrace")]
private static int RhGetCurrentThreadStackTrace(IntPtr[] outputBuffer)
{
_ = outputBuffer;
return 0;
}

[StackTraceHidden]
[DebuggerHidden]
[RuntimeExport("RhExceptionHandling_FailedAllocation")]
public static void FailedAllocation(MethodTable* pEEType, bool fIsOverflow)
{
_ = pEEType;
_ = fIsOverflow;
FallbackFailFast(RhFailFastReason.InternalError, null);
}

internal static void FallbackFailFast(RhFailFastReason reason, object? unhandledException)
{
_ = reason;
_ = unhandledException;
InternalCalls.RhpFallbackFailFast();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ internal static class InternalCalls
internal static extern unsafe void RhpInitializeGcStress();
#endif // FEATURE_GC_STRESS

// WASM omits the native EH enumerator and StackFrameIterator implementation.
#if !TARGET_WASM
[RuntimeImport(RuntimeLibrary, "RhpEHEnumInitFromStackFrameIterator")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpEHEnumInitFromStackFrameIterator(ref StackFrameIterator pFrameIter, out EH.MethodRegionInfo pMethodRegionInfo, void* pEHEnum);

[RuntimeImport(RuntimeLibrary, "RhpEHEnumNext")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpEHEnumNext(void* pEHEnum, void* pEHClause);
#endif // !TARGET_WASM

[RuntimeImport(RuntimeLibrary, "RhpGetClasslibFunctionFromCodeAddress")]
[MethodImpl(MethodImplOptions.InternalCall)]
Expand All @@ -141,13 +144,16 @@ internal static class InternalCalls
// StackFrameIterator
//

// WASM does not have the native register context required by this iterator.
#if !TARGET_WASM
[RuntimeImport(RuntimeLibrary, "RhpSfiInit")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpSfiInit(ref StackFrameIterator pThis, void* pStackwalkCtx, bool instructionFault, bool* fIsExceptionIntercepted);

[RuntimeImport(RuntimeLibrary, "RhpSfiNext")]
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern unsafe bool RhpSfiNext(ref StackFrameIterator pThis, uint* uExCollideClauseIdx, bool* fUnwoundReversePInvoke, bool* fIsExceptionIntercepted);
#endif // !TARGET_WASM

//
// Miscellaneous helpers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public static unsafe void RhUnbox(object? obj, ref byte data, MethodTable* pUnbo
}
}

#if !TARGET_WASM
[RuntimeExport("RhGetCurrentThreadStackTrace")]
[MethodImpl(MethodImplOptions.NoInlining)] // Ensures that the RhGetCurrentThreadStackTrace frame is always present
public static unsafe int RhGetCurrentThreadStackTrace(IntPtr[] outputBuffer)
Expand Down Expand Up @@ -342,5 +343,6 @@ private static unsafe int RhpCalculateStackTraceWorker(IntPtr* pOutputBuffer, ui

return success ? (int)nFrames : -(int)nFrames;
}
#endif // !TARGET_WASM
}
}
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FCIMPL1(uint8_t *, RhGetCrashInfoBuffer, int32_t* pcbMaxSize)
}
FCIMPLEND

#if TARGET_UNIX
#if TARGET_UNIX || TARGET_WASM
#include "PalCreateDump.h"
FCIMPL1(void, RhCreateCrashDumpIfEnabled, PEXCEPTION_RECORD pExceptionRecord)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,18 +616,18 @@ public static unsafe string TryGetFullPathToApplicationModule(IntPtr ip, out Int
moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip);
if (moduleBase == IntPtr.Zero)
return null;
#if TARGET_UNIX
#if TARGET_WINDOWS
char* pModuleName;
int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName);
string modulePath = new string(pModuleName, 0, numChars);
#else
// RhGetModuleFileName on Unix calls dladdr that accepts any ip. Avoid the redundant lookup
// and pass the ip into RhGetModuleFileName directly. Also, older versions of Musl have a bug
// that leads to crash with the redundant lookup.
byte* pModuleNameUtf8;
int numUtf8Chars = RuntimeImports.RhGetModuleFileName(ip, out pModuleNameUtf8);
string modulePath = System.Text.Encoding.UTF8.GetString(pModuleNameUtf8, numUtf8Chars);
#else // TARGET_UNIX
char* pModuleName;
int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName);
string modulePath = new string(pModuleName, 0, numChars);
#endif // TARGET_UNIX
#endif
return modulePath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ internal static unsafe IntPtr ResolvePInvokeSlow(MethodFixupCell* pCell)

internal static unsafe void FreeLibrary(IntPtr hModule)
{
#if !TARGET_UNIX
#if TARGET_WINDOWS
Interop.Kernel32.FreeLibrary(hModule);
#else
Interop.Sys.FreeLibrary(hModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,22 @@
<PropertyGroup>
<FeaturePortableTimer>true</FeaturePortableTimer>
</PropertyGroup>
<PropertyGroup>
<FeatureThunkPool>true</FeatureThunkPool>
</PropertyGroup>
<PropertyGroup>
<FeatureHardwareIntrinsics>true</FeatureHardwareIntrinsics>
<FeatureSharedLowLevelLock>true</FeatureSharedLowLevelLock>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetsWasm)' == 'true'">
<FeatureThunkPool>false</FeatureThunkPool>

<!-- single thread -->
<FeaturePortableTimer Condition="'$(WasmEnableThreads)' != 'true'">false</FeaturePortableTimer>
<FeaturePortableThreadPool Condition="'$(WasmEnableThreads)' != 'true'">false</FeaturePortableThreadPool>
</PropertyGroup>

<PropertyGroup>
<Features>$(Features);runtime-async=on</Features>
</PropertyGroup>
Expand Down Expand Up @@ -167,7 +178,7 @@
<Compile Include="System\Reflection\Runtime\TypeInfos\RuntimeFunctionPointerTypeInfo.cs" />
<Compile Include="System\Reflection\Runtime\TypeInfos\RuntimeFunctionPointerTypeInfo.UnificationKey.cs" />
<Compile Include="System\CrashInfo.cs" />
<Compile Include="System\Runtime\InteropServices\ComAwareWeakReference.NativeAot.cs" />
<Compile Include="System\Runtime\InteropServices\ComAwareWeakReference.NativeAot.cs" Condition="'$(FeatureComWrappers)' == 'true'" />
<Compile Include="System\Runtime\InteropServices\CriticalHandle.NativeAot.cs" />
<Compile Include="System\Runtime\InteropServices\Java\JavaMarshal.NativeAot.cs" Condition="'$(FeatureJavaMarshal)' == 'true'" />
<Compile Include="System\Activator.NativeAot.cs" />
Expand Down Expand Up @@ -206,7 +217,8 @@
<Compile Include="System\Runtime\GCSettings.NativeAot.cs" />
<Compile Include="System\Runtime\InteropServices\TypeMapLazyDictionary.NativeAot.cs" />
<Compile Include="System\Runtime\TypeLoaderExports.cs" />
<Compile Include="System\Runtime\ThunkPool.cs" />
<Compile Include="System\Runtime\ThunkPool.cs" Condition="'$(FeatureThunkPool)' == 'true'" />
<Compile Include="System\Runtime\ThunkPool.NotSupported.cs" Condition="'$(FeatureThunkPool)' != 'true'" />
<Compile Include="System\Runtime\InteropServices\ComEventsHelper.NativeAot.cs" Condition="'$(FeatureCominterop)' == 'true'" />
<Compile Include="System\Runtime\InteropServices\ComWrappers.NativeAot.cs" Condition="'$(FeatureComWrappers)' == 'true'" />
<Compile Include="System\Runtime\InteropServices\GCHandle.NativeAot.cs" />
Expand Down Expand Up @@ -287,7 +299,7 @@
<Compile Include="System\Threading\Thread.NativeAot.Windows.cs" />
<Compile Include="System\Threading\ThreadPoolCallbackWrapper.NativeAot.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)'=='true'">
<ItemGroup Condition="'$(TargetsUnix)'=='true' or '$(TargetsWasm)'=='true'">
<Compile Include="Internal\Runtime\FrozenObjectHeapManager.Unix.cs" />
<Compile Include="System\Environment.NativeAot.Unix.cs" />
<Compile Include="System\Runtime\InteropServices\PInvokeMarshal.Unix.cs" />
Expand Down Expand Up @@ -495,22 +507,25 @@
<Compile Include="$(RuntimeBasePath)System\Runtime\GCStress.cs">
<Link>Runtime.Base\src\System\Runtime\GCStress.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\__Finalizer.cs">
<Compile Include="$(RuntimeBasePath)System\Runtime\__Finalizer.cs" Condition="'$(TargetsWasm)' != 'true'">
<Link>Runtime.Base\src\System\Runtime\__Finalizer.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\MethodTable.Runtime.cs">
<Link>Runtime.Base\src\System\Runtime\MethodTable.Runtime.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\ExceptionHandling.cs">
<Compile Include="$(RuntimeBasePath)System\Runtime\ExceptionHandling.cs" Condition="'$(TargetsWasm)' != 'true'">
<Link>Runtime.Base\src\System\Runtime\ExceptionHandling.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\ExceptionHandling.wasm.cs" Condition="'$(TargetsWasm)' == 'true'">
<Link>Runtime.Base\src\System\Runtime\ExceptionHandling.wasm.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\InternalCalls.cs">
<Link>Runtime.Base\src\System\Runtime\InternalCalls.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\RuntimeExports.cs">
<Link>Runtime.Base\src\System\Runtime\RuntimeExports.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\StackFrameIterator.cs">
<Compile Include="$(RuntimeBasePath)System\Runtime\StackFrameIterator.cs" Condition="'$(TargetsWasm)' != 'true'">
<Link>Runtime.Base\src\System\Runtime\StackFrameIterator.cs</Link>
</Compile>
<Compile Include="$(RuntimeBasePath)System\Runtime\TypeCast.cs">
Expand All @@ -520,7 +535,7 @@
<Link>Common\TransitionBlock.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(InPlaceRuntime)' == 'true'">
<ItemGroup Condition="'$(InPlaceRuntime)' == 'true' and '$(TargetsWasm)' != 'true'">
<Compile Include="$(IntermediatesDir)\nativeaot\Runtime\Full\AsmOffsets.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace System.Diagnostics
{
public partial class StackTrace
{
#if !TARGET_WASM
/// <summary>
/// Initialize the stack trace based on current thread and given initial frame index.
/// </summary>
Expand All @@ -25,7 +24,6 @@ private void InitializeForCurrentThread(int skipFrames, bool needFileInfo)
Debug.Assert(trueFrameCount == frameCount);
InitializeForIpAddressArray(stackTrace, skipFrames + SystemDiagnosticsStackDepth, frameCount, needFileInfo);
}
#endif

/// <summary>
/// Initialize the stack trace based on a given exception and initial frame index.
Expand Down Expand Up @@ -77,7 +75,6 @@ private void InitializeForIpAddressArray(IntPtr[] ipAddresses, int skipFrames, i
_methodsToSkip = 0;
}

#if !TARGET_WASM
internal void ToString(TraceFormat traceFormat, StringBuilder builder)
{
if (_stackFrames != null)
Expand All @@ -94,6 +91,5 @@ internal void ToString(TraceFormat traceFormat, StringBuilder builder)
if (traceFormat == TraceFormat.TrailingNewLine && builder.Length == 0)
builder.AppendLine();
}
#endif
}
}
Loading
Loading