Skip to content

Commit 11408ab

Browse files
radekdoulikkglewingjkotas
authored
[wasm] build paltests (#112404)
* Make configure pass for wasm and paltests component Disable few parts, some might need closer look later. * Fix compilation and linking on wasm * Ignore limits and dlopen(nullptr, ...) on wasm * Do not return 0 for minipal_get_current_thread_id on wasm * Add simple index.html to run paltests on wasm in browser * Forward console log and error to http server * Enable debug output temporarily * Do not create synchronization manager worker thread on wasm And also skip creating pipe to communicate with it * Temporarily override main args on wasm to simplify testing * Prototype pal test suite runner * Reload between tests to work around stack exhaustion * Shorter delay between tests; logging of exit code specifies which test it was so you can pull the test statuses out of a log file * Add mechanism for disabling tests and disable the debug_api tests * Disable another set of tests * Disable more tests and reduce run delay * Full test run completes now * Use exit runtime option To avoid error messages at the end of each run * Add summary with counts of passed, failed and disabled tests * Trap on assert to stop * Filter the tests, use paltestlist.txt as runpaltests.sh Also write missing tests * Don't output when capturing tests Also fix disabled tests count * Add notes to failing tests * Make flush instruction cache no-op on wasm, disable few MT tests * Reenable debug_api test, which is not failing Add few more notes to failing memory related tests * Do not call mmap to re-set memory protection Emscripten's mmap doesn't support that and because we don't have virtual memory in wasm, it doesn't make sense to call it there * Disable 3 exception_handling/RaiseException tests Also re-enable debug test, which works and disable few MT tests * Disable paltest_probememory_probememory_neg1 * Disable dll tests on wasm * Fix cmake warnings * Install the additional files for wasm * Use onExit instead of quit This fixes issue with newer emscripten, where Module['quit'] handling is removed. Also fix single test runs. * Add mono.emsdk subset * Remove forgotten check * Update msbuild targets to allow build of wasm paltests * Add CI build and temporarily disable all other runtime builds to save resources * Fix remaining conflict * Fix build afer merge with main * Make membarrier noop on wasm * Change subsets build order * Disable fs test which fails with chromedriver * Fix InternalCanonicalizeRealPath corner case that affects wasm pal tests * Zero memory for MEM_DECOMMIT on WASM instead of just doing nothing, to at least get slightly closer to intended behavior * Removed notes about the failing tests * Fix few new cmake warnings * Put runtime runs back * Remove unwanted changes * List disabled and failed tests when the run completed * Fix mono wasm/MT build * Remove unwanted fields Co-authored-by: Jan Kotas <[email protected]> * Fix mono wasm/MT build once more * Fix windows build * Fix windows build * Feedback * More feedback * More feedback * More feedback * Feedback * Fix cmake warning * Update src/coreclr/pal/src/CMakeLists.txt Co-authored-by: Jan Kotas <[email protected]> * Update src/coreclr/pal/src/CMakeLists.txt Co-authored-by: Jan Kotas <[email protected]> * Update src/coreclr/pal/src/CMakeLists.txt Co-authored-by: Jan Kotas <[email protected]> * Update src/coreclr/pal/src/CMakeLists.txt Co-authored-by: Jan Kotas <[email protected]> * Feedback --------- Co-authored-by: Katelyn Gadd <[email protected]> Co-authored-by: Larry Ewing <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
1 parent c6a3984 commit 11408ab

File tree

38 files changed

+475
-38
lines changed

38 files changed

+475
-38
lines changed

eng/Subsets.props

+7-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
<!-- Mono -->
208208
<SubsetName Include="Mono" Description="The Mono runtime and CoreLib. Equivalent to: $(DefaultMonoSubsets)" />
209209
<SubsetName Include="Mono.Runtime" Description="The Mono .NET runtime." />
210+
<SubsetName Include="Mono.EmSDK" Description="The emsdk provisioning." />
210211
<SubsetName Include="Mono.AotCross" Description="The cross-compiler runtime for Mono AOT." />
211212
<SubsetName Include="Mono.CoreLib" Description="The managed System.Private.CoreLib library for Mono." />
212213
<SubsetName Include="Mono.Manifests" Description="The NuGet packages with manifests defining the mobile and Blazor workloads." />
@@ -264,6 +265,11 @@
264265
</ProjectToBuild>
265266
</ItemDefinitionGroup>
266267

268+
<!-- emscripten provisioning, needs to be placed before runtime projects -->
269+
<ItemGroup Condition="$(_subset.Contains('+mono.emsdk+'))">
270+
<ProjectToBuild Include="$(MonoProjectRoot)mono.proj" AdditionalProperties="%(AdditionalProperties);ProvisionEmscriptenOnly=true" Category="mono" />
271+
</ItemGroup>
272+
267273
<!-- CoreClr sets -->
268274
<ItemGroup Condition="$(_subset.Contains('+clr.corelib+'))">
269275
<ProjectToBuild Include="$(CoreClrProjectRoot)System.Private.CoreLib\System.Private.CoreLib.csproj" Category="clr" />
@@ -325,7 +331,7 @@
325331
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.
326332
-->
327333
<PropertyGroup>
328-
<_BuildAnyCrossArch Condition="'$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != ''">true</_BuildAnyCrossArch>
334+
<_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetArchitecture)' != 'wasm'">true</_BuildAnyCrossArch>
329335
<_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true</_BuildCrossComponents>
330336
<_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true</_BuildCrossComponents>
331337
<_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true</_CrossBitwidthBuild>

eng/pipelines/runtime.yml

+15
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ extends:
117117
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
118118
eq(variables['isRollingBuild'], true))
119119
120+
- template: /eng/pipelines/common/platform-matrix.yml
121+
parameters:
122+
jobTemplate: /eng/pipelines/common/global-build-job.yml
123+
buildConfig: ${{ variables.debugOnPrReleaseOnRolling }}
124+
platforms:
125+
- browser_wasm
126+
jobParameters:
127+
nameSuffix: AllSubsets_CoreCLR
128+
buildArgs: -s mono.emsdk+clr.paltests -rc Release -c Release -lc $(_BuildConfig)
129+
timeoutInMinutes: 120
130+
condition: >-
131+
or(
132+
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_non_mono_and_wasm.containsChange'], true),
133+
eq(variables['isRollingBuild'], true))
134+
120135
#
121136
# Build CoreCLR and Libraries with Libraries tests
122137
# For running libraries tests and installer tests

src/coreclr/CMakeLists.txt

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if(CORECLR_SET_RPATH)
2929
set(MACOSX_RPATH ON)
3030
endif(CORECLR_SET_RPATH)
3131

32-
if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS)
32+
if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_BROWSER)
3333
set(FEATURE_STANDALONE_GC 0)
3434
endif()
3535

@@ -148,8 +148,9 @@ endif()
148148
include_directories("pal/prebuilt/inc")
149149
include_directories(${CLR_ARTIFACTS_OBJ_DIR})
150150

151-
add_subdirectory(tools/aot/jitinterface)
152-
151+
if (NOT CLR_CMAKE_TARGET_BROWSER)
152+
add_subdirectory(tools/aot/jitinterface)
153+
endif (NOT CLR_CMAKE_TARGET_BROWSER)
153154

154155
if(NOT CLR_CROSS_COMPONENTS_BUILD)
155156
# NativeAOT only buildable for a subset of CoreCLR-supported configurations
@@ -262,7 +263,7 @@ if(CLR_CMAKE_HOST_UNIX)
262263
add_subdirectory(nativeresources)
263264
endif(CLR_CMAKE_HOST_UNIX)
264265

265-
if(NOT CLR_CMAKE_HOST_TVOS)
266+
if(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)
266267
add_subdirectory(utilcode)
267268
add_subdirectory(inc)
268269

@@ -280,7 +281,7 @@ if(NOT CLR_CMAKE_HOST_TVOS)
280281
add_subdirectory(dlls)
281282
add_subdirectory(unwinder)
282283
add_subdirectory(interop)
283-
endif()
284+
endif(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)
284285

285286
if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
286287
add_subdirectory(tools)

src/coreclr/clrfeatures.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
33
endif()
44

55
if(NOT DEFINED FEATURE_EVENT_TRACE)
6-
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
7-
set(FEATURE_EVENT_TRACE 1)
6+
if (NOT CLR_CMAKE_TARGET_BROWSER)
7+
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
8+
set(FEATURE_EVENT_TRACE 1)
9+
endif()
810
endif(NOT DEFINED FEATURE_EVENT_TRACE)
911

1012
if(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)

src/coreclr/inc/volatile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#error The Volatile type is currently only defined for Visual C++ and GNU C++
6969
#endif
7070

71-
#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)
71+
#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)
7272
#error The Volatile type is currently only defined for GCC when targeting x86, AMD64, ARM, ARM64, LOONGARCH64, RISCV64, PPC64LE, or S390X CPUs
7373
#endif
7474

src/coreclr/interpreter/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ else()
2828
add_custom_target(interpreter_exports DEPENDS ${EXPORTS_FILE})
2929
endif()
3030

31-
add_library_clr(clrinterpreter SHARED ${INTERPRETER_SOURCES})
31+
if(CLR_CMAKE_TARGET_BROWSER)
32+
set(LIBRARY_TYPE STATIC)
33+
else()
34+
set(LIBRARY_TYPE SHARED)
35+
endif()
36+
37+
add_library_clr(clrinterpreter ${LIBRARY_TYPE} ${INTERPRETER_SOURCES})
3238

3339
add_dependencies(clrinterpreter interpreter_exports)
3440

src/coreclr/jit/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ elseif(CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
495495
elseif(CLR_CMAKE_TARGET_ARCH_RISCV64)
496496
set(JIT_ARCH_SOURCES ${JIT_RISCV64_SOURCES})
497497
set(JIT_ARCH_HEADERS ${JIT_RISCV64_HEADERS})
498+
elseif(CLR_CMAKE_TARGET_ARCH_WASM)
499+
set(JIT_ARCH_SOURCES ${JIT_WASM32_SOURCES})
500+
set(JIT_ARCH_HEADERS ${JIT_WASM32_HEADERS})
498501
else()
499502
clr_unknown_arch()
500503
endif()

src/coreclr/pal/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ include_directories(${COREPAL_SOURCE_DIR}/inc)
66
include_directories(${COREPAL_SOURCE_DIR}/src)
77
include_directories(${COREPAL_SOURCE_DIR}/../inc)
88

9-
add_compile_options(-fexceptions)
9+
if (NOT CLR_CMAKE_TARGET_BROWSER)
10+
add_compile_options(-fexceptions)
11+
else()
12+
add_compile_options(-fwasm-exceptions)
13+
add_link_options(-fwasm-exceptions -sEXIT_RUNTIME=1)
14+
endif()
1015

1116
add_subdirectory(src)
1217
add_subdirectory(tests)

src/coreclr/pal/inc/pal.h

+22
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,26 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
24692469
//
24702470

24712471
} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
2472+
#elif defined(HOST_WASM)
2473+
#define CONTEXT_CONTROL 0
2474+
#define CONTEXT_INTEGER 0
2475+
#define CONTEXT_FLOATING_POINT 0
2476+
#define CONTEXT_FULL 0
2477+
2478+
#define CONTEXT_XSTATE 0
2479+
2480+
#define CONTEXT_EXCEPTION_ACTIVE 0x8000000L
2481+
#define CONTEXT_SERVICE_ACTIVE 0x10000000L
2482+
#define CONTEXT_EXCEPTION_REQUEST 0x40000000L
2483+
#define CONTEXT_EXCEPTION_REPORTING 0x80000000L
2484+
2485+
typedef struct _CONTEXT {
2486+
ULONG ContextFlags;
2487+
} CONTEXT, *PCONTEXT, *LPCONTEXT;
2488+
2489+
typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2490+
DWORD none;
2491+
} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
24722492

24732493
#else
24742494
#error Unknown architecture for defining CONTEXT.
@@ -2600,6 +2620,8 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH
26002620
#define PAL_CS_NATIVE_DATA_SIZE 96
26012621
#elif defined(__HAIKU__) && defined(__x86_64__)
26022622
#define PAL_CS_NATIVE_DATA_SIZE 56
2623+
#elif defined(HOST_WASM)
2624+
#define PAL_CS_NATIVE_DATA_SIZE 76
26032625
#else
26042626
#error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
26052627
#endif

src/coreclr/pal/inc/rt/palrt.h

+8
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,14 @@ typedef struct _DISPATCHER_CONTEXT {
10031003
DWORD Reserved;
10041004
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
10051005

1006+
#elif defined(HOST_WASM)
1007+
1008+
typedef struct _DISPATCHER_CONTEXT {
1009+
// WASM does not build the VM or JIT at this point,
1010+
// so we only provide a dummy definition.
1011+
DWORD Reserved;
1012+
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
1013+
10061014
#else
10071015

10081016
#error Unknown architecture for defining DISPATCHER_CONTEXT.

src/coreclr/pal/src/CMakeLists.txt

+21-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ elseif (CLR_CMAKE_TARGET_FREEBSD)
1010
include_directories(SYSTEM $ENV{ROOTFS_DIR}/usr/local/include)
1111
endif()
1212

13-
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
13+
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
1414
include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include)
1515
include_directories(${CLR_SRC_NATIVE_DIR}/external/libunwind/include/tdep)
1616
include_directories(${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include)
@@ -21,7 +21,7 @@ elseif(NOT CLR_CMAKE_TARGET_APPLE)
2121
find_unwind_libs(UNWIND_LIBS)
2222
else()
2323
add_subdirectory(${CLR_SRC_NATIVE_DIR}/external/libunwind_extras ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind)
24-
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
24+
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
2525

2626
include(configure.cmake)
2727

@@ -59,6 +59,8 @@ elseif(CLR_CMAKE_HOST_ARCH_S390X)
5959
set(PAL_ARCH_SOURCES_DIR s390x)
6060
elseif(CLR_CMAKE_HOST_ARCH_POWERPC64)
6161
set(PAL_ARCH_SOURCES_DIR ppc64le)
62+
elseif(CLR_CMAKE_HOST_ARCH_WASM)
63+
set(PAL_ARCH_SOURCES_DIR wasm)
6264
endif()
6365

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

116-
set(ARCH_SOURCES
117-
arch/${PAL_ARCH_SOURCES_DIR}/context2.S
118-
arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S
119-
arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S
120-
)
118+
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
119+
set(ARCH_SOURCES
120+
arch/${PAL_ARCH_SOURCES_DIR}/context2.S
121+
arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S
122+
arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S
123+
)
124+
endif()
125+
126+
if (CLR_CMAKE_TARGET_ARCH_WASM)
127+
set(PLATFORM_SOURCES
128+
arch/${PAL_ARCH_SOURCES_DIR}/stubs.cpp
129+
)
130+
endif()
121131

122-
if(NOT CLR_CMAKE_TARGET_APPLE)
132+
if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
123133
list(APPEND PLATFORM_SOURCES
124134
arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S
125135
arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp
126136
)
127-
endif(NOT CLR_CMAKE_TARGET_APPLE)
137+
endif(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
128138

129139
if(CLR_CMAKE_HOST_ARCH_ARM)
130140
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@@ -210,9 +220,9 @@ set_source_files_properties(
210220
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../inc/rt
211221
)
212222

213-
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
223+
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
214224
set(LIBUNWIND_OBJECTS $<TARGET_OBJECTS:libunwind>)
215-
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
225+
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
216226

217227
add_library(coreclrpal
218228
STATIC
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#include "pal/dbgmsg.h"
5+
#include "pal/signal.hpp"
6+
7+
SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first
8+
9+
/* debugbreak */
10+
11+
extern "C" void
12+
DBG_DebugBreak()
13+
{
14+
asm volatile ("unreachable");
15+
}
16+
17+
/* context */
18+
19+
extern "C" void
20+
RtlCaptureContext(OUT PCONTEXT ContextRecord)
21+
{
22+
_ASSERT("RtlCaptureContext not implemented on wasm");
23+
}
24+
25+
extern "C" void
26+
CONTEXT_CaptureContext(LPCONTEXT lpContext)
27+
{
28+
_ASSERT("CONTEXT_CaptureContext not implemented on wasm");
29+
}
30+
31+
extern "C" void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex)
32+
{
33+
_ASSERT("ThrowExceptionFromContextInternal not implemented on wasm");
34+
}
35+
36+
/* unwind */
37+
38+
void ExecuteHandlerOnCustomStack(int code, siginfo_t *siginfo, void *context, size_t sp, SignalHandlerWorkerReturnPoint* returnPoint)
39+
{
40+
_ASSERT("ExecuteHandlerOnCustomStack not implemented on wasm");
41+
}
42+
43+
extern "C" int unw_getcontext(int)
44+
{
45+
_ASSERT("unw_getcontext not implemented on wasm");
46+
return 0;
47+
}
48+
49+
extern "C" int unw_init_local(int, int)
50+
{
51+
_ASSERT("unw_init_local not implemented on wasm");
52+
return 0;
53+
}
54+
55+
extern "C" int unw_step(int)
56+
{
57+
_ASSERT("unw_step not implemented on wasm");
58+
return 0;
59+
}
60+
61+
extern "C" int unw_is_signal_frame(int)
62+
{
63+
_ASSERT("unw_is_signal_frame not implemented on wasm");
64+
return 0;
65+
}
66+
67+
/* threading */
68+
69+
extern "C" int pthread_setschedparam(pthread_t, int, const struct sched_param *)
70+
{
71+
_ASSERT("pthread_setschedparam not implemented on wasm");
72+
return 0;
73+
}

src/coreclr/pal/src/configure.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,9 @@ elseif(CLR_CMAKE_TARGET_HAIKU)
937937
# Haiku does not have ptrace.
938938
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
939939
set(HAVE_SCHED_OTHER_ASSIGNABLE 1)
940+
elseif(CLR_CMAKE_TARGET_BROWSER)
941+
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
942+
set(HAVE_SCHED_OTHER_ASSIGNABLE 0)
940943
else() # Anything else is Linux
941944
# LTTNG is not available on Android, so don't error out
942945
if(NOT HAVE_LTTNG_TRACEPOINT_H AND NOT CLR_CMAKE_TARGET_ANDROID AND FEATURE_EVENT_TRACE)

src/coreclr/pal/src/debug/debug.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ This is a no-op for x86 architectures where the instruction and data
111111
caches are coherent in hardware. For non-X86 architectures, this call
112112
usually maps to a kernel API to flush the D-caches on all processors.
113113
114+
It is also no-op on wasm. We don't have a way to flush the instruction
115+
cache and it is also not needed.
116+
114117
--*/
115118
BOOL
116119
PALAPI
@@ -422,7 +425,12 @@ DebugBreak(
422425
BOOL
423426
IsInDebugBreak(void *addr)
424427
{
428+
#if defined (__wasm__)
429+
_ASSERT("IsInDebugBreak not implemented on wasm");
430+
return false;
431+
#else
425432
return (addr >= (void *)DBG_DebugBreak) && (addr <= (void *)DBG_DebugBreak_End);
433+
#endif
426434
}
427435

428436
/*++

src/coreclr/pal/src/exception/seh-unwind.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
497497
unw_get_reg(cursor, UNW_PPC64_R28, (unw_word_t *) &winContext->R28);
498498
unw_get_reg(cursor, UNW_PPC64_R29, (unw_word_t *) &winContext->R29);
499499
unw_get_reg(cursor, UNW_PPC64_R30, (unw_word_t *) &winContext->R30);
500+
#elif defined(HOST_WASM)
501+
ASSERT("UnwindContextToWinContext not implemented for WASM");
500502
#else
501503
#error unsupported architecture
502504
#endif
@@ -631,6 +633,8 @@ void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOL
631633
GetContextPointer(cursor, unwContext, UNW_PPC64_R29, (SIZE_T **)&contextPointers->R29);
632634
GetContextPointer(cursor, unwContext, UNW_PPC64_R30, (SIZE_T **)&contextPointers->R30);
633635
GetContextPointer(cursor, unwContext, UNW_PPC64_R31, (SIZE_T **)&contextPointers->R31);
636+
#elif defined(HOST_WASM)
637+
ASSERT("GetContextPointers not implemented for WASM");
634638
#else
635639
#error unsupported architecture
636640
#endif

0 commit comments

Comments
 (0)