Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
b32ad25
[wasm][coreclr] Get further in the runtime initialization
radekdoulik Jun 6, 2025
790712a
Fix condition
radekdoulik Jun 9, 2025
0036748
Fix build
radekdoulik Jun 9, 2025
788fecf
Update after merge
radekdoulik Jun 9, 2025
0119876
Feedback
radekdoulik Jun 9, 2025
9605e64
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jun 10, 2025
43c83fd
Update after merge
radekdoulik Jun 10, 2025
70b06c5
Fix release build offsets
radekdoulik Jun 10, 2025
51f0214
Build Debug runtime configuration on CI, so that interpreter is enabled
radekdoulik Jun 10, 2025
c667e6c
Fix build
radekdoulik Jun 10, 2025
e45f726
Enable interpreter in all configuration on wasm
radekdoulik Jun 10, 2025
3470ff4
Merge branch 'main' into wasm-coreclr-wip-3-squashed
radekdoulik Jun 10, 2025
91f336c
Build in Release again as we are missing debug packages
radekdoulik Jun 10, 2025
f9a0339
Move inline keyword
radekdoulik Jun 11, 2025
2df11b1
Feedback
radekdoulik Jun 11, 2025
556e5fa
Feedback
radekdoulik Jun 13, 2025
5032d37
Fix release build
radekdoulik Jun 13, 2025
c61d5a3
Feedback
radekdoulik Jun 13, 2025
15e1d83
Feedback
radekdoulik Jun 13, 2025
86efb1c
Feedback
radekdoulik Jun 13, 2025
01563ca
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jun 13, 2025
c6da89e
Feedback
radekdoulik Jun 13, 2025
d1eb90a
Feedback
radekdoulik Jun 14, 2025
063fc3b
Feedback, add FEATURE_PEIMAGE_FLAT_LAYOUT
radekdoulik Jun 16, 2025
22acc25
Revert mapping changes for PE loaded layout
radekdoulik Jun 16, 2025
c93a61b
Feedback, change call order of execute interp method
radekdoulik Jun 16, 2025
406594a
Feedback, change condition to avoid dynamic loads in corhost
radekdoulik Jun 16, 2025
34a6179
Merge branch 'main' into wasm-coreclr-wip-3-squashed
radekdoulik Jun 16, 2025
3c58f83
Increase stub size to fit interpreter stub data
radekdoulik Jun 17, 2025
caec182
Update precode sizes, feedback and size check
radekdoulik Jun 17, 2025
9a761d7
Feedback, TODO, transition block
radekdoulik Jun 18, 2025
dda8b41
Feedback
radekdoulik Jun 18, 2025
ee63503
Use coreclr_static library for wasm
radekdoulik Jun 20, 2025
ebc8f45
Feedback
radekdoulik Jun 22, 2025
18e25e4
Feedback
radekdoulik Jun 22, 2025
6ca105c
Write barriers helper updated
radekdoulik Jun 22, 2025
542d732
Write barriers helper updated
radekdoulik Jun 22, 2025
f907a4d
Feedback
radekdoulik Jun 22, 2025
f5c3500
Make InitJITWriteBarrierHelpers no-op on wasm
radekdoulik Jun 22, 2025
2bdc376
Feedback
radekdoulik Jun 22, 2025
c3ca64a
Feedback
radekdoulik Jun 23, 2025
efd8722
Feedback
radekdoulik Jun 23, 2025
fb6f747
Feedback
radekdoulik Jun 23, 2025
13b945a
Feedback
radekdoulik Jun 24, 2025
da2b405
Feedback
radekdoulik Jun 24, 2025
7c912c5
Feedback
radekdoulik Jun 24, 2025
bd16e77
Feedback
radekdoulik Jun 24, 2025
035332b
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jun 24, 2025
defe297
Fix build
radekdoulik Jun 24, 2025
ef5b327
Fix non-wasm build
radekdoulik Jun 25, 2025
a7ef899
Merge branch 'main' into wasm-coreclr-wip-3-squashed
radekdoulik Jun 25, 2025
71643ec
Feedback
radekdoulik Jun 25, 2025
2aa639f
Feedback
radekdoulik Jul 7, 2025
0226bf8
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jul 7, 2025
bcc8051
Feedback
radekdoulik Jul 8, 2025
19d1e78
Feedback
radekdoulik Jul 8, 2025
897ac1c
Merge branch 'main' into wasm-coreclr-wip-3-squashed
radekdoulik Jul 8, 2025
a5d3c97
Feedback
radekdoulik Jul 10, 2025
9f26f89
Feedback
radekdoulik Jul 10, 2025
e811fbe
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jul 14, 2025
9f26ea7
Add comment
radekdoulik Jul 14, 2025
3afb7ae
Merge branch 'main' into wasm-coreclr-wip-3-squashed
radekdoulik Jul 14, 2025
fdb56bc
Feedback
radekdoulik Jul 18, 2025
7a556e6
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jul 18, 2025
7c27915
Fix build
radekdoulik Jul 18, 2025
4a2f57a
Feedback
radekdoulik Jul 23, 2025
3eae3d7
Feedback
radekdoulik Jul 23, 2025
c2ecb47
Fix whitespace
radekdoulik Jul 23, 2025
a9df639
Prefer TARGET_WASM
radekdoulik Jul 23, 2025
ca1ce47
Update src/coreclr/pal/src/init/pal.cpp
radekdoulik Jul 23, 2025
17d9952
Prefer TARGET_WASM
radekdoulik Jul 23, 2025
1e2246f
Prefer TARGET_WASM
radekdoulik Jul 23, 2025
2ba3bc8
Merge remote-tracking branch 'remotes/origin/main' into wasm-coreclr-…
radekdoulik Jul 23, 2025
52dd3d2
Few more places to use more general TARGET_WASM
radekdoulik Jul 23, 2025
4f6f578
Prefer TARGET_WASM
radekdoulik Jul 23, 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
4 changes: 4 additions & 0 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ if (DEFINED CLR_CMAKE_ICU_DIR)
include_directories(${CLR_CMAKE_ICU_DIR}/include)
endif(DEFINED CLR_CMAKE_ICU_DIR)

if (CLR_CMAKE_TARGET_ARCH_WASM)
add_compile_options(-fwasm-exceptions)
endif()

#----------------------------------------------------
# Cross target Component build specific configuration
#----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class AsmOffsets
public const int OFFSETOF__REGDISPLAY__SP = 0xba8;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0xbb0;
#elif TARGET_WASM
public const int SIZEOF__REGDISPLAY = 0x3c;
public const int OFFSETOF__REGDISPLAY__SP = 0x34;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0x38;
public const int SIZEOF__REGDISPLAY = 0x38;
public const int OFFSETOF__REGDISPLAY__SP = 0x30;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0x34;
#endif

#if TARGET_64BIT
Expand All @@ -73,9 +73,14 @@ class AsmOffsets
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x3d0;
#else // TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
#if FEATURE_INTERPRETER
public const int SIZEOF__StackFrameIterator = 0xdc;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0xd8;
#else
public const int SIZEOF__StackFrameIterator = 0xcc;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0xba;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0xc8;
#endif
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0xba;
#endif // TARGET_64BIT

#else // DEBUG
Expand Down Expand Up @@ -117,9 +122,9 @@ class AsmOffsets
public const int OFFSETOF__REGDISPLAY__SP = 0xba0;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0xba8;
#elif TARGET_WASM
public const int SIZEOF__REGDISPLAY = 0x3c;
public const int OFFSETOF__REGDISPLAY__SP = 0x34;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0x38;
public const int SIZEOF__REGDISPLAY = 0x34;
public const int OFFSETOF__REGDISPLAY__SP = 0x2c;
public const int OFFSETOF__REGDISPLAY__ControlPC = 0x30;
#endif

#if TARGET_64BIT
Expand All @@ -139,9 +144,14 @@ class AsmOffsets
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x3c8;
#else // TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
#if FEATURE_INTERPRETER
public const int SIZEOF__StackFrameIterator = 0xd4;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0xd0;
#else
public const int SIZEOF__StackFrameIterator = 0xc4;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0xb2;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0xc0;
#endif
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0xb2;
#endif // TARGET_64BIT

#endif // DEBUG
Expand All @@ -167,7 +177,7 @@ class AsmOffsets
#elif TARGET_LOONGARCH64
public const int SIZEOF__PAL_LIMITED_CONTEXT = 0x520;
#elif TARGET_WASM
public const int SIZEOF__PAL_LIMITED_CONTEXT = 0x08;
public const int SIZEOF__PAL_LIMITED_CONTEXT = 0x04;
#endif

#if TARGET_AMD64
Expand Down
16 changes: 9 additions & 7 deletions src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ endif(NOT DEFINED FEATURE_DBGIPC)

if(NOT DEFINED FEATURE_INTERPRETER)
if(CLR_CMAKE_TARGET_ANDROID)
set(FEATURE_INTERPRETER 0)
set(FEATURE_INTERPRETER 0)
elseif(CLR_CMAKE_TARGET_ARCH_WASM)
set(FEATURE_INTERPRETER 1)
else()
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
set(FEATURE_INTERPRETER $<IF:$<CONFIG:Debug,Checked>,1,0>)
else(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
set(FEATURE_INTERPRETER 0)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
set(FEATURE_INTERPRETER $<IF:$<CONFIG:Debug,Checked>,1,0>)
else(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
set(FEATURE_INTERPRETER 0)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
endif()
endif(NOT DEFINED FEATURE_INTERPRETER)

Expand All @@ -54,7 +56,7 @@ if(NOT DEFINED FEATURE_SINGLE_FILE_DIAGNOSTICS)
set(FEATURE_SINGLE_FILE_DIAGNOSTICS 1)
endif(NOT DEFINED FEATURE_SINGLE_FILE_DIAGNOSTICS)

if (CLR_CMAKE_TARGET_WIN32 OR CLR_CMAKE_TARGET_UNIX)
if ((CLR_CMAKE_TARGET_WIN32 OR CLR_CMAKE_TARGET_UNIX) AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(FEATURE_COMWRAPPERS 1)
endif()

Expand Down
61 changes: 41 additions & 20 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,36 @@ endif (CLR_CMAKE_HOST_WIN32)

add_definitions(-DFX_VER_INTERNALNAME_STR=CoreCLR.dll)

add_library_clr(coreclr
SHARED
${CLR_SOURCES}
)
if (NOT CLR_CMAKE_HOST_ARCH_WASM)
add_library_clr(coreclr
SHARED
${CLR_SOURCES}
)

add_custom_target(coreclr_exports DEPENDS ${EXPORTS_FILE})
add_custom_target(coreclr_def DEPENDS ${DEF_FILE})
add_custom_target(coreclr_exports DEPENDS ${EXPORTS_FILE})
add_custom_target(coreclr_def DEPENDS ${DEF_FILE})

add_dependencies(coreclr coreclr_def)
add_dependencies(coreclr coreclr_exports)
add_dependencies(coreclr coreclr_def)
add_dependencies(coreclr coreclr_exports)

set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
set(LIB_CORDBEE cordbee_wks)
set(LIB_INTEROP interop)
set(LIB_CDAC_CONTRACT_DESCRIPTOR cdac_contract_descriptor)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

if (CLR_CMAKE_HOST_UNIX)
if (CLR_CMAKE_HOST_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(LIB_UNWINDER unwinder_wks)
endif (CLR_CMAKE_HOST_UNIX)
endif (CLR_CMAKE_HOST_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)

# IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is
# order dependent and changing the order can result in undefined symbols in the shared
# library.
set(CORECLR_LIBRARIES
utilcode
${START_LIBRARY_GROUP} # Start group of libraries that have circular references
cordbee_wks
${LIB_CORDBEE}
debug-pal
${LIB_UNWINDER}
v3binder
Expand All @@ -95,10 +100,10 @@ set(CORECLR_LIBRARIES
utilcode
v3binder
System.Globalization.Native-Static
interop
${LIB_INTEROP}
coreclrminipal
gc_pal
cdac_contract_descriptor
${LIB_CDAC_CONTRACT_DESCRIPTOR}
)

if(CLR_CMAKE_TARGET_ARCH_AMD64)
Expand Down Expand Up @@ -172,12 +177,25 @@ if(FEATURE_STATICALLY_LINKED)
set(CLRJIT_STATIC clrjit_static)
endif(FEATURE_STATICALLY_LINKED)

if(FEATURE_JIT)
set(CORECLR_STATIC_CLRJIT_STATIC clrjit_static)
endif(FEATURE_JIT)

if(NOT CLR_CMAKE_HOST_ARCH_WASM)
set(CEE_WKS_STATIC cee_wks_mergeable)
else()
set(CEE_WKS_STATIC cee_wks)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

if (CLR_CMAKE_TARGET_OSX)
find_library(FOUNDATION Foundation REQUIRED)
endif()

target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks_core cee_wks ${FOUNDATION})
target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} cee_wks_core clrjit_static cee_wks_mergeable ${FOUNDATION})
if(NOT CLR_CMAKE_HOST_ARCH_WASM)
target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks_core cee_wks ${FOUNDATION})
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} cee_wks_core ${CORECLR_STATIC_CLRJIT_STATIC} ${CEE_WKS_STATIC} ${FOUNDATION})
target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED)

if (CLR_CMAKE_HOST_ANDROID)
Expand Down Expand Up @@ -227,10 +245,13 @@ if(CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_WIN32)

# add the install targets
install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime)
if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID)
if(NOT CLR_CMAKE_HOST_ARCH_WASM)
install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_ARCH_WASM)
install_clr(TARGETS coreclr_static DESTINATIONS . sharedFramework COMPONENT runtime)
endif(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID)
endif(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_ARCH_WASM)

# Enable profile guided optimization
add_pgo(coreclr)
13 changes: 10 additions & 3 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool GCToOSInterface::Initialize()
//
// support for FlusProcessWriteBuffers
//

#ifndef TARGET_WASM
assert(s_flushUsingMemBarrier == 0);

if (CanFlushUsingMembarrier())
Expand Down Expand Up @@ -262,6 +262,7 @@ bool GCToOSInterface::Initialize()
}
}
#endif // !TARGET_APPLE
#endif // !TARGET_WASM

InitializeCGroup();

Expand Down Expand Up @@ -412,6 +413,7 @@ bool GCToOSInterface::CanGetCurrentProcessorNumber()
// Flush write buffers of processors that are executing threads of the current process
void GCToOSInterface::FlushProcessWriteBuffers()
{
#ifndef TARGET_WASM
#if defined(__linux__) || HAVE_SYS_MEMBARRIER_H
if (s_flushUsingMemBarrier)
{
Expand Down Expand Up @@ -490,6 +492,7 @@ void GCToOSInterface::FlushProcessWriteBuffers()
CHECK_MACH("vm_deallocate()", machret);
}
#endif // TARGET_APPLE
#endif // !TARGET_WASM
}

// Break into a debugger. Uses a compiler intrinsic if one is available,
Expand Down Expand Up @@ -576,7 +579,7 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags,
}

pRetVal = pAlignedRetVal;
#ifdef MADV_DONTDUMP
#if defined(MADV_DONTDUMP) && !defined(TARGET_WASM)
// Do not include reserved uncommitted memory in coredump.
if (!committing)
{
Expand Down Expand Up @@ -624,9 +627,13 @@ bool GCToOSInterface::VirtualRelease(void* address, size_t size)
// true if it has succeeded, false if it has failed
static bool VirtualCommitInner(void* address, size_t size, uint16_t node, bool newMemory)
{
#ifndef TARGET_WASM
bool success = mprotect(address, size, PROT_WRITE | PROT_READ) == 0;
#else
bool success = true;
#endif // !TARGET_WASM

#ifdef MADV_DODUMP
#if defined(MADV_DONTDUMP) && !defined(TARGET_WASM)
if (success && !newMemory)
{
// Include committed memory in coredump. New memory is included by default.
Expand Down
12 changes: 8 additions & 4 deletions src/coreclr/hosts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
include_directories(inc)

if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(coreshim)
endif(CLR_CMAKE_HOST_WIN32)
if (CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(corewasmrun)
else()
if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(coreshim)
endif(CLR_CMAKE_HOST_WIN32)

add_subdirectory(corerun)
add_subdirectory(corerun)
endif()
28 changes: 28 additions & 0 deletions src/coreclr/hosts/corewasmrun/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
project(corewasmrun)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

if (DEFINED CLR_CMAKE_ICU_DIR)
link_directories(${CLR_CMAKE_ICU_DIR}/lib)
endif(DEFINED CLR_CMAKE_ICU_DIR)

add_executable_clr(corewasmrun
corewasmrun.cpp
)

set(_WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL")
if (EXISTS "${_WASM_PRELOAD_DIR}")
set(_WASM_PRELOAD_FILE --preload-file ${_WASM_PRELOAD_DIR}@/)
endif (EXISTS "${_WASM_PRELOAD_DIR}")

target_compile_options(corewasmrun PRIVATE -fwasm-exceptions)
target_link_options(corewasmrun PRIVATE -fwasm-exceptions -sEXIT_RUNTIME=1 -sINITIAL_MEMORY=134217728 -sFORCE_FILESYSTEM=1 ${_WASM_PRELOAD_FILE} -Wl,-error-limit=0)

target_link_libraries(corewasmrun PRIVATE coreclr_static)
target_link_libraries(corewasmrun PRIVATE clrinterpreter)

target_link_libraries(corewasmrun PRIVATE icuuc)
target_link_libraries(corewasmrun PRIVATE icui18n)
target_link_libraries(corewasmrun PRIVATE icudata)

install_clr(TARGETS corewasmrun DESTINATIONS . COMPONENT hosts)
49 changes: 49 additions & 0 deletions src/coreclr/hosts/corewasmrun/corewasmrun.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//

#include <cstdio>
#include <coreclrhost.h>

static void log_error_info(const char* line)
{
std::fprintf(stderr, "log error: %s\n", line);
}

// The current CoreCLR instance details.
static void* CurrentClrInstance;
static unsigned int CurrentAppDomainId;

static int run()
{
const char* exe_path = "<coreclr-wasm>";
const char* app_domain_name = "corewasmrun";
const char* entry_assembly = "ManagedAssembly.dll";

coreclr_set_error_writer(log_error_info);

printf("call coreclr_initialize\n");
int retval = coreclr_initialize(exe_path, app_domain_name, 0, nullptr, nullptr, &CurrentClrInstance, &CurrentAppDomainId);

if (retval < 0)
{
std::fprintf(stderr, "coreclr_initialize failed - Error: 0x%08x\n", retval);
return -1;
}
else
{
printf("coreclr_initialize succeeded - retval: 0x%08x\n", retval);
}

// coreclr_execute_assembly();
// coreclr_shutdown();

return retval;
}

int main()
{
int retval = run();

return retval;
}
Loading
Loading