Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] build paltests #112404

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
779f950
Make configure pass for wasm and paltests component
radekdoulik Jan 21, 2025
b33f467
Fix compilation and linking on wasm
radekdoulik Jan 24, 2025
812d033
Ignore limits and dlopen(nullptr, ...) on wasm
radekdoulik Jan 27, 2025
d5609a1
Do not return 0 for minipal_get_current_thread_id on wasm
radekdoulik Jan 27, 2025
249c63b
Add simple index.html to run paltests on wasm in browser
radekdoulik Jan 27, 2025
182dbab
Forward console log and error to http server
radekdoulik Jan 28, 2025
1e85092
Enable debug output temporarily
radekdoulik Jan 28, 2025
e3a397d
Do not create synchronization manager worker thread on wasm
radekdoulik Jan 28, 2025
c815832
Temporarily override main args on wasm to simplify testing
radekdoulik Jan 28, 2025
b31bd17
Prototype pal test suite runner
kg Jan 29, 2025
c8e6f43
Reload between tests to work around stack exhaustion
kg Jan 29, 2025
e398347
Shorter delay between tests; logging of exit code specifies which tes…
kg Jan 29, 2025
ceecb69
Add mechanism for disabling tests and disable the debug_api tests
kg Jan 29, 2025
25911d5
Disable another set of tests
kg Jan 29, 2025
b764cab
Disable more tests and reduce run delay
kg Jan 29, 2025
10ca17d
Full test run completes now
kg Jan 29, 2025
7d323bc
Use exit runtime option
radekdoulik Feb 3, 2025
5f57edc
Add summary with counts of passed, failed and disabled tests
radekdoulik Feb 3, 2025
0ed2e2c
Trap on assert to stop
radekdoulik Feb 3, 2025
9a724a8
Filter the tests, use paltestlist.txt as runpaltests.sh
radekdoulik Feb 3, 2025
e6ae8b4
Don't output when capturing tests
radekdoulik Feb 3, 2025
b7e67f9
Add notes to failing tests
radekdoulik Feb 3, 2025
ebe84a5
Make flush instruction cache no-op on wasm, disable few MT tests
radekdoulik Feb 4, 2025
25639aa
Reenable debug_api test, which is not failing
radekdoulik Feb 4, 2025
ee586b5
Do not call mmap to re-set memory protection
radekdoulik Feb 5, 2025
5025bc5
Disable 3 exception_handling/RaiseException tests
radekdoulik Feb 5, 2025
b0b5dff
Disable paltest_probememory_probememory_neg1
radekdoulik Feb 6, 2025
db1ee87
Disable dll tests on wasm
radekdoulik Feb 7, 2025
5529d79
Fix cmake warnings
radekdoulik Feb 7, 2025
1fc2a12
Install the additional files for wasm
radekdoulik Feb 7, 2025
2723525
Use onExit instead of quit
radekdoulik Feb 10, 2025
1980944
Add mono.emsdk subset
radekdoulik Feb 10, 2025
399c0a5
Remove forgotten check
radekdoulik Feb 10, 2025
fc4b084
Update msbuild targets to allow build of wasm paltests
radekdoulik Feb 11, 2025
738a2e4
Add CI build and temporarily disable all other runtime builds to save…
radekdoulik Feb 11, 2025
e3ceeca
Merge remote-tracking branch 'remotes/origin/main'
radekdoulik Feb 11, 2025
062a5ec
Fix remaining conflict
radekdoulik Feb 11, 2025
763ffbd
Fix build afer merge with main
radekdoulik Feb 11, 2025
2abcabf
Make membarrier noop on wasm
radekdoulik Feb 11, 2025
f118db1
Change subsets build order
radekdoulik Feb 11, 2025
46e8dd2
Merge branch 'main' into wasm-build
lewing Feb 12, 2025
bd7f383
Disable fs test which fails with chromedriver
radekdoulik Feb 12, 2025
96f70e1
Fix InternalCanonicalizeRealPath corner case that affects wasm pal tests
kg Feb 12, 2025
4dbb97d
Zero memory for MEM_DECOMMIT on WASM instead of just doing nothing, t…
kg Feb 12, 2025
e735301
Removed notes about the failing tests
radekdoulik Feb 13, 2025
a622aad
Fix few new cmake warnings
radekdoulik Feb 13, 2025
9635ab5
Put runtime runs back
radekdoulik Feb 13, 2025
f9569ed
Merge branch 'main' into wasm-build
radekdoulik Feb 13, 2025
8576c23
Remove unwanted changes
radekdoulik Feb 13, 2025
cfccd4b
List disabled and failed tests when the run completed
radekdoulik Feb 13, 2025
03b890d
Fix mono wasm/MT build
radekdoulik Feb 14, 2025
efe85cb
Remove unwanted fields
radekdoulik Feb 14, 2025
f230b37
Merge branch 'main' into wasm-build
radekdoulik Feb 14, 2025
c592985
Fix mono wasm/MT build once more
radekdoulik Feb 14, 2025
f280813
Fix windows build
radekdoulik Feb 14, 2025
ffd05ad
Merge branch 'main' into wasm-build
radekdoulik Feb 14, 2025
9caabff
Fix windows build
radekdoulik Feb 17, 2025
c5185e9
Merge branch 'main' into wasm-build
radekdoulik Feb 17, 2025
3414b4b
Merge branch 'main' into wasm-build
radekdoulik Feb 18, 2025
04dc417
Feedback
radekdoulik Feb 27, 2025
0518bfb
More feedback
radekdoulik Feb 27, 2025
a3e61cd
More feedback
radekdoulik Feb 27, 2025
026ce15
More feedback
radekdoulik Feb 27, 2025
0f63c60
Merge remote-tracking branch 'remotes/origin/main' into wasm-build
radekdoulik Feb 27, 2025
ee63033
Feedback
radekdoulik Feb 28, 2025
a776620
Fix cmake warning
radekdoulik Feb 28, 2025
2a04e29
Merge branch 'main' into wasm-build
radekdoulik Feb 28, 2025
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
8 changes: 7 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
<!-- Mono -->
<SubsetName Include="Mono" Description="The Mono runtime and CoreLib. Equivalent to: $(DefaultMonoSubsets)" />
<SubsetName Include="Mono.Runtime" Description="The Mono .NET runtime." />
<SubsetName Include="Mono.EmSDK" Description="The emsdk provisioning." />
<SubsetName Include="Mono.AotCross" Description="The cross-compiler runtime for Mono AOT." />
<SubsetName Include="Mono.CoreLib" Description="The managed System.Private.CoreLib library for Mono." />
<SubsetName Include="Mono.Manifests" Description="The NuGet packages with manifests defining the mobile and Blazor workloads." />
Expand Down Expand Up @@ -264,6 +265,11 @@
</ProjectToBuild>
</ItemDefinitionGroup>

<!-- emscripten provisioning, needs to be placed before runtime projects -->
<ItemGroup Condition="$(_subset.Contains('+mono.emsdk+'))">
<ProjectToBuild Include="$(MonoProjectRoot)mono.proj" AdditionalProperties="%(AdditionalProperties);ProvisionEmscriptenOnly=true" Category="mono" />
</ItemGroup>

<!-- CoreClr sets -->
<ItemGroup Condition="$(_subset.Contains('+clr.corelib+'))">
<ProjectToBuild Include="$(CoreClrProjectRoot)System.Private.CoreLib\System.Private.CoreLib.csproj" Category="clr" />
Expand Down Expand Up @@ -325,7 +331,7 @@
The cross tools are used as part of the build process with the downloaded build tools, so we need to build them for the host architecture and build them as unsanitized binaries.
-->
<PropertyGroup>
<_BuildAnyCrossArch Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != ''">true</_BuildAnyCrossArch>
<_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetArchitecture)' != 'wasm'">true</_BuildAnyCrossArch>
<_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true</_BuildCrossComponents>
<_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true</_BuildCrossComponents>
<_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true</_CrossBitwidthBuild>
Expand Down
15 changes: 15 additions & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ extends:
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
eq(variables['isRollingBuild'], true))

- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: ${{ variables.debugOnPrReleaseOnRolling }}
platforms:
- browser_wasm
jobParameters:
nameSuffix: AllSubsets_CoreCLR
buildArgs: -s mono.emsdk+clr.paltests -rc Release -c Release -lc $(_BuildConfig)
timeoutInMinutes: 120
condition: >-
or(
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
eq(variables['isRollingBuild'], true))

#
# Build CoreCLR and Libraries with Libraries tests
# For running libraries tests and installer tests
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(CORECLR_SET_RPATH)
set(MACOSX_RPATH ON)
endif(CORECLR_SET_RPATH)

if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS)
if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_BROWSER)
set(FEATURE_STANDALONE_GC 0)
endif()

Expand Down Expand Up @@ -148,8 +148,9 @@ endif()
include_directories("pal/prebuilt/inc")
include_directories(${CLR_ARTIFACTS_OBJ_DIR})

add_subdirectory(tools/aot/jitinterface)

if (NOT CLR_CMAKE_TARGET_BROWSER)
add_subdirectory(tools/aot/jitinterface)
endif (NOT CLR_CMAKE_TARGET_BROWSER)

if(NOT CLR_CROSS_COMPONENTS_BUILD)
# NativeAOT only buildable for a subset of CoreCLR-supported configurations
Expand Down Expand Up @@ -262,7 +263,7 @@ if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(nativeresources)
endif(CLR_CMAKE_HOST_UNIX)

if(NOT CLR_CMAKE_HOST_TVOS)
if(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)
add_subdirectory(utilcode)
add_subdirectory(inc)

Expand All @@ -280,7 +281,7 @@ if(NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(dlls)
add_subdirectory(unwinder)
add_subdirectory(interop)
endif()
endif(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)

if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(tools)
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
endif()

if(NOT DEFINED FEATURE_EVENT_TRACE)
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
set(FEATURE_EVENT_TRACE 1)
if (NOT CLR_CMAKE_TARGET_BROWSER)
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
set(FEATURE_EVENT_TRACE 1)
endif()
endif(NOT DEFINED FEATURE_EVENT_TRACE)

if(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/volatile.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#error The Volatile type is currently only defined for Visual C++ and GNU C++
#endif

#if defined(__GNUC__) && !defined(HOST_X86) && !defined(HOST_AMD64) && !defined(HOST_ARM) && !defined(HOST_ARM64) && !defined(HOST_LOONGARCH64) && !defined(HOST_RISCV64) && !defined(HOST_S390X) && !defined(HOST_POWERPC64)
#if defined(__GNUC__) && !defined(HOST_X86) && !defined(HOST_AMD64) && !defined(HOST_ARM) && !defined(HOST_ARM64) && !defined(HOST_LOONGARCH64) && !defined(HOST_RISCV64) && !defined(HOST_S390X) && !defined(HOST_POWERPC64) && !defined(HOST_WASM)
#error The Volatile type is currently only defined for GCC when targeting x86, AMD64, ARM, ARM64, LOONGARCH64, RISCV64, PPC64LE, or S390X CPUs
#endif

Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ else()
add_custom_target(interpreter_exports DEPENDS ${EXPORTS_FILE})
endif()

add_library_clr(clrinterpreter SHARED ${INTERPRETER_SOURCES})
if(CLR_CMAKE_TARGET_BROWSER)
set(LIBRARY_TYPE STATIC)
else()
set(LIBRARY_TYPE SHARED)
endif()

add_library_clr(clrinterpreter ${LIBRARY_TYPE} ${INTERPRETER_SOURCES})

add_dependencies(clrinterpreter interpreter_exports)

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ elseif(CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
elseif(CLR_CMAKE_TARGET_ARCH_RISCV64)
set(JIT_ARCH_SOURCES ${JIT_RISCV64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_RISCV64_HEADERS})
elseif(CLR_CMAKE_TARGET_ARCH_WASM)
set(JIT_ARCH_SOURCES ${JIT_WASM32_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_WASM32_HEADERS})
else()
clr_unknown_arch()
endif()
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ include_directories(${COREPAL_SOURCE_DIR}/inc)
include_directories(${COREPAL_SOURCE_DIR}/src)
include_directories(${COREPAL_SOURCE_DIR}/../inc)

add_compile_options(-fexceptions)
if (NOT CLR_CMAKE_TARGET_BROWSER)
add_compile_options(-fexceptions)
else()
add_compile_options(-fwasm-exceptions)
add_link_options(-fwasm-exceptions -sEXIT_RUNTIME=1)
endif()

add_subdirectory(src)
add_subdirectory(tests)
22 changes: 22 additions & 0 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,26 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
//

} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
#elif defined(HOST_WASM)
#define CONTEXT_CONTROL 0
#define CONTEXT_INTEGER 0
#define CONTEXT_FLOATING_POINT 0
#define CONTEXT_FULL 0

#define CONTEXT_XSTATE 0

#define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
#define CONTEXT_SERVICE_ACTIVE 0x10000000L
#define CONTEXT_EXCEPTION_REQUEST 0x40000000L
#define CONTEXT_EXCEPTION_REPORTING 0x80000000L

typedef struct _CONTEXT {
ULONG ContextFlags;
} CONTEXT, *PCONTEXT, *LPCONTEXT;

typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
DWORD none;
} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;

#else
#error Unknown architecture for defining CONTEXT.
Expand Down Expand Up @@ -2600,6 +2620,8 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH
#define PAL_CS_NATIVE_DATA_SIZE 96
#elif defined(__HAIKU__) && defined(__x86_64__)
#define PAL_CS_NATIVE_DATA_SIZE 56
#elif defined(HOST_WASM)
#define PAL_CS_NATIVE_DATA_SIZE 76
#else
#error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
#endif
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/pal/inc/rt/palrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,14 @@ typedef struct _DISPATCHER_CONTEXT {
DWORD Reserved;
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;

#elif defined(HOST_WASM)

typedef struct _DISPATCHER_CONTEXT {
// WASM does not build the VM or JIT at this point,
// so we only provide a dummy definition.
DWORD Reserved;
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;

#else

#error Unknown architecture for defining DISPATCHER_CONTEXT.
Expand Down
32 changes: 21 additions & 11 deletions src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ elseif (CLR_CMAKE_TARGET_FREEBSD)
include_directories(SYSTEM $ENV{ROOTFS_DIR}/usr/local/include)
endif()

if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include)
include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include/tdep)
include_directories(${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include)
Expand All @@ -21,7 +21,7 @@ elseif(NOT CLR_CMAKE_TARGET_APPLE)
find_unwind_libs(UNWIND_LIBS)
else()
add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)

include(configure.cmake)

Expand Down Expand Up @@ -59,6 +59,8 @@ elseif(CLR_CMAKE_HOST_ARCH_S390X)
set(PAL_ARCH_SOURCES_DIR s390x)
elseif(CLR_CMAKE_HOST_ARCH_POWERPC64)
set(PAL_ARCH_SOURCES_DIR ppc64le)
elseif(CLR_CMAKE_HOST_ARCH_WASM)
set(PAL_ARCH_SOURCES_DIR wasm)
endif()

if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
Expand Down Expand Up @@ -113,18 +115,26 @@ endif(CLR_CMAKE_TARGET_HAIKU)
# turn off capability to remove unused functions (which was enabled in debug build with sanitizers)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections")

set(ARCH_SOURCES
arch/${PAL_ARCH_SOURCES_DIR}/context2.S
arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S
arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S
)
if (NOT CLR_CMAKE_TARGET_BROWSER)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (NOT CLR_CMAKE_TARGET_BROWSER)
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)

set(ARCH_SOURCES
arch/${PAL_ARCH_SOURCES_DIR}/context2.S
arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S
arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S
)
endif()

if (CLR_CMAKE_TARGET_BROWSER)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (CLR_CMAKE_TARGET_BROWSER)
if (CLR_CMAKE_TARGET_ARCH_WASM)

set(PLATFORM_SOURCES
arch/${PAL_ARCH_SOURCES_DIR}/stubs.cpp
)
endif()

if(NOT CLR_CMAKE_TARGET_APPLE)
if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_BROWSER)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_BROWSER)
if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM)

list(APPEND PLATFORM_SOURCES
arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S
arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp
)
endif(NOT CLR_CMAKE_TARGET_APPLE)
endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_BROWSER)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_BROWSER)
endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM)


if(CLR_CMAKE_HOST_ARCH_ARM)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down Expand Up @@ -210,9 +220,9 @@ set_source_files_properties(
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../inc/rt
)

if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(LIBUNWIND_OBJECTS $<TARGET_OBJECTS:libunwind>)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)

add_library(coreclrpal
STATIC
Expand Down
69 changes: 69 additions & 0 deletions src/coreclr/pal/src/arch/wasm/stubs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "pal/dbgmsg.h"
Copy link
Member

Choose a reason for hiding this comment

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

License header

#include "pal/signal.hpp"
SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first

/* debugbreak */

extern "C" void
DBG_DebugBreak()
{
asm volatile ("unreachable");
}

/* context */

extern "C" void
RtlCaptureContext(OUT PCONTEXT ContextRecord)
{
_ASSERT("RtlCaptureContext not implemented on wasm");
}

extern "C" void
CONTEXT_CaptureContext(LPCONTEXT lpContext)
{
_ASSERT("CONTEXT_CaptureContext not implemented on wasm");
}

extern "C" void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex)
{
_ASSERT("ThrowExceptionFromContextInternal not implemented on wasm");
}

/* unwind */

void ExecuteHandlerOnCustomStack(int code, siginfo_t *siginfo, void *context, size_t sp, SignalHandlerWorkerReturnPoint* returnPoint)
{
_ASSERT("ExecuteHandlerOnCustomStack not implemented on wasm");
}

extern "C" int unw_getcontext(int)
{
_ASSERT("unw_getcontext not implemented on wasm");
return 0;
}

extern "C" int unw_init_local(int, int)
{
_ASSERT("unw_init_local not implemented on wasm");
return 0;
}

extern "C" int unw_step(int)
{
_ASSERT("unw_step not implemented on wasm");
return 0;
}

extern "C" int unw_is_signal_frame(int)
{
_ASSERT("unw_is_signal_frame not implemented on wasm");
return 0;
}

/* threading */

extern "C" int pthread_setschedparam(pthread_t, int, const struct sched_param *)
{
_ASSERT("pthread_setschedparam not implemented on wasm");
return 0;
}
3 changes: 3 additions & 0 deletions src/coreclr/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,9 @@ elseif(CLR_CMAKE_TARGET_HAIKU)
# Haiku does not have ptrace.
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
set(HAVE_SCHED_OTHER_ASSIGNABLE 1)
elseif(CLR_CMAKE_TARGET_BROWSER)
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
set(HAVE_SCHED_OTHER_ASSIGNABLE 0)
else() # Anything else is Linux
# LTTNG is not available on Android, so don't error out
if(NOT HAVE_LTTNG_TRACEPOINT_H AND NOT CLR_CMAKE_TARGET_ANDROID AND FEATURE_EVENT_TRACE)
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/pal/src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ This is a no-op for x86 architectures where the instruction and data
caches are coherent in hardware. For non-X86 architectures, this call
usually maps to a kernel API to flush the D-caches on all processors.

It is also no-op on wasm. We don't have a way to flush the instruction
cache and it is also not needed.

--*/
BOOL
PALAPI
Expand Down Expand Up @@ -422,7 +425,12 @@ DebugBreak(
BOOL
IsInDebugBreak(void *addr)
{
#if defined (__wasm__)
_ASSERT("IsInDebugBreak not implemented on wasm");
return false;
#else
return (addr >= (void *)DBG_DebugBreak) && (addr <= (void *)DBG_DebugBreak_End);
#endif
}

/*++
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/pal/src/exception/seh-unwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
unw_get_reg(cursor, UNW_PPC64_R28, (unw_word_t *) &winContext->R28);
unw_get_reg(cursor, UNW_PPC64_R29, (unw_word_t *) &winContext->R29);
unw_get_reg(cursor, UNW_PPC64_R30, (unw_word_t *) &winContext->R30);
#elif defined(HOST_WASM)
ASSERT("UnwindContextToWinContext not implemented for WASM");
#else
#error unsupported architecture
#endif
Expand Down Expand Up @@ -631,6 +633,8 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL
GetContextPointer(cursor, unwContext, UNW_PPC64_R29, (SIZE_T **)&contextPointers->R29);
GetContextPointer(cursor, unwContext, UNW_PPC64_R30, (SIZE_T **)&contextPointers->R30);
GetContextPointer(cursor, unwContext, UNW_PPC64_R31, (SIZE_T **)&contextPointers->R31);
#elif defined(HOST_WASM)
ASSERT("GetContextPointers not implemented for WASM");
#else
#error unsupported architecture
#endif
Expand Down
Loading
Loading