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 src/coreclr/clrdatadescriptors.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function(generate_data_descriptors)
set(LIBRARY ${DATA_DESCRIPTORS_LIBRARY_NAME})

set(DATA_DESCRIPTOR_SHARED_SOURCE_DIR "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/debug/datadescriptor-shared")
set(DATA_DESCRIPTOR_SHARED_INCLUDE_DIR "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/debug/datadescriptor-shared/inc")
set(GENERATED_CDAC_DESCRIPTOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/cdac-${LIBRARY}")

# configure contract export name
Expand Down Expand Up @@ -73,6 +74,7 @@ function(generate_data_descriptors)
)
add_dependencies(${LIBRARY} ${INTERMEDIARY_LIBRARY})

target_include_directories(${LIBRARY} PUBLIC ${DATA_DESCRIPTOR_SHARED_INCLUDE_DIR})
target_include_directories(${LIBRARY} PRIVATE ${GENERATED_CDAC_DESCRIPTOR_DIR})

# inherit definitions, include directories, and dependencies from the INTERFACE target
Expand Down
30 changes: 17 additions & 13 deletions src/coreclr/debug/datadescriptor-shared/contract-descriptor.c.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include <stdint.h>
#include "contractconfiguration.h"

#ifdef _MSC_VER
Expand All @@ -10,22 +9,11 @@
#define DLLEXPORT __attribute__((visibility("default")))
#endif

struct ContractDescriptor
{
uint64_t magic;
uint32_t flags;
const uint32_t descriptor_size;
const char *descriptor;
const uint32_t pointer_data_count;
uint32_t pad0;
const void** pointer_data;
};

// POINTER_DATA_NAME and CONTRACT_NAME are macros provided by
// contractconfiguration.h which is configured by CMake
extern const void* POINTER_DATA_NAME[];

#if EXPORT_CONTRACT
#ifdef EXPORT_CONTRACT
DLLEXPORT
#endif // EXPORT_CONTRACT
struct ContractDescriptor CONTRACT_NAME = {
Expand All @@ -36,3 +24,19 @@ struct ContractDescriptor CONTRACT_NAME = {
.pointer_data_count = %%pointerDataCount%%,
.pointer_data = &POINTER_DATA_NAME[0],
};

// When using emscripten, we need to export the contract descriptor
// symbol through a function export to ensure it is not removed by the linker.
// Due to linking order, the export may also need to be added to
// the EXPORTED_FUNCTIONS setting for emcc.
// See https://emscripten.org/docs/getting_started/FAQ.html#why-do-functions-in-my-c-c-source-code-vanish-when-i-compile-to-webassembly
#if defined(EXPORT_CONTRACT) && defined(__EMSCRIPTEN__)
#include <emscripten.h>

#define _GETTER_NAME(exportname) Get ## exportname
#define GETTER_NAME(exportname) _GETTER_NAME(exportname)
extern void* EMSCRIPTEN_KEEPALIVE GETTER_NAME(CONTRACT_NAME)()
{
return (void*)&CONTRACT_NAME;
}
#endif // EXPORT_CONTRACT && __EMSCRIPTEN__
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#define POINTER_DATA_NAME @POINTER_DATA_NAME@
#define CONTRACT_NAME @CONTRACT_NAME@
#include <contract-descriptor.h>

#define EXPORT_CONTRACT @EXPORT_CONTRACT@
#cmakedefine POINTER_DATA_NAME @POINTER_DATA_NAME@
#cmakedefine CONTRACT_NAME @CONTRACT_NAME@

#cmakedefine EXPORT_CONTRACT @EXPORT_CONTRACT@
12 changes: 0 additions & 12 deletions src/coreclr/debug/datadescriptor-shared/contractdescriptorstub.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include <stdint.h>
#include "contractconfiguration.h"

#ifdef _MSC_VER
Expand All @@ -10,17 +9,6 @@
#define DLLEXPORT __attribute__((visibility("default")))
#endif

struct ContractDescriptor
{
uint64_t magic;
uint32_t flags;
const uint32_t descriptor_size;
const char *descriptor;
const uint32_t pointer_data_count;
uint32_t pad0;
const void** pointer_data;
};

// POINTER_DATA_NAME and CONTRACT_NAME are macros provided by
// contractconfiguration.h which is configured by CMake
extern const void* POINTER_DATA_NAME[];
Expand Down
20 changes: 20 additions & 0 deletions src/coreclr/debug/datadescriptor-shared/inc/contract-descriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#ifndef CONTRACT_DESCRIPTOR_H
#define CONTRACT_DESCRIPTOR_H

#include <stdint.h>

struct ContractDescriptor
{
uint64_t magic;
uint32_t flags;
const uint32_t descriptor_size;
const char* descriptor;
const uint32_t pointer_data_count;
uint32_t pad0;
const void** pointer_data;
};

#endif // CONTRACT_DESCRIPTOR_H
20 changes: 8 additions & 12 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ if (NOT CLR_CMAKE_HOST_ARCH_WASM)
set(LIB_INTEROP interop)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)

set(LIB_CDAC_CONTRACT_DESCRIPTOR cdac_contract_descriptor)
set(LIB_CDAC_GC_WKS_DESCRIPTOR gc_wks_descriptor)
set(LIB_CDAC_GC_SVR_DESCRIPTOR gc_svr_descriptor)

if (CLR_CMAKE_HOST_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(LIB_UNWINDER unwinder_wks)
endif (CLR_CMAKE_HOST_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
Expand Down Expand Up @@ -106,13 +102,13 @@ set(CORECLR_LIBRARIES
${LIB_INTEROP}
coreclrminipal
gc_pal
${LIB_CDAC_CONTRACT_DESCRIPTOR}
${LIB_CDAC_GC_WKS_DESCRIPTOR}
cdac_contract_descriptor
gc_wks_descriptor
)

if (FEATURE_SVR_GC)
list(APPEND CORECLR_LIBRARIES
${LIB_CDAC_GC_SVR_DESCRIPTOR}
gc_svr_descriptor
)
endif(FEATURE_SVR_GC)

Expand Down Expand Up @@ -188,11 +184,11 @@ 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()
if(CLR_CMAKE_HOST_ARCH_WASM)
set(CEE_WKS_STATIC cee_wks)
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)
else()
set(CEE_WKS_STATIC cee_wks_mergeable)
endif()

if (CLR_CMAKE_TARGET_OSX)
find_library(FOUNDATION Foundation REQUIRED)
Expand All @@ -202,7 +198,7 @@ if(NOT CLR_CMAKE_HOST_ARCH_WASM)
target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} ${CLRINTERPRETER_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} ${CLRINTERPRETER_STATIC} ${CEE_WKS_STATIC} ${FOUNDATION})
target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} ${CORECLR_STATIC_CLRJIT_STATIC} ${CLRINTERPRETER_STATIC} cee_wks_core ${CEE_WKS_STATIC} ${FOUNDATION})
target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED)

if (CLR_CMAKE_HOST_ANDROID)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ else()
-sEXIT_RUNTIME=1
-sINITIAL_MEMORY=134217728
-sSTACK_SIZE=5MB
-sEXPORTED_FUNCTIONS=_main,_GetDotNetRuntimeContractDescriptor
-sENVIRONMENT=node,shell,web
-Wl,-error-limit=0)

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ set(INTERPRETER_LINK_LIBRARIES
)

if(CLR_CMAKE_HOST_WIN32)
list(APPEND INTERPRETER_LINK_LIBRARIES
${STATIC_MT_CRT_LIB}
${STATIC_MT_VCRT_LIB}
)
endif(CLR_CMAKE_HOST_WIN32)
list(APPEND INTERPRETER_LINK_LIBRARIES
${STATIC_MT_CRT_LIB}
${STATIC_MT_VCRT_LIB}
)
endif()

if(CLR_CMAKE_HOST_WIN32)
set(CLRINTERPRETER_EXPORTS ${CMAKE_CURRENT_LIST_DIR}/clrinterpreter.exports)
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/vm/wks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ add_dependencies(cee_wks_mergeable precompiled_asm)
target_compile_definitions(cee_wks_mergeable PUBLIC FEATURE_STATICALLY_LINKED)
target_compile_definitions(cee_wks_mergeable PUBLIC CORECLR_EMBEDDED)

if (NOT CLR_CMAKE_HOST_ARCH_WASM)
target_compile_definitions(cee_wks_core PRIVATE -DGC_DESCRIPTOR)
endif (NOT CLR_CMAKE_HOST_ARCH_WASM)
target_compile_definitions(cee_wks_core PRIVATE GC_DESCRIPTOR)

if (CLR_CMAKE_HOST_WIN32)
link_natvis_sources_for_target(cee_wks INTERFACE ../vm.natvis)
Expand Down
Loading