Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions eng/native.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<ItemGroup>
<NativeCMakeArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs &quot;-DCMAKE_ICU_DIR=$(_IcuDir)&quot;" />
<NativeCMakeArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs &quot;-DCMAKE_TZD_DIR=$(_TzdDir)&quot;" />
<NativeCMakeArg Condition="'$(RuntimeFlavor)' == 'Mono'" Include="-cmakeargs &quot;-DCLR_CMAKE_RUNTIME_MONO=1&quot;" />
<NativeCMakeArg Condition="'$(RuntimeFlavor)' == 'CoreCLR'" Include="-cmakeargs &quot;-DCLR_CMAKE_RUNTIME_CORECLR=1&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_PRODUCT_VERSION=$(ProductVersion)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_CONTINUOUS_INTEGRATION_BUILD=$(ContinuousIntegrationBuild)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_NET_CORE_APP_CURRENT_VERSION=$(NetCoreAppCurrentVersion)&quot;" />
Expand Down
15 changes: 15 additions & 0 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,21 @@ if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
else()
if(CLR_CMAKE_RUNTIME_CORECLR)
if(CLR_CMAKE_TARGET_BROWSER)
add_link_options(-fwasm-exceptions)
add_link_options(-Wno-unused-command-line-argument)
add_link_options(-Wl,-error-limit=0)

add_compile_options(-fwasm-exceptions)
add_compile_options(-mbulk-memory)
add_compile_options(-msimd128)
endif()
if(CLR_CMAKE_TARGET_WASI)
add_compile_options(-fexceptions)
endif()
endif()
endif()

if (CLR_CMAKE_HOST_ANDROID)
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ endif()

OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)

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

#----------------------------------------------------
# Cross target Component build specific configuration
#----------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/gc/unix/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class CGroup
static void Initialize()
{
s_cgroup_version = FindCGroupVersion();
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1MemorySubsystem : nullptr, &s_memory_cgroup_path, &s_memory_cgroup_hierarchy_mount);
if (s_cgroup_version != 0)
{
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1MemorySubsystem : nullptr, &s_memory_cgroup_path, &s_memory_cgroup_hierarchy_mount);
}
}

static void Cleanup()
Expand Down Expand Up @@ -119,7 +122,7 @@ class CGroup
// modes because both of those involve cgroup v1 controllers managing
// resources.

#if !HAVE_NON_LEGACY_STATFS
#if !HAVE_NON_LEGACY_STATFS || TARGET_WASM
return 0;
#else

Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ typedef cpuset_t cpu_set_t;
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
#endif

#ifdef __EMSCRIPTEN__
#include <emscripten/heap.h>
#endif // __EMSCRIPTEN__


// The cached total number of CPUs that can be used in the OS.
static uint32_t g_totalCpuCount = 0;

Expand Down Expand Up @@ -814,7 +819,7 @@ static uint64_t GetMemorySizeMultiplier(char units)
return 1;
}

#if !defined(__APPLE__) && !defined(__HAIKU__)
#if !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__EMSCRIPTEN__)
// Try to read the MemAvailable entry from /proc/meminfo.
// Return true if the /proc/meminfo existed, the entry was present and we were able to parse it.
static bool ReadMemAvailable(uint64_t* memAvailable)
Expand Down Expand Up @@ -1082,6 +1087,8 @@ uint64_t GetAvailablePhysicalMemory()
{
available = info.free_memory;
}
#elif defined(__EMSCRIPTEN__)
available = emscripten_get_heap_max() - emscripten_get_heap_size();
#else // Linux
static volatile bool tryReadMemInfo = true;

Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ else()
System.Native.TimeZoneData.Invariant)
# linker options for NodeJs, link in JavaScript helper, access to local filesystem
if (CLR_CMAKE_TARGET_BROWSER)
target_compile_options(corerun PRIVATE
-fwasm-exceptions
-msimd128
)
target_link_libraries(corerun PRIVATE
System.Native.Browser-Static)
set(JS_SYSTEM_NATIVE_BROWSER
Expand All @@ -73,12 +69,12 @@ else()
LINK_FLAGS "--pre-js ${JS_CORE_RUN_PRE} --js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
target_link_options(corerun PRIVATE
-fwasm-exceptions
-sEXIT_RUNTIME=1
-sINITIAL_MEMORY=134217728
-sMAXIMUM_MEMORY=2147483648
-sALLOW_MEMORY_GROWTH=1
-sSTACK_SIZE=5MB
-sWASM_BIGINT=1
-sEXPORTED_FUNCTIONS=_main,_GetDotNetRuntimeContractDescriptor
-sENVIRONMENT=node,shell,web
-Wl,-error-limit=0)
Expand Down
24 changes: 19 additions & 5 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ void InterpCompiler::LinkBBs(InterpBasicBlock *from, InterpBasicBlock *to)
if (newCapacity > prevCapacity)
{
InterpBasicBlock **newa = (InterpBasicBlock**)AllocMemPool(newCapacity * sizeof(InterpBasicBlock*));
memcpy(newa, from->ppOutBBs, from->outCount * sizeof(InterpBasicBlock*));
if (from->outCount != 0)
{
memcpy(newa, from->ppOutBBs, from->outCount * sizeof(InterpBasicBlock*));
}
from->ppOutBBs = newa;
}
from->ppOutBBs [from->outCount] = to;
Expand All @@ -483,7 +486,9 @@ void InterpCompiler::LinkBBs(InterpBasicBlock *from, InterpBasicBlock *to)
int newCapacity = GetBBLinksCapacity(to->inCount + 1);
if (newCapacity > prevCapacity) {
InterpBasicBlock **newa = (InterpBasicBlock**)AllocMemPool(newCapacity * sizeof(InterpBasicBlock*));
memcpy(newa, to->ppInBBs, to->inCount * sizeof(InterpBasicBlock*));
if (to->inCount != 0) {
memcpy(newa, to->ppInBBs, to->inCount * sizeof(InterpBasicBlock*));
}
to->ppInBBs = newa;
}
to->ppInBBs [to->inCount] = from;
Expand Down Expand Up @@ -5300,7 +5305,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
// We need to realloc the IL code buffer to hold the extra opcodes

uint8_t* newILCode = (uint8_t*)AllocMemPool(newILCodeSize);
memcpy(newILCode, m_pILCode, m_ILCodeSize);
if (m_ILCodeSize != 0)
{
memcpy(newILCode, m_pILCode, m_ILCodeSize);
}
memcpy(newILCode + m_synchronizedFinallyStartOffset, opCodesForSynchronizedMethodFinally, sizeof(opCodesForSynchronizedMethodFinally));
memcpy(newILCode + m_synchronizedPostFinallyOffset, opCodesForSynchronizedMethodEpilog, sizeof(opCodesForSynchronizedMethodEpilog));
m_pILCode = newILCode;
Expand Down Expand Up @@ -5512,7 +5520,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
{
MergeStackTypeInfo(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight);
// This is relevant only for copying the vars associated with the values on the stack
memcpy(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
if (pNewBB->stackHeight != 0)
{
memcpy(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
}
m_pStackPointer = m_pStackBase + pNewBB->stackHeight;
}
else
Expand All @@ -5527,7 +5538,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
if (pNewBB->stackHeight >= 0)
{
// This is relevant only for copying the vars associated with the values on the stack
memcpy (m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
if (pNewBB->stackHeight != 0)
{
memcpy (m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
}
m_pStackPointer = m_pStackBase + pNewBB->stackHeight;
pNewBB->emitState = BBStateEmitting;
emittedBBlocks = true;
Expand Down
12 changes: 0 additions & 12 deletions src/coreclr/pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,5 @@ include_directories(${COREPAL_SOURCE_DIR}/inc)
include_directories(${COREPAL_SOURCE_DIR}/src)
include_directories(${COREPAL_SOURCE_DIR}/../inc)

if (NOT CLR_CMAKE_TARGET_BROWSER)
add_compile_options(-fexceptions)
else()
add_compile_options(
-fwasm-exceptions
-msimd128
)
add_link_options(
-fwasm-exceptions
)
endif()

add_subdirectory(src)
add_subdirectory(tests)
7 changes: 5 additions & 2 deletions src/coreclr/pal/src/misc/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class CGroup
static void Initialize()
{
s_cgroup_version = FindCGroupVersion();
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1CpuSubsystem : nullptr, &s_cpu_cgroup_path);
if (s_cgroup_version != 0)
{
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1CpuSubsystem : nullptr, &s_cpu_cgroup_path);
}
}

static void Cleanup()
Expand Down Expand Up @@ -84,7 +87,7 @@ class CGroup
// modes because both of those involve cgroup v1 controllers managing
// resources.

#if !HAVE_NON_LEGACY_STATFS
#if !HAVE_NON_LEGACY_STATFS || TARGET_WASM
return 0;
#else
struct statfs stats;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3678,7 +3678,10 @@ VOID MethodTableBuilder::AllocateWorkingSlotTables()

// Allocate a FieldDesc* for each field
bmtMFDescs->ppFieldDescList = new (GetStackingAllocator()) FieldDesc*[bmtMetaData->cFields];
ZeroMemory(bmtMFDescs->ppFieldDescList, bmtMetaData->cFields * sizeof(FieldDesc *));
if (bmtMetaData->cFields != 0)
{
ZeroMemory(bmtMFDescs->ppFieldDescList, bmtMetaData->cFields * sizeof(FieldDesc *));
}

// Create a temporary function table (we don't know how large the vtable will be until the very end,
// since we don't yet know how many declared methods are overrides vs. newslots).
Expand Down
16 changes: 2 additions & 14 deletions src/native/corehost/browserhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ add_library(BrowserHost-Static
)
set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEAN_DIRECT_OUTPUT 1)

target_compile_options(BrowserHost-Static PRIVATE
-fwasm-exceptions
-msimd128
)
target_link_libraries(BrowserHost-Static PRIVATE
hostmisc
)
Expand Down Expand Up @@ -97,11 +93,6 @@ set_target_properties(browserhost PROPERTIES
LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_SYSTEM_RUNTIME_INTEROPSERVICES_JAVASCRIPT_NATIVE} --js-library ${JS_BROWSER_HOST} --extern-post-js ${JS_SYSTEM_NATIVE_BROWSER_EXPOST}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

target_compile_options(browserhost PRIVATE
-fwasm-exceptions
-msimd128
)

if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
target_link_options(browserhost PRIVATE
# -sVERBOSE
Expand All @@ -112,24 +103,21 @@ if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
)
endif ()

# WASM-TODO -sWASM_BIGINT=1
# WASM-TODO -emit-llvm
# WASM-TODO --source-map-base http://microsoft.com
target_link_options(browserhost PRIVATE
-sINITIAL_MEMORY=134217728
-sMAXIMUM_MEMORY=2147483648
-sALLOW_MEMORY_GROWTH=1
-sSTACK_SIZE=5MB
-sWASM_BIGINT=1
-sMODULARIZE=1
-sEXPORT_ES6=1
-sEXIT_RUNTIME=0
-sEXPORTED_RUNTIME_METHODS=UTF8ToString,cwrap,ccall,HEAPU8,HEAPU32,HEAPU64,BROWSER_HOST
-sEXPORTED_FUNCTIONS=_posix_memalign,_free,stackAlloc,stackRestore,stackSave,_BrowserHost_InitializeCoreCLR,_BrowserHost_ExecuteAssembly,___cpp_exception
-sEXPORT_NAME=createDotnetRuntime
-fwasm-exceptions
-lnodefs.js
-Wno-unused-command-line-argument
-Wl,-error-limit=0)
-lnodefs.js)

target_link_libraries(browserhost PUBLIC
BrowserHost-Static
Expand Down
7 changes: 0 additions & 7 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
else()
set(TEST_LIB_TYPE STATIC)

add_compile_options(
-fwasm-exceptions
-msimd128)
add_link_options(
-fwasm-exceptions
)

# opt in into tests that make sense for WASM
add_subdirectory(JIT/interpreter)
endif()
Loading