From 8a3bb1c15e83377d79a60b5375083ddabf545c54 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 Jun 2024 16:32:08 -0700 Subject: [PATCH 01/31] Move containers library to be an object library instead of a list of sources --- src/coreclr/CMakeLists.txt | 2 + .../Runtime/eventpipe/CMakeLists.txt | 15 ++----- .../vm/eventing/eventpipe/CMakeLists.txt | 11 +---- src/mono/mono/component/CMakeLists.txt | 7 +++- src/mono/mono/eventpipe/eventpipe.cmake | 11 ----- src/mono/mono/mini/CMakeLists.txt | 17 +++----- src/native/containers/CMakeLists.txt | 22 ++++++++++ src/native/containers/containers.cmake | 41 ------------------- src/native/containers/dn-allocator.h | 4 ++ src/native/containers/dn-config.h.in | 8 ++++ src/native/containers/dn-fwd-list.h | 4 ++ src/native/containers/dn-list.h | 4 ++ src/native/containers/dn-queue.h | 4 ++ .../containers/dn-simdhash-ght-compatible.c | 2 +- src/native/containers/dn-simdhash-ptr-ptr.c | 2 +- .../containers/dn-simdhash-ptrpair-ptr.c | 2 +- .../containers/dn-simdhash-string-ptr.c | 2 +- src/native/containers/dn-umap.h | 4 ++ src/native/containers/dn-utils.h | 4 ++ src/native/containers/dn-vector-priv.h | 4 ++ src/native/containers/dn-vector.h | 4 ++ 21 files changed, 85 insertions(+), 89 deletions(-) create mode 100644 src/native/containers/CMakeLists.txt delete mode 100644 src/native/containers/containers.cmake create mode 100644 src/native/containers/dn-config.h.in diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 7ed0d509212cc4..52e4831f8e80e2 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -125,6 +125,8 @@ add_subdirectory(pal/prebuilt/inc) set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}") include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake) +add_subdirectory(${CLR_SRC_NATIVE_DIR}/containers containers) + if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(debug/debug-pal) endif() diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 19ea228f01b62c..6044124a9702ba 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -106,8 +106,6 @@ endif() set(AOT_EVENTPIPE_SHIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set (CONTAINER_SOURCES "") -set (CONTAINER_HEADERS "") set (MINIPAL_SOURCES "") set (EVENTPIPE_SOURCES "") set (EVENTPIPE_HEADERS "") @@ -122,7 +120,6 @@ set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers") set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") set (SHARED_MINIPAL_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/minipal") include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake) -include (${SHARED_CONTAINERS_SOURCE_PATH}/containers.cmake) list(APPEND MINIPAL_SOURCES utf8.c @@ -164,8 +161,6 @@ list(APPEND EVENTPIPE_HEADERS ${SHARED_DIAGNOSTIC_SERVER_HEADERS} ) -addprefix(CONTAINER_SOURCES ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_SOURCES}") -addprefix(CONTAINER_HEADERS ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_HEADERS}") addprefix(MINIPAL_SOURCES ${SHARED_MINIPAL_SOURCE_PATH} "${MINIPAL_SOURCES}") addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}") @@ -174,11 +169,9 @@ addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES LANGUAGE CXX) set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX) if(CLR_CMAKE_HOST_UNIX) - set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) endif(CLR_CMAKE_HOST_UNIX) @@ -188,7 +181,7 @@ endif() list(APPEND AOT_EVENTPIPE_SHIM_SOURCES ${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-aot.cpp - ${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.cpp + ${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.cpp ) list(APPEND AOT_EVENTPIPE_SHIM_HEADERS @@ -239,8 +232,6 @@ list(APPEND EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_CONFIG_HEADERS} ${GEN_EVENTPIPE_PROVIDER_SOURCES} ${GEN_EVENTPIPE_PLAT_AGNOSTIC_SOURCES} - ${CONTAINER_SOURCES} - ${CONTAINER_HEADERS} ${MINIPAL_SOURCES} ) @@ -253,6 +244,7 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES ) add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES}) +target_link_libraries(eventpipe-enabled PRIVATE dn-containers) add_dependencies(eventpipe-enabled aot_eventing_headers) if(CLR_CMAKE_TARGET_WIN32) add_dependencies(eventpipe-enabled aot_etw_headers) @@ -265,6 +257,7 @@ if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) + target_link_libraries(eventpipe-enabled.GuardCF PRIVATE dn-containers) add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) add_dependencies(eventpipe-disabled.GuardCF aot_eventing_headers) set_target_properties(eventpipe-enabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) @@ -276,4 +269,4 @@ install_static_library(eventpipe-disabled aotsdk nativeaot) if (CLR_CMAKE_TARGET_WIN32) install_static_library(eventpipe-enabled.GuardCF aotsdk nativeaot) install_static_library(eventpipe-disabled.GuardCF aotsdk nativeaot) -endif (CLR_CMAKE_TARGET_WIN32) \ No newline at end of file +endif (CLR_CMAKE_TARGET_WIN32) diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index 666761a1123928..df6cbe47ad244f 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -28,8 +28,6 @@ add_custom_command(OUTPUT ${GEN_EVENTPIPE_SOURCES} COMMAND ${GENERATE_COMMAND} DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS}) -set (CONTAINER_SOURCES "") -set (CONTAINER_HEADERS "") set (EVENTPIPE_SOURCES "") set (EVENTPIPE_HEADERS "") set (CORECLR_EVENTPIPE_SHIM_SOURCES "") @@ -39,7 +37,6 @@ set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers") set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") set (CORECLR_EVENTPIPE_SHIM_SOURCE_PATH "${CORECLR_EVENTPIPE_SHIM_DIR}") -include (${SHARED_CONTAINERS_SOURCE_PATH}/containers.cmake) include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake) list(APPEND EVENTPIPE_SOURCES @@ -52,9 +49,6 @@ list(APPEND EVENTPIPE_HEADERS ${SHARED_DIAGNOSTIC_SERVER_HEADERS} ) -addprefix(CONTAINER_SOURCES ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_SOURCES}") -addprefix(CONTAINER_HEADERS ${SHARED_CONTAINERS_SOURCE_PATH} "${SHARED_CONTAINER_HEADERS}") - addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}") addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS}") @@ -90,8 +84,6 @@ list(APPEND EVENTPIPE_SOURCES ${CORECLR_EVENTPIPE_SHIM_HEADERS} ${EVENTPIPE_HEADERS} ${SHARED_EVENTPIPE_CONFIG_HEADERS} - ${CONTAINER_SOURCES} - ${CONTAINER_HEADERS} ) add_library_clr(eventpipe_gen_objs OBJECT ${GEN_EVENTPIPE_SOURCES}) @@ -103,6 +95,7 @@ add_library_clr(eventpipe_objs OBJECT ${EVENTPIPE_SOURCES}) target_precompile_headers(eventpipe_objs PRIVATE [["common.h"]]) set_target_properties(eventpipe_objs PROPERTIES LINKER_LANGUAGE CXX) add_dependencies(eventpipe_objs eventing_headers) +target_link_libraries(eventpipe_objs INTERFACE dn-containers) add_library(eventpipe INTERFACE) -target_sources(eventpipe INTERFACE $ $) +target_sources(eventpipe INTERFACE $ $ $) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index f61b3dc09e172a..bf18310a7a37a8 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -9,6 +9,8 @@ set(MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME "diagnostics_tracing") set(MONO_DEBUGGER_COMPONENT_NAME "debugger") set(MONO_MARSHAL_ILGEN_COMPONENT_NAME "marshal-ilgen") +add_subdirectory(${SHARED_CONTAINERS_SOURCE_PATH} containers) + # a list of every component. set(components "") # a list of components needed by the AOT compiler @@ -70,7 +72,6 @@ include_directories( ) set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-sources - ${container_sources} ${eventpipe_sources} ${diagnostic_server_sources} ${MONO_COMPONENT_PATH}/event_pipe.c @@ -166,6 +167,10 @@ foreach(component IN LISTS components) target_link_libraries("${component}-stub-objects" PUBLIC eglib_api) endforeach() +if (TARGET "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects") + target_link_libraries("${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects" PRIVATE dn-containers) +endif() + if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS) # define a shared library for each component foreach(component IN LISTS components_to_build) diff --git a/src/mono/mono/eventpipe/eventpipe.cmake b/src/mono/mono/eventpipe/eventpipe.cmake index 6f3c0bf16cd374..0c53e88d3ebb4b 100644 --- a/src/mono/mono/eventpipe/eventpipe.cmake +++ b/src/mono/mono/eventpipe/eventpipe.cmake @@ -10,17 +10,6 @@ if(ENABLE_PERFTRACING) add_definitions(-DBIGENDIAN) endif (TARGET_S390X) - include (${SHARED_CONTAINERS_SOURCE_PATH}containers.cmake) - - set(container_sources "") - - list(APPEND container_sources - ${SHARED_CONTAINER_SOURCES} - ${SHARED_CONTAINER_HEADERS} - ) - - addprefix(container_sources ${SHARED_CONTAINERS_SOURCE_PATH} "${container_sources}") - include (${SHARED_EVENTPIPE_SOURCE_PATH}eventpipe.cmake) set(MONO_EVENTPIPE_SHIM_SOURCES "") diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index b9bd9d426bc686..bc6db83f3fa1fe 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -49,14 +49,6 @@ endif() # MINI # -set(imported_native_sources - ../../../native/containers/dn-simdhash.c - ../../../native/containers/dn-simdhash-ptr-ptr.c - ../../../native/containers/dn-simdhash-string-ptr.c - ../../../native/containers/dn-simdhash-u32-ptr.c - ../../../native/containers/dn-simdhash-ght-compatible.c - ../../../native/containers/dn-simdhash-ptrpair-ptr.c) - set(mini_common_sources mini.c mini-runtime.c @@ -310,7 +302,7 @@ else() set(profiler_sources "") endif() -set(mini_sources "main-core.c;${imported_native_sources};${mini_common_sources};${arch_sources};${os_sources};${mini_interp_sources};${llvm_sources};${debugger_sources};${profiler_sources};${llvm_runtime_sources}") +set(mini_sources "main-core.c;${mini_common_sources};${arch_sources};${os_sources};${mini_interp_sources};${llvm_sources};${debugger_sources};${profiler_sources};${llvm_runtime_sources}") if(LLVM_INCLUDEDIR) include_directories(BEFORE SYSTEM "${LLVM_INCLUDEDIR}") @@ -341,6 +333,7 @@ endif() add_library(monosgen-static STATIC $ $ $ $ $) set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME ${MONO_LIB_NAME}) +target_link_libraries(monosgen-static PRIVATE dn-containers) if(DISABLE_COMPONENTS OR AOT_COMPONENTS) # add component fallback stubs into static mono library when components have been disabled. @@ -366,9 +359,9 @@ if(NOT DISABLE_SHARED_LIBS) set_target_properties(monosgen-shared PROPERTIES INSTALL_RPATH "$ORIGIN") endif() if(HOST_WIN32) - target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects_shared sgen_objects_shared metadata_objects_shared) + target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects_shared sgen_objects_shared metadata_objects_shared dn-containers) else() - target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects dn-containers) endif() target_include_directories (monosgen-shared PRIVATE monoapi) if(TARGET_WIN32) @@ -541,7 +534,7 @@ if(NOT DISABLE_EXECUTABLES) set_target_properties(mono-sgen PROPERTIES INSTALL_RPATH "$ORIGIN") endif() endif() - target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static) + target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static dn-containers) if (HOST_WASM) target_link_libraries(mono-sgen PRIVATE mono-wasm-nosimd) endif() diff --git a/src/native/containers/CMakeLists.txt b/src/native/containers/CMakeLists.txt new file mode 100644 index 00000000000000..8256e7990a78f9 --- /dev/null +++ b/src/native/containers/CMakeLists.txt @@ -0,0 +1,22 @@ +add_library(dn-containers OBJECT) + +target_sources(dn-containers PRIVATE + dn-allocator.c + dn-fwd-list.c + dn-list.c + dn-queue.c + dn-umap.c + dn-vector.c + dn-simdhash.c + dn-simdhash-string-ptr.c + dn-simdhash-u32-ptr.c + dn-simdhash-ptr-ptr.c + dn-simdhash-ght-compatible.c + dn-simdhash-ptrpair-ptr.c +) + +configure_file(dn-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dn-config.h) + +target_include_directories(dn-containers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +target_include_directories(dn-containers PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/native/containers/containers.cmake b/src/native/containers/containers.cmake deleted file mode 100644 index 4749dceea2dd9a..00000000000000 --- a/src/native/containers/containers.cmake +++ /dev/null @@ -1,41 +0,0 @@ -set (SHARED_CONTAINER_SOURCES "") -set (SHARED_CONTAINER_HEADERS "") - -list(APPEND SHARED_CONTAINER_SOURCES - dn-allocator.c - dn-fwd-list.c - dn-list.c - dn-queue.c - dn-umap.c - dn-vector.c - # FIXME: Including these here causes a linker collision with sgen metadata - # dn-simdhash.c - # dn-simdhash-string-ptr.c - # dn-simdhash-u32-ptr.c - # dn-simdhash-ptr-ptr.c - # dn-simdhash-ght-compatible.c - # dn-simdhash-ptrpair-ptr.c -) - -list(APPEND SHARED_CONTAINER_HEADERS - dn-allocator.h - dn-fwd-list.h - dn-list.h - dn-queue.h - dn-sort-frag.inc - dn-umap.h - dn-umap-t.h - dn-utils.h - dn-vector.h - dn-vector-priv.h - dn-vector-ptr.h - dn-vector-t.h - dn-vector-types.h - dn-simdhash.h - dn-simdhash-specialization.h - dn-simdhash-specialization-declarations.h - dn-simdhash-specializations.h - dn-simdhash-arch.h - dn-simdhash-string-ptr.h - dn-simdhash-utils.h -) diff --git a/src/native/containers/dn-allocator.h b/src/native/containers/dn-allocator.h index ef4e3d15f815b1..5fd5f31b081168 100644 --- a/src/native/containers/dn-allocator.h +++ b/src/native/containers/dn-allocator.h @@ -8,6 +8,8 @@ #include #include +EXTERN_C_BEGIN + #define DN_ALLOCATOR_MEM_ALIGN8 8 #define DN_ALLOCATOR_MEM_ALIGN16 16 #define DN_ALLOCATOR_MAX_ALIGNMENT DN_ALLOCATOR_MEM_ALIGN16 @@ -104,4 +106,6 @@ dn_allocator_fixed_or_malloc_reset (dn_allocator_fixed_or_malloc_t *allocator); #define DN_DEFAULT_ALLOCATOR NULL #define DN_DEFAULT_LOCAL_ALLOCATOR(var_name, buffer_size) DN_ALLOCATOR_FIXED_OR_MALLOC (var_name, buffer_size) +EXTERN_C_END + #endif /* __DN_ALLOCATOR_H__ */ diff --git a/src/native/containers/dn-config.h.in b/src/native/containers/dn-config.h.in new file mode 100644 index 00000000000000..99192a359f87af --- /dev/null +++ b/src/native/containers/dn-config.h.in @@ -0,0 +1,8 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +#ifndef DN_CONFIG_H +#define DN_CONFIG_H + +#cmakedefine SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@ + +#endif // DN_CONFIG_H diff --git a/src/native/containers/dn-fwd-list.h b/src/native/containers/dn-fwd-list.h index c5c809d070a606..a7fd275bd4c066 100644 --- a/src/native/containers/dn-fwd-list.h +++ b/src/native/containers/dn-fwd-list.h @@ -7,6 +7,8 @@ #include "dn-utils.h" #include "dn-allocator.h" +EXTERN_C_BEGIN + typedef int32_t (DN_CALLBACK_CALLTYPE *dn_fwd_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_fwd_list_equal_func_t) (const void *a, const void *b); typedef void (DN_CALLBACK_CALLTYPE *dn_fwd_list_for_each_func_t) (void *data, void *user_data); @@ -321,4 +323,6 @@ dn_fwd_list_find ( return dn_fwd_list_custom_find (list, data, NULL); } +EXTERN_C_END + #endif /* __DN_FWD_LIST_H__ */ diff --git a/src/native/containers/dn-list.h b/src/native/containers/dn-list.h index 1b16c15b74c32f..3e77eef842dce6 100644 --- a/src/native/containers/dn-list.h +++ b/src/native/containers/dn-list.h @@ -7,6 +7,8 @@ #include "dn-utils.h" #include "dn-allocator.h" +EXTERN_C_BEGIN + typedef int32_t (DN_CALLBACK_CALLTYPE *dn_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_list_equal_func_t) (const void *a, const void *b); typedef void (DN_CALLBACK_CALLTYPE *dn_list_for_each_func_t) (void *data, void *user_data); @@ -371,4 +373,6 @@ dn_list_find ( return dn_list_custom_find (list, data, NULL); } +EXTERN_C_END + #endif /* __DN_LIST_H__ */ diff --git a/src/native/containers/dn-queue.h b/src/native/containers/dn-queue.h index 93e886b9261c44..75e3b2279e8a68 100644 --- a/src/native/containers/dn-queue.h +++ b/src/native/containers/dn-queue.h @@ -8,6 +8,8 @@ #include "dn-allocator.h" #include "dn-list.h" +EXTERN_C_BEGIN + typedef void (DN_CALLBACK_CALLTYPE *dn_queue_dispose_func_t) (void *data); typedef struct _dn_queue_t dn_queue_t; @@ -144,4 +146,6 @@ dn_queue_clear (dn_queue_t *queue) dn_queue_custom_clear (queue, NULL); } +EXTERN_C_END + #endif /* __DN_QUEUE_H__ */ diff --git a/src/native/containers/dn-simdhash-ght-compatible.c b/src/native/containers/dn-simdhash-ght-compatible.c index eced9aac478c89..af0cf96365ecfc 100644 --- a/src/native/containers/dn-simdhash-ght-compatible.c +++ b/src/native/containers/dn-simdhash-ght-compatible.c @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #ifndef NO_CONFIG_H -#include +#include #endif #include "dn-simdhash.h" diff --git a/src/native/containers/dn-simdhash-ptr-ptr.c b/src/native/containers/dn-simdhash-ptr-ptr.c index 25e7530d39dc48..80501ffc3fa992 100644 --- a/src/native/containers/dn-simdhash-ptr-ptr.c +++ b/src/native/containers/dn-simdhash-ptr-ptr.c @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #ifndef NO_CONFIG_H -#include +#include #endif #include "dn-simdhash.h" diff --git a/src/native/containers/dn-simdhash-ptrpair-ptr.c b/src/native/containers/dn-simdhash-ptrpair-ptr.c index d377647b6636ac..a427c7e76ef9c1 100644 --- a/src/native/containers/dn-simdhash-ptrpair-ptr.c +++ b/src/native/containers/dn-simdhash-ptrpair-ptr.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include #include "dn-simdhash.h" #include "dn-simdhash-utils.h" diff --git a/src/native/containers/dn-simdhash-string-ptr.c b/src/native/containers/dn-simdhash-string-ptr.c index 87c00f40f01822..4bd03896506657 100644 --- a/src/native/containers/dn-simdhash-string-ptr.c +++ b/src/native/containers/dn-simdhash-string-ptr.c @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #ifndef NO_CONFIG_H -#include +#include #endif #include "dn-simdhash.h" diff --git a/src/native/containers/dn-umap.h b/src/native/containers/dn-umap.h index 140d9bf288ba29..549e475fd83259 100644 --- a/src/native/containers/dn-umap.h +++ b/src/native/containers/dn-umap.h @@ -7,6 +7,8 @@ #include "dn-utils.h" #include "dn-allocator.h" +EXTERN_C_BEGIN + typedef uint32_t (DN_CALLBACK_CALLTYPE *dn_umap_hash_func_t) (const void *key); typedef bool (DN_CALLBACK_CALLTYPE *dn_umap_equal_func_t) (const void *a, const void *b); typedef void (DN_CALLBACK_CALLTYPE *dn_umap_key_dispose_func_t) (void *key); @@ -274,4 +276,6 @@ uint32_t DN_CALLBACK_CALLTYPE dn_str_hash (const void *v1); +EXTERN_C_END + #endif /* __DN_UMAP_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index dab4160852b1fa..b4f7cc3b4c3dc8 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -7,9 +7,13 @@ #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS +#define EXTERN_C_BEGIN extern "C" { +#define EXTERN_C_END } #endif #else #include +#define EXTERN_C_BEGIN +#define EXTERN_C_END #endif #include diff --git a/src/native/containers/dn-vector-priv.h b/src/native/containers/dn-vector-priv.h index 9b373aa08e5b98..d75c58368daafe 100644 --- a/src/native/containers/dn-vector-priv.h +++ b/src/native/containers/dn-vector-priv.h @@ -8,6 +8,8 @@ #include "dn-allocator.h" #include "dn-vector-types.h" +EXTERN_C_BEGIN + bool _dn_vector_ensure_capacity ( dn_vector_t *vector, @@ -92,4 +94,6 @@ _dn_vector_find_adapter ( *found = _dn_vector_custom_find (vector, data, equal_func); } +EXTERN_C_END + #endif /* __DN_VECTOR_PRIV_H__ */ diff --git a/src/native/containers/dn-vector.h b/src/native/containers/dn-vector.h index 462dc54867d69a..0f7f76c393ce39 100644 --- a/src/native/containers/dn-vector.h +++ b/src/native/containers/dn-vector.h @@ -9,6 +9,8 @@ #include "dn-vector-types.h" #include "dn-vector-priv.h" +EXTERN_C_BEGIN + static inline dn_vector_it_t dn_vector_begin (dn_vector_t *vector) { @@ -325,4 +327,6 @@ dn_vector_find ( return dn_vector_custom_find (vector, value, equal_func); } +EXTERN_C_END + #endif /* __DN_VECTOR_H__ */ From 0877350e640e74cb1566c10e710caccebda544cf Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 11:41:03 -0700 Subject: [PATCH 02/31] Define default implementation of the simdhash assert failure function for runtimes that haven't adopted simdhash --- src/native/containers/CMakeLists.txt | 1 + src/native/containers/dn-simdhash-utils.c | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/native/containers/dn-simdhash-utils.c diff --git a/src/native/containers/CMakeLists.txt b/src/native/containers/CMakeLists.txt index 8256e7990a78f9..7793a2dc1471f4 100644 --- a/src/native/containers/CMakeLists.txt +++ b/src/native/containers/CMakeLists.txt @@ -13,6 +13,7 @@ target_sources(dn-containers PRIVATE dn-simdhash-ptr-ptr.c dn-simdhash-ght-compatible.c dn-simdhash-ptrpair-ptr.c + dn-simdhash-utils.c ) configure_file(dn-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dn-config.h) diff --git a/src/native/containers/dn-simdhash-utils.c b/src/native/containers/dn-simdhash-utils.c new file mode 100644 index 00000000000000..7f10d9e18a47a0 --- /dev/null +++ b/src/native/containers/dn-simdhash-utils.c @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include "dn-utils.h" +#include "dn-simdhash-utils.h" + +#include +#include + +// Define a default implementation of the assert failure function. + +#ifdef _MSC_VER +#define DEFINE_ALTERNATENAME_3(part) _Pragma(#part) +#define DEFINE_ALTERNATENAME_2(part) DEFINE_ALTERNATENAME_3(comment(linker, part)) +#define DEFINE_ALTERNATENAME_1(part) DEFINE_ALTERNATENAME_2(#part) +#define DEFINE_ALTERNATENAME(alias, func) DEFINE_ALTERNATENAME_1(/ALTERNATENAME:alias=func) +#ifdef _M_IX86 +#define DEFAULT_IMPLEMENTATION(func, impl, retval) DEFINE_ALTERNATENAME(_ ## func, _ ## impl) retval impl +#else +#define DEFAULT_IMPLEMENTATION(func, impl, retval) DEFINE_ALTERNATENAME(func, impl) retval impl +#endif +#else +#define DEFAULT_IMPLEMENTATION(func, impl, retval) __attribute__((weak)) retval func +#endif + +DEFAULT_IMPLEMENTATION(dn_simdhash_assert_fail, dn_simdhash_assert_fail_default, void) (const char *file, int line, const char *condition) +{ + fprintf(stderr, "Assertion failed:%s\n\tFile: %s\n\tLine:%d\n", condition, file, line); + abort(); +} From 3adeb0fef7861117a078402778c1ac9a60491e50 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 14:36:08 -0700 Subject: [PATCH 03/31] Convert EventPipe and DiagnosticServer to be defined as interface libraries, and update CoreCLR to use the new model. --- src/coreclr/CMakeLists.txt | 1 + src/coreclr/debug/debug-pal/CMakeLists.txt | 17 ++--- .../vm/eventing/eventpipe/CMakeLists.txt | 56 ++------------ src/native/eventpipe/CMakeLists.txt | 76 +++++++++++++++++++ src/native/eventpipe/ep-shared-config.h.in | 22 +++++- 5 files changed, 114 insertions(+), 58 deletions(-) create mode 100644 src/native/eventpipe/CMakeLists.txt diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 52e4831f8e80e2..808aac13e22cd1 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -126,6 +126,7 @@ set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}") include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake) add_subdirectory(${CLR_SRC_NATIVE_DIR}/containers containers) +add_subdirectory(${CLR_SRC_NATIVE_DIR}/eventpipe eventpipe) if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS) add_subdirectory(debug/debug-pal) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index adc8efacab4ae9..9f7b1365d5af9d 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -1,8 +1,6 @@ include_directories(../inc) include_directories(../../pal/inc) -include_directories(${EP_GENERATED_HEADER_PATH}) -set(SHARED_EVENTPIPE_SOURCE_PATH ${CLR_SRC_NATIVE_DIR}/eventpipe) add_definitions(-DFEATURE_CORECLR) add_definitions(-DFEATURE_PERFTRACING) add_definitions(-DFEATURE_PERFTRACING_STANDALONE_PAL) @@ -12,9 +10,6 @@ if(CLR_CMAKE_HOST_WIN32) include_directories(../../inc) #needed for warning control if(CLR_CMAKE_TARGET_WIN32) - set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-namedpipe.c") - set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX) - set(TWO_WAY_PIPE_SOURCES ${EVENTPIPE_PAL_SOURCES} win/twowaypipe.cpp @@ -32,10 +27,6 @@ if(CLR_CMAKE_HOST_UNIX) add_definitions(-DPAL_IMPLEMENTATION) add_definitions(-D_POSIX_C_SOURCE=200809L) - set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-socket.c") - set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX) - set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) - set(TWO_WAY_PIPE_SOURCES ${EVENTPIPE_PAL_SOURCES} unix/twowaypipe.cpp @@ -45,3 +36,11 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) add_library_clr(debug-pal OBJECT ${TWO_WAY_PIPE_SOURCES}) + +target_link_libraries(debug-pal PRIVATE dn-diagnosticserver-pal) + +# The DiagnosticServer Runtime implementation in CoreCLR is C++, +# but the Diagnostic Server PAL is written in C. +# Override those files to build as C++. +get_property(ds_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES) +set_source_files_properties(${ds_pal_sources} PROPERTIES LANGUAGE CXX) diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index df6cbe47ad244f..a0d5739713cd35 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -28,41 +28,6 @@ add_custom_command(OUTPUT ${GEN_EVENTPIPE_SOURCES} COMMAND ${GENERATE_COMMAND} DEPENDS ${GENERATE_SCRIPT} ${EVENT_MANIFEST} ${EVENT_EXCLUSIONS}) -set (EVENTPIPE_SOURCES "") -set (EVENTPIPE_HEADERS "") -set (CORECLR_EVENTPIPE_SHIM_SOURCES "") -set (CORECLR_EVENTPIPE_SHIM_HEADERS "") - -set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers") -set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") -set (CORECLR_EVENTPIPE_SHIM_SOURCE_PATH "${CORECLR_EVENTPIPE_SHIM_DIR}") - -include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake) - -list(APPEND EVENTPIPE_SOURCES - ${SHARED_EVENTPIPE_SOURCES} - ${SHARED_DIAGNOSTIC_SERVER_SOURCES} -) - -list(APPEND EVENTPIPE_HEADERS - ${SHARED_EVENTPIPE_HEADERS} - ${SHARED_DIAGNOSTIC_SERVER_HEADERS} -) - -addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}") -addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS}") - -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) - -set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES LANGUAGE CXX) -set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX) - -if(CLR_CMAKE_HOST_UNIX) - set_source_files_properties(${CONTAINER_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) - set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) -endif(CLR_CMAKE_HOST_UNIX) - list(APPEND CORECLR_EVENTPIPE_SHIM_SOURCES ep-rt-coreclr.cpp ) @@ -75,27 +40,22 @@ list(APPEND CORECLR_EVENTPIPE_SHIM_HEADERS ep-rt-types-coreclr.h ) -addprefix(CORECLR_EVENTPIPE_SHIM_SOURCES ${CORECLR_EVENTPIPE_SHIM_SOURCE_PATH} "${CORECLR_EVENTPIPE_SHIM_SOURCES}") -addprefix(CORECLR_EVENTPIPE_SHIM_HEADERS ${CORECLR_EVENTPIPE_SHIM_SOURCE_PATH} "${CORECLR_EVENTPIPE_SHIM_HEADERS}") - - -list(APPEND EVENTPIPE_SOURCES - ${CORECLR_EVENTPIPE_SHIM_SOURCES} - ${CORECLR_EVENTPIPE_SHIM_HEADERS} - ${EVENTPIPE_HEADERS} - ${SHARED_EVENTPIPE_CONFIG_HEADERS} -) - add_library_clr(eventpipe_gen_objs OBJECT ${GEN_EVENTPIPE_SOURCES}) target_precompile_headers(eventpipe_gen_objs PRIVATE [["common.h"]]) set_target_properties(eventpipe_gen_objs PROPERTIES LINKER_LANGUAGE CXX) add_dependencies(eventpipe_gen_objs eventing_headers) -add_library_clr(eventpipe_objs OBJECT ${EVENTPIPE_SOURCES}) +add_library_clr(eventpipe_objs OBJECT ${CORECLR_EVENTPIPE_SHIM_SOURCES} ${CORECLR_EVENTPIPE_SHIM_HEADERS}) target_precompile_headers(eventpipe_objs PRIVATE [["common.h"]]) set_target_properties(eventpipe_objs PROPERTIES LINKER_LANGUAGE CXX) add_dependencies(eventpipe_objs eventing_headers) -target_link_libraries(eventpipe_objs INTERFACE dn-containers) +target_link_libraries(eventpipe_objs PRIVATE dn-diagnosticserver dn-eventpipe) + +# The CoreCLR EventPipe runtime is C++, but the EventPipe and DiagnosticServer sources are C. +# Forcibly override them to build as C++. +get_property(diagnosticserver_sources TARGET dn-diagnosticserver PROPERTY INTERFACE_SOURCES) +get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) +set_source_files_properties(${diagnosticserver_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) add_library(eventpipe INTERFACE) target_sources(eventpipe INTERFACE $ $ $) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt new file mode 100644 index 00000000000000..518135fb491ab8 --- /dev/null +++ b/src/native/eventpipe/CMakeLists.txt @@ -0,0 +1,76 @@ +include(CheckSymbolExists) + +check_symbol_exists( + accept4 + sys/socket.h + HAVE_ACCEPT4) + +if (NOT DEFINED EP_GENERATED_HEADER_PATH) + message(FATAL_ERROR "Required configuration EP_GENERATED_HEADER_PATH not set.") +endif (NOT DEFINED EP_GENERATED_HEADER_PATH) + +configure_file(${CLR_SRC_NATIVE_DIR}/eventpipe/ep-shared-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/ep-shared-config.h) + +set (SHARED_EVENTPIPE_CONFIG_HEADERS "${EP_GENERATED_HEADER_PATH}/ep-shared-config.h") + +add_library(dn-diagnosticserver INTERFACE) + +target_sources(dn-diagnosticserver INTERFACE + ds-sources.c + ds-dump-protocol.c + ds-eventpipe-protocol.c + ds-ipc.c + ds-process-protocol.c + ds-profiler-protocol.c + ds-protocol.c + ds-server.c) + +target_include_directories(dn-diagnosticserver INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) + +add_library(dn-diagnosticserver-pal INTERFACE) +target_include_directories(dn-diagnosticserver-pal INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) + +if (FEATURE_PERFTRACING_PAL_TCP) + target_sources(dn-diagnosticserver-pal INTERFACE + ds-ipc-pal-socket.c + ) +elseif(HOST_WIN32 OR CLR_CMAKE_TARGET_WIN32) + target_sources(dn-diagnosticserver-pal INTERFACE + ds-ipc-pal-namedpipe.c + ) +else() + target_sources(dn-diagnosticserver-pal INTERFACE + ds-ipc-pal-socket.c + ) +endif (FEATURE_PERFTRACING_PAL_TCP) + + +add_library(dn-eventpipe INTERFACE) +target_sources(dn-eventpipe INTERFACE + ep-sources.c + ep.c + ep-block.c + ep-buffer.c + ep-buffer-manager.c + ep-config.c + ep-event.c + ep-event-instance.c + ep-event-payload.c + ep-event-source.c + ep-file.c + ep-json-file.c + ep-metadata-generator.c + ep-provider.c + ep-sample-profiler.c + ep-session.c + ep-session-provider.c + ep-stack-contents.c + ep-stream.c + ep-string.c + ep-thread.c) + +target_include_directories(dn-eventpipe INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) + +# Build EventPipe and DiagnosticServer as unity-builds. +set_source_files_properties(ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) +set_source_files_properties(ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) diff --git a/src/native/eventpipe/ep-shared-config.h.in b/src/native/eventpipe/ep-shared-config.h.in index 9fd64d11c0dfc5..7f27754ad2d8d0 100644 --- a/src/native/eventpipe/ep-shared-config.h.in +++ b/src/native/eventpipe/ep-shared-config.h.in @@ -4,4 +4,24 @@ /* This platforms supports setting flags atomically when accepting connections. */ #cmakedefine01 HAVE_ACCEPT4 -#endif //EP_SHARED_CONFIG_H_INCLUDED \ No newline at end of file +#cmakedefine FEATURE_PERFTRACING_PAL_TCP +#ifdef FEATURE_PERFTRACING_PAL_TCP +#define ENABLE_PERFTRACING_PAL_TCP +#endif + +#cmakedefine FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS +#ifdef FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS +#define DISABLE_PERFTRACING_LISTEN_PORTS +#endif + +#cmakedefine FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT +#ifdef FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT +#define DISABLE_PERFTRACING_DEFAULT_LISTEN_PORT +#endif + +#cmakedefine FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS +#ifdef FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS +#define DISABLE_PERFTRACING_CONNECT_PORTS +#endif + +#endif //EP_SHARED_CONFIG_H_INCLUDED From 39118f0349f059ccf15ff157e03903fb15120cf0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 14:53:37 -0700 Subject: [PATCH 04/31] Move NativeAOT over to the new model as well. --- .../Runtime/eventpipe/CMakeLists.txt | 74 +++++-------------- .../vm/eventing/eventpipe/CMakeLists.txt | 5 ++ src/native/eventpipe/CMakeLists.txt | 14 ++-- 3 files changed, 29 insertions(+), 64 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 6044124a9702ba..7eb6e8cde19f83 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -108,42 +108,14 @@ set(AOT_EVENTPIPE_SHIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set (MINIPAL_SOURCES "") set (EVENTPIPE_SOURCES "") -set (EVENTPIPE_HEADERS "") -# Use TCP for EventPipe on mobile platforms -if (CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID) - set(FEATURE_PERFTRACING_PAL_TCP 1) - set(FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT 1) -endif() - -set (SHARED_CONTAINERS_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/containers") -set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") set (SHARED_MINIPAL_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/minipal") -include (${SHARED_EVENTPIPE_SOURCE_PATH}/eventpipe.cmake) list(APPEND MINIPAL_SOURCES utf8.c ) -if(CLR_CMAKE_HOST_WIN32) - list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES - ds-ipc-pal-namedpipe.c - ) - - list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS - ds-ipc-pal-namedpipe.h - ) -endif(CLR_CMAKE_HOST_WIN32) - if(CLR_CMAKE_HOST_UNIX) - list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES - ds-ipc-pal-socket.c - ) - - list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS - ds-ipc-pal-socket.h - ) - include(${CLR_SRC_NATIVE_DIR}/minipal/configure.cmake) list(APPEND MINIPAL_SOURCES random.c @@ -151,34 +123,8 @@ if(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_UNIX) -list(APPEND EVENTPIPE_SOURCES - ${SHARED_EVENTPIPE_SOURCES} - ${SHARED_DIAGNOSTIC_SERVER_SOURCES} -) - -list(APPEND EVENTPIPE_HEADERS - ${SHARED_EVENTPIPE_HEADERS} - ${SHARED_DIAGNOSTIC_SERVER_HEADERS} -) - addprefix(MINIPAL_SOURCES ${SHARED_MINIPAL_SOURCE_PATH} "${MINIPAL_SOURCES}") -addprefix(EVENTPIPE_SOURCES ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_SOURCES}") -addprefix(EVENTPIPE_HEADERS ${SHARED_EVENTPIPE_SOURCE_PATH} "${EVENTPIPE_HEADERS}") - -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) - -set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES LANGUAGE CXX) - -if(CLR_CMAKE_HOST_UNIX) - set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) -endif(CLR_CMAKE_HOST_UNIX) - -if (CLR_CMAKE_TARGET_WIN32) - set_source_files_properties(${EVENTPIPE_SOURCES} PROPERTIES COMPILE_FLAGS "/FI\"${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"") -endif() - list(APPEND AOT_EVENTPIPE_SHIM_SOURCES ${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-aot.cpp ${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.cpp @@ -222,6 +168,17 @@ if (FEATURE_EVENT_TRACE) endif() endif() +# The NativeAOT EventPipe runtime is C++, but the EventPipe and DiagnosticServer sources are C. +# Forcibly override them to build as C++. +get_property(diagnosticserver_sources TARGET dn-diagnosticserver PROPERTY INTERFACE_SOURCES) +get_property(diagnosticserver_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES) +get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) +set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) + +if (CLR_CMAKE_TARGET_WIN32) + set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} + PROPERTIES COMPILE_FLAGS "/FI\"${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"") +endif() list(APPEND EVENTPIPE_SOURCES @@ -243,8 +200,14 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES ${GEN_EVENTPIPE_PLAT_AGNOSTIC_DISABLED_SOURCES} ) +# Build EventPipe and DiagnosticServer as unity-builds. +set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") +set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) +set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) + + add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES}) -target_link_libraries(eventpipe-enabled PRIVATE dn-containers) +target_link_libraries(eventpipe-enabled PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) add_dependencies(eventpipe-enabled aot_eventing_headers) if(CLR_CMAKE_TARGET_WIN32) add_dependencies(eventpipe-enabled aot_etw_headers) @@ -255,6 +218,7 @@ add_dependencies(eventpipe-disabled aot_eventing_headers) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) + target_link_libraries(eventpipe-enabled.GuardCF PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) target_link_libraries(eventpipe-enabled.GuardCF PRIVATE dn-containers) diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index a0d5739713cd35..a8a7346c5d1c25 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -57,5 +57,10 @@ get_property(diagnosticserver_sources TARGET dn-diagnosticserver PROPERTY INTERF get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) set_source_files_properties(${diagnosticserver_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) +# Build EventPipe and DiagnosticServer as unity-builds. +set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") +set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) +set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) + add_library(eventpipe INTERFACE) target_sources(eventpipe INTERFACE $ $ $) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index 518135fb491ab8..4e0f9e1d435908 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -5,14 +5,14 @@ check_symbol_exists( sys/socket.h HAVE_ACCEPT4) -if (NOT DEFINED EP_GENERATED_HEADER_PATH) - message(FATAL_ERROR "Required configuration EP_GENERATED_HEADER_PATH not set.") -endif (NOT DEFINED EP_GENERATED_HEADER_PATH) +# Use TCP for EventPipe on mobile platforms +if (CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID) + set(FEATURE_PERFTRACING_PAL_TCP 1) + set(FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT 1) +endif() configure_file(${CLR_SRC_NATIVE_DIR}/eventpipe/ep-shared-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/ep-shared-config.h) -set (SHARED_EVENTPIPE_CONFIG_HEADERS "${EP_GENERATED_HEADER_PATH}/ep-shared-config.h") - add_library(dn-diagnosticserver INTERFACE) target_sources(dn-diagnosticserver INTERFACE @@ -70,7 +70,3 @@ target_sources(dn-eventpipe INTERFACE ep-thread.c) target_include_directories(dn-eventpipe INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) - -# Build EventPipe and DiagnosticServer as unity-builds. -set_source_files_properties(ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) From b7e9e821fa3087998560114ffff0d2902f330425 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 15:24:51 -0700 Subject: [PATCH 05/31] Move Mono to the new eventpipe model --- src/mono/mono/component/CMakeLists.txt | 19 ++++++++++--- src/mono/mono/eventpipe/eventpipe.cmake | 33 +++------------------- src/native/eventpipe/ep-shared-config.h.in | 7 +++++ 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index bf18310a7a37a8..a4a5c8c32ce925 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -10,6 +10,7 @@ set(MONO_DEBUGGER_COMPONENT_NAME "debugger") set(MONO_MARSHAL_ILGEN_COMPONENT_NAME "marshal-ilgen") add_subdirectory(${SHARED_CONTAINERS_SOURCE_PATH} containers) +add_subdirectory(${SHARED_EVENTPIPE_SOURCE_PATH} eventpipe) # a list of every component. set(components "") @@ -140,6 +141,16 @@ function(define_component_libs) endif() endfunction() +function(component_link_libraries component) + # Link the provided libraries to each target for the component that is defined + if (TARGET ${component}-objects) + target_link_libraries(${component}-objects ${ARGN}) + endif() + if (TARGET mono-component-${component}) + target_link_libraries(mono-component-${component} ${ARGN}) + endif() +endfunction() + # a generic component interface that all components implement add_library(component_base INTERFACE) target_sources(component_base INTERFACE @@ -167,10 +178,6 @@ foreach(component IN LISTS components) target_link_libraries("${component}-stub-objects" PUBLIC eglib_api) endforeach() -if (TARGET "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects") - target_link_libraries("${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects" PRIVATE dn-containers) -endif() - if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS) # define a shared library for each component foreach(component IN LISTS components_to_build) @@ -218,6 +225,10 @@ elseif(AOT_COMPONENTS OR (NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS)) endif() +if (ENABLE_PERFTRACING) + component_link_libraries(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE dn-containers dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) +endif() + # define a list of mono-components-stubs objects that will be linked into # the runtime to be used as fallbacks if the dynamic components are not # available or when only static component stubs are requested. diff --git a/src/mono/mono/eventpipe/eventpipe.cmake b/src/mono/mono/eventpipe/eventpipe.cmake index 0c53e88d3ebb4b..3feda481e359ce 100644 --- a/src/mono/mono/eventpipe/eventpipe.cmake +++ b/src/mono/mono/eventpipe/eventpipe.cmake @@ -1,17 +1,6 @@ include(${MONO_EVENTPIPE_SHIM_SOURCE_PATH}/gen-eventing.cmake) -# For feature detection to work correctly, this needs to be outside of the conditional. -set(EP_GENERATED_HEADER_PATH "${MONO_EVENTPIPE_GEN_INCLUDE_PATH}") -include(${SHARED_EVENTPIPE_SOURCE_PATH}configure.cmake) - if(ENABLE_PERFTRACING) - - if (TARGET_S390X) - add_definitions(-DBIGENDIAN) - endif (TARGET_S390X) - - include (${SHARED_EVENTPIPE_SOURCE_PATH}eventpipe.cmake) - set(MONO_EVENTPIPE_SHIM_SOURCES "") set(MONO_EVENTPIPE_SHIM_HEADERS "") @@ -39,24 +28,10 @@ if(ENABLE_PERFTRACING) ds-rt-types-mono.h ) - set(shared_eventpipe_sources_base "") set(mono_eventpipe_shim_sources_base "") - set(shared_diagnostic_server_sources_base "") set(mono_diagnostic_server_shim_sources_base "") - list(APPEND shared_eventpipe_sources_base - ${SHARED_EVENTPIPE_SOURCES} - ${SHARED_EVENTPIPE_HEADERS} - ) - - list(APPEND shared_diagnostic_server_sources_base - ${SHARED_DIAGNOSTIC_SERVER_SOURCES} - ${SHARED_DIAGNOSTIC_SERVER_HEADERS} - ${SHARED_DIAGNOSTIC_SERVER_PAL_SOURCES} - ${SHARED_DIAGNOSTIC_SERVER_PAL_HEADERS} - ) - list(APPEND mono_eventpipe_shim_sources_base ${MONO_EVENTPIPE_SHIM_SOURCES} ${MONO_EVENTPIPE_SHIM_HEADERS} @@ -67,15 +42,15 @@ if(ENABLE_PERFTRACING) ${MONO_DIAGNOSTIC_SERVER_SHIM_HEADERS} ) - addprefix(shared_eventpipe_sources_base ${SHARED_EVENTPIPE_SOURCE_PATH} "${shared_eventpipe_sources_base}") addprefix(mono_eventpipe_shim_sources_base ${MONO_EVENTPIPE_SHIM_SOURCE_PATH} "${mono_eventpipe_shim_sources_base}") - addprefix(shared_diagnostic_server_sources_base ${SHARED_EVENTPIPE_SOURCE_PATH} "${shared_diagnostic_server_sources_base}") addprefix(mono_diagnostic_server_shim_sources_base ${MONO_EVENTPIPE_SHIM_SOURCE_PATH} "${mono_diagnostic_server_shim_sources_base}") - set(eventpipe_sources ${shared_eventpipe_sources_base} ${SHARED_EVENTPIPE_CONFIG_HEADERS} ${mono_eventpipe_shim_sources_base} ${MONO_EVENTPIPE_GEN_HEADERS} ${MONO_EVENTPIPE_GEN_SOURCES}) - set(diagnostic_server_sources ${shared_diagnostic_server_sources_base} ${mono_diagnostic_server_shim_sources_base}) + set(eventpipe_sources ${mono_eventpipe_shim_sources_base} ${MONO_EVENTPIPE_GEN_HEADERS} ${MONO_EVENTPIPE_GEN_SOURCES}) + set(diagnostic_server_sources ${mono_diagnostic_server_shim_sources_base}) + # Build EventPipe and DiagnosticServer as unity-builds. + set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) diff --git a/src/native/eventpipe/ep-shared-config.h.in b/src/native/eventpipe/ep-shared-config.h.in index 7f27754ad2d8d0..188f55fd32170c 100644 --- a/src/native/eventpipe/ep-shared-config.h.in +++ b/src/native/eventpipe/ep-shared-config.h.in @@ -24,4 +24,11 @@ #define DISABLE_PERFTRACING_CONNECT_PORTS #endif +#define CMAKE_C_BYTE_ORDER_LITTLE_ENDIAN 0 +#define CMAKE_C_BYTE_ORDER_BIG_ENDIAN 1 +#cmakedefine CMAKE_C_BYTE_ORDER CMAKE_C_BYTE_ORDER_@CMAKE_C_BYTE_ORDER@ +#if CMAKE_C_BYTE_ORDER == CMAKE_C_BYTE_ORDER_BIG_ENDIAN +#define BIGENDIAN +#endif + #endif //EP_SHARED_CONFIG_H_INCLUDED From 82562ffda1b626846ed59c08068022e688031c50 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 17:02:47 -0700 Subject: [PATCH 06/31] Remove old eventpipe model --- src/native/eventpipe/eventpipe.cmake | 133 --------------------------- 1 file changed, 133 deletions(-) delete mode 100644 src/native/eventpipe/eventpipe.cmake diff --git a/src/native/eventpipe/eventpipe.cmake b/src/native/eventpipe/eventpipe.cmake deleted file mode 100644 index 6e093d39b5092b..00000000000000 --- a/src/native/eventpipe/eventpipe.cmake +++ /dev/null @@ -1,133 +0,0 @@ -if(ENABLE_PERFTRACING OR FEATURE_PERFTRACING) - set (SHARED_EVENTPIPE_SOURCES "") - set (SHARED_EVENTPIPE_HEADERS "") - set (SHARED_DIAGNOSTIC_SERVER_SOURCES "") - set (SHARED_DIAGNOSTIC_SERVER_HEADERS "") - - if (FEATURE_PERFTRACING_PAL_TCP) - add_definitions(-DENABLE_PERFTRACING_PAL_TCP) - endif (FEATURE_PERFTRACING_PAL_TCP) - - if (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS) - add_definitions(-DDISABLE_PERFTRACING_LISTEN_PORTS) - endif (FEATURE_PERFTRACING_DISABLE_PERFTRACING_LISTEN_PORTS) - - if (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT) - add_definitions(-DDISABLE_PERFTRACING_DEFAULT_LISTEN_PORT) - endif (FEATURE_PERFTRACING_DISABLE_DEFAULT_LISTEN_PORT) - - if (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS) - add_definitions(-DDISABLE_PERFTRACING_CONNECT_PORTS) - endif (FEATURE_PERFTRACING_DISABLE_CONNECT_PORTS) - - list(APPEND SHARED_EVENTPIPE_SOURCES - ep-sources.c - ep.c - ep-block.c - ep-buffer.c - ep-buffer-manager.c - ep-config.c - ep-event.c - ep-event-instance.c - ep-event-payload.c - ep-event-source.c - ep-file.c - ep-json-file.c - ep-metadata-generator.c - ep-provider.c - ep-sample-profiler.c - ep-session.c - ep-session-provider.c - ep-stack-contents.c - ep-stream.c - ep-string.c - ep-thread.c - ) - - list(APPEND SHARED_EVENTPIPE_HEADERS - ep.h - ep-block.h - ep-buffer.h - ep-buffer-manager.h - ep-config.h - ep-config-internals.h - ep-event.h - ep-event-instance.h - ep-event-payload.h - ep-event-source.h - ep-file.h - ep-getter-setter.h - ep-ipc-pal-types.h - ep-ipc-pal-types-forward.h - ep-ipc-stream.h - ep-json-file.h - ep-metadata-generator.h - ep-provider.h - ep-provider-internals.h - ep-rt.h - ep-rt-config.h - ep-rt-types.h - ep-sample-profiler.h - ep-session.h - ep-session-provider.h - ep-stack-contents.h - ep-stream.h - ep-string.h - ep-thread.h - ep-types.h - ep-types-forward.h - ) - - list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES - ds-sources.c - ds-dump-protocol.c - ds-eventpipe-protocol.c - ds-ipc.c - ds-process-protocol.c - ds-profiler-protocol.c - ds-protocol.c - ds-server.c - ) - - list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS - ds-dump-protocol.h - ds-eventpipe-protocol.h - ds-getter-setter.h - ds-ipc.h - ds-ipc-pal.h - ds-ipc-pal-types.h - ds-process-protocol.h - ds-profiler-protocol.h - ds-protocol.h - ds-rt.h - ds-rt-config.h - ds-rt-types.h - ds-server.h - ds-types.h - ) - if (FEATURE_PERFTRACING_PAL_TCP) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_SOURCES - ds-ipc-pal-socket.c - ) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_HEADERS - ds-ipc-pal-socket.h - ) - else (FEATURE_PERFTRACING_PAL_TCP) - if(HOST_WIN32 OR CLR_CMAKE_TARGET_WIN32) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_SOURCES - ds-ipc-pal-namedpipe.c - ) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_HEADERS - ds-ipc-pal-namedpipe.h - ) - else(HOST_WIN32 OR CLR_CMAKE_TARGET_WIN32) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_SOURCES - ds-ipc-pal-socket.c - ) - list(APPEND SHARED_DIAGNOSTIC_SERVER_PAL_HEADERS - ds-ipc-pal-socket.h - ) - endif(HOST_WIN32 OR CLR_CMAKE_TARGET_WIN32) - endif (FEATURE_PERFTRACING_PAL_TCP) - -endif(ENABLE_PERFTRACING OR FEATURE_PERFTRACING) From 7332da4768e3c47af903cd0402774dfba9f9c8bf Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 17:03:36 -0700 Subject: [PATCH 07/31] Use CMake's Unity Build support instead of our own hacked-together version. --- .../Runtime/eventpipe/CMakeLists.txt | 44 +++++++++++++------ .../vm/eventing/eventpipe/CMakeLists.txt | 8 ++-- src/mono/mono/component/CMakeLists.txt | 28 +++++++----- src/mono/mono/eventpipe/eventpipe.cmake | 5 --- src/native/eventpipe/CMakeLists.txt | 3 +- .../{ds-sources.c => ds-portable-rid.c} | 17 ------- src/native/eventpipe/ep-rt-config.h | 6 +-- src/native/eventpipe/ep-sources.c | 35 --------------- 8 files changed, 54 insertions(+), 92 deletions(-) rename src/native/eventpipe/{ds-sources.c => ds-portable-rid.c} (74%) delete mode 100644 src/native/eventpipe/ep-sources.c diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 7eb6e8cde19f83..61459aa226fe20 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -175,18 +175,34 @@ get_property(diagnosticserver_pal_sources TARGET dn-diagnosticserver-pal PROPERT get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) +add_library(eventpipe-shared-objects OBJECT) +target_link_libraries(eventpipe-shared-objects PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) +# Build EventPipe and DiagnosticServer as unity-builds for better inlining. +set_target_properties(eventpipe-shared-objects PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 0 +) if (CLR_CMAKE_TARGET_WIN32) - set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} - PROPERTIES COMPILE_FLAGS "/FI\"${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h\"") -endif() + add_library(eventpipe-shared-objects.GuardCF OBJECT) + target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) + + target_compile_options(eventpipe-shared-objects PRIVATE + "/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h") + target_compile_options(eventpipe-shared-objects.GuardCF PRIVATE + "/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h") + + # Build EventPipe and DiagnosticServer as unity-builds for better inlining. + set_target_properties(eventpipe-shared-objects.GuardCF PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 0 + CLR_CONTROL_FLOW_GUARD ON) +endif() list(APPEND EVENTPIPE_SOURCES ${AOT_EVENTPIPE_SHIM_SOURCES} - ${AOT_EVENTPIPE_SHIM_HEADERS} ${AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES} ${AOT_EVENTTRACE_SOURCES} - ${SHARED_EVENTPIPE_CONFIG_HEADERS} ${GEN_EVENTPIPE_PROVIDER_SOURCES} ${GEN_EVENTPIPE_PLAT_AGNOSTIC_SOURCES} ${MINIPAL_SOURCES} @@ -200,14 +216,9 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES ${GEN_EVENTPIPE_PLAT_AGNOSTIC_DISABLED_SOURCES} ) -# Build EventPipe and DiagnosticServer as unity-builds. -set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) - - add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES}) -target_link_libraries(eventpipe-enabled PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) + +target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects) add_dependencies(eventpipe-enabled aot_eventing_headers) if(CLR_CMAKE_TARGET_WIN32) add_dependencies(eventpipe-enabled aot_etw_headers) @@ -218,10 +229,15 @@ add_dependencies(eventpipe-disabled aot_eventing_headers) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) - target_link_libraries(eventpipe-enabled.GuardCF PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) + + set_target_properties(eventpipe-enabled.GuardCF PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 0 + ) + + target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) - target_link_libraries(eventpipe-enabled.GuardCF PRIVATE dn-containers) add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) add_dependencies(eventpipe-disabled.GuardCF aot_eventing_headers) set_target_properties(eventpipe-enabled.GuardCF PROPERTIES CLR_CONTROL_FLOW_GUARD ON) diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index a8a7346c5d1c25..054a90b4d5c3d9 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -47,7 +47,11 @@ add_dependencies(eventpipe_gen_objs eventing_headers) add_library_clr(eventpipe_objs OBJECT ${CORECLR_EVENTPIPE_SHIM_SOURCES} ${CORECLR_EVENTPIPE_SHIM_HEADERS}) target_precompile_headers(eventpipe_objs PRIVATE [["common.h"]]) -set_target_properties(eventpipe_objs PROPERTIES LINKER_LANGUAGE CXX) +set_target_properties(eventpipe_objs PROPERTIES + LINKER_LANGUAGE CXX + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 0 +) add_dependencies(eventpipe_objs eventing_headers) target_link_libraries(eventpipe_objs PRIVATE dn-diagnosticserver dn-eventpipe) @@ -59,8 +63,6 @@ set_source_files_properties(${diagnosticserver_sources} ${eventpipe_sources} PRO # Build EventPipe and DiagnosticServer as unity-builds. set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) -set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) add_library(eventpipe INTERFACE) target_sources(eventpipe INTERFACE $ $ $) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index a4a5c8c32ce925..180c918e763522 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -141,16 +141,6 @@ function(define_component_libs) endif() endfunction() -function(component_link_libraries component) - # Link the provided libraries to each target for the component that is defined - if (TARGET ${component}-objects) - target_link_libraries(${component}-objects ${ARGN}) - endif() - if (TARGET mono-component-${component}) - target_link_libraries(mono-component-${component} ${ARGN}) - endif() -endfunction() - # a generic component interface that all components implement add_library(component_base INTERFACE) target_sources(component_base INTERFACE @@ -226,7 +216,23 @@ elseif(AOT_COMPONENTS OR (NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS)) endif() if (ENABLE_PERFTRACING) - component_link_libraries(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE dn-containers dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) + # Build EventPipe and DiagnosticServer with the Mono runtime implementation as unity-builds. + add_library(eventpipe-mono-objects OBJECT) + set_target_properties( + eventpipe-mono-objects + PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 0 + ) + target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-containers dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) + # Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries. + if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects) + target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $) + endif() + if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) + target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE eventpipe-mono-objects) + endif() + list(APPEND mono-components-objects $) endif() # define a list of mono-components-stubs objects that will be linked into diff --git a/src/mono/mono/eventpipe/eventpipe.cmake b/src/mono/mono/eventpipe/eventpipe.cmake index 3feda481e359ce..642173c80dea1c 100644 --- a/src/mono/mono/eventpipe/eventpipe.cmake +++ b/src/mono/mono/eventpipe/eventpipe.cmake @@ -49,9 +49,4 @@ if(ENABLE_PERFTRACING) set(eventpipe_sources ${mono_eventpipe_shim_sources_base} ${MONO_EVENTPIPE_GEN_HEADERS} ${MONO_EVENTPIPE_GEN_SOURCES}) set(diagnostic_server_sources ${mono_diagnostic_server_shim_sources_base}) - # Build EventPipe and DiagnosticServer as unity-builds. - set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") - set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ep-sources.c PROPERTIES COMPILE_DEFINITIONS EP_FORCE_INCLUDE_SOURCE_FILES) - set_source_files_properties(${SHARED_EVENTPIPE_SOURCE_PATH}/ds-sources.c PROPERTIES COMPILE_DEFINITIONS DS_FORCE_INCLUDE_SOURCE_FILES) - endif(ENABLE_PERFTRACING) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index 4e0f9e1d435908..ed9d787fc46ad0 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -16,10 +16,10 @@ configure_file(${CLR_SRC_NATIVE_DIR}/eventpipe/ep-shared-config.h.in ${CMAKE_CUR add_library(dn-diagnosticserver INTERFACE) target_sources(dn-diagnosticserver INTERFACE - ds-sources.c ds-dump-protocol.c ds-eventpipe-protocol.c ds-ipc.c + ds-portable-rid.c ds-process-protocol.c ds-profiler-protocol.c ds-protocol.c @@ -47,7 +47,6 @@ endif (FEATURE_PERFTRACING_PAL_TCP) add_library(dn-eventpipe INTERFACE) target_sources(dn-eventpipe INTERFACE - ep-sources.c ep.c ep-block.c ep-buffer.c diff --git a/src/native/eventpipe/ds-sources.c b/src/native/eventpipe/ds-portable-rid.c similarity index 74% rename from src/native/eventpipe/ds-sources.c rename to src/native/eventpipe/ds-portable-rid.c index 35e5568ca98b14..ff7950729f5a1f 100644 --- a/src/native/eventpipe/ds-sources.c +++ b/src/native/eventpipe/ds-portable-rid.c @@ -4,20 +4,6 @@ #include "ds-types.h" -// Option to include all internal source files into ds-sources.c. -#ifdef DS_INCLUDE_SOURCE_FILES -#ifndef DS_FORCE_INCLUDE_SOURCE_FILES -#define DS_FORCE_INCLUDE_SOURCE_FILES -#endif -#include "ds-server.c" -#include "ds-eventpipe-protocol.c" -#include "ds-dump-protocol.c" -#include "ds-ipc.c" -#include "ds-process-protocol.c" -#include "ds-profiler-protocol.c" -#include "ds-protocol.c" -#endif - #undef PORTABLE_RID_OS #if defined(TARGET_BROWSER) @@ -75,6 +61,3 @@ const ep_char8_t* _ds_portable_rid_info = PORTABLE_RID_OS "-" PORTABLE_RID_ARCH; #endif /* ENABLE_PERFTRACING */ - -extern const char quiet_linker_empty_file_warning_diagnostics_sources; -const char quiet_linker_empty_file_warning_diagnostics_sources = 0; diff --git a/src/native/eventpipe/ep-rt-config.h b/src/native/eventpipe/ep-rt-config.h index ea4475227339a9..040b853b989d28 100644 --- a/src/native/eventpipe/ep-rt-config.h +++ b/src/native/eventpipe/ep-rt-config.h @@ -16,7 +16,7 @@ #define DS_RT_H #define DS_RT_TYPES_H -#elif defined(FEATURE_CORECLR) +#elif defined(FEATURE_CORECLR) #ifndef EP_NO_RT_DEPENDENCY #include "common.h" @@ -76,8 +76,4 @@ #define EP_INLINE_GETTER_SETTER -#ifdef EP_INLINE_GETTER_SETTER -#define EP_INCLUDE_SOURCE_FILES -#endif - #endif /* __EVENTPIPE_RT_CONFIG_H__ */ diff --git a/src/native/eventpipe/ep-sources.c b/src/native/eventpipe/ep-sources.c deleted file mode 100644 index 6c1822e218438d..00000000000000 --- a/src/native/eventpipe/ep-sources.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "ep-rt-config.h" - -#ifdef ENABLE_PERFTRACING - -// Option to include all internal source files into ep-sources.c. -#ifdef EP_INCLUDE_SOURCE_FILES -#ifndef EP_FORCE_INCLUDE_SOURCE_FILES -#define EP_FORCE_INCLUDE_SOURCE_FILES -#endif -#include "ep.c" -#include "ep-block.c" -#include "ep-buffer.c" -#include "ep-buffer-manager.c" -#include "ep-config.c" -#include "ep-event.c" -#include "ep-event-instance.c" -#include "ep-event-payload.c" -#include "ep-event-source.c" -#include "ep-file.c" -#include "ep-json-file.c" -#include "ep-metadata-generator.c" -#include "ep-provider.c" -#include "ep-sample-profiler.c" -#include "ep-session.c" -#include "ep-session-provider.c" -#include "ep-stack-contents.c" -#include "ep-stream.c" -#include "ep-string.c" -#include "ep-thread.c" -#endif - -#endif /* ENABLE_PERFTRACING */ - -extern const char quiet_linker_empty_file_warning_eventpipe_sources; -const char quiet_linker_empty_file_warning_eventpipe_sources = 0; From 2f8f3618bd4feffb0786d216cf378d7cd09841e9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 17:10:34 -0700 Subject: [PATCH 08/31] Flow dn_containers dependency --- src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt | 4 ++-- src/mono/mono/component/CMakeLists.txt | 2 +- src/native/eventpipe/CMakeLists.txt | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 61459aa226fe20..85bf0a804d7854 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -176,7 +176,7 @@ get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) add_library(eventpipe-shared-objects OBJECT) -target_link_libraries(eventpipe-shared-objects PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) +target_link_libraries(eventpipe-shared-objects PRIVATE dn-diagnosticserver dn-eventpipe) # Build EventPipe and DiagnosticServer as unity-builds for better inlining. set_target_properties(eventpipe-shared-objects PROPERTIES UNITY_BUILD ON @@ -184,7 +184,7 @@ set_target_properties(eventpipe-shared-objects PROPERTIES ) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-shared-objects.GuardCF OBJECT) - target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-containers dn-diagnosticserver dn-eventpipe) + target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-diagnosticserver dn-eventpipe) target_compile_options(eventpipe-shared-objects PRIVATE "/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h") diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 180c918e763522..92086d00d85a44 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -224,7 +224,7 @@ if (ENABLE_PERFTRACING) UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 0 ) - target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-containers dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) + target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) # Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries. if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects) target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index ed9d787fc46ad0..8d2e83325c2dce 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -26,9 +26,11 @@ target_sources(dn-diagnosticserver INTERFACE ds-server.c) target_include_directories(dn-diagnosticserver INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(dn-diagnosticserver INTERFACE dn-containers) add_library(dn-diagnosticserver-pal INTERFACE) target_include_directories(dn-diagnosticserver-pal INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(dn-diagnosticserver-pal INTERFACE dn-containers) if (FEATURE_PERFTRACING_PAL_TCP) target_sources(dn-diagnosticserver-pal INTERFACE @@ -69,3 +71,4 @@ target_sources(dn-eventpipe INTERFACE ep-thread.c) target_include_directories(dn-eventpipe INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(dn-eventpipe INTERFACE dn-containers) From bf6bb4731d47bb805519f66e6df22afb92ac3ff4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 7 Jun 2024 17:13:50 -0700 Subject: [PATCH 09/31] Add a comment to explain the rationale for using an INTERFACE lib (as there's very few reasons to use it in this way, but this is one of the scenarios for it). --- src/native/eventpipe/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index 8d2e83325c2dce..15ccd57cc69aba 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -13,6 +13,12 @@ endif() configure_file(${CLR_SRC_NATIVE_DIR}/eventpipe/ep-shared-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/ep-shared-config.h) +# Define the DiagnosticsServer and EventPipe as interface libraries. +# We must define them as interface libraries as each runtime builds the same set of files slightly differently. +# Defining it as an interface library allows us to specify common sources, include directories, dependencies, etc. +# in one place, but also allow each runtime to add any settings that are specific to that runtime. +# This includes, but is not limited to each runtime's implementation of the ds-rt.h and ep-rt.h contracts. + add_library(dn-diagnosticserver INTERFACE) target_sources(dn-diagnosticserver INTERFACE From 062aa32f88831d3c909027563b533781362fb1b5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 Jun 2024 14:43:17 -0700 Subject: [PATCH 10/31] PCH and UNITY_BUILD don't work together well --- src/coreclr/vm/eventing/eventpipe/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index 054a90b4d5c3d9..e6a4ba24e3bead 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -46,7 +46,6 @@ set_target_properties(eventpipe_gen_objs PROPERTIES LINKER_LANGUAGE CXX) add_dependencies(eventpipe_gen_objs eventing_headers) add_library_clr(eventpipe_objs OBJECT ${CORECLR_EVENTPIPE_SHIM_SOURCES} ${CORECLR_EVENTPIPE_SHIM_HEADERS}) -target_precompile_headers(eventpipe_objs PRIVATE [["common.h"]]) set_target_properties(eventpipe_objs PROPERTIES LINKER_LANGUAGE CXX UNITY_BUILD ON From e32ce79d389132da08b1e00883a60be796b82b9d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 Jun 2024 14:44:30 -0700 Subject: [PATCH 11/31] Don't build NativeAOT's EP runtime as a unity build, only the shared sources. --- src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 85bf0a804d7854..3d3b8e985cbc31 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -229,12 +229,6 @@ add_dependencies(eventpipe-disabled aot_eventing_headers) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) - - set_target_properties(eventpipe-enabled.GuardCF PROPERTIES - UNITY_BUILD ON - UNITY_BUILD_BATCH_SIZE 0 - ) - target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) From f428cee5f5909bed1a62bd48bc06e5c146131f4e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 Jun 2024 14:53:18 -0700 Subject: [PATCH 12/31] Add another dependency for dn-containers to try to fix the android build. --- src/mono/mono/component/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 92086d00d85a44..e191fca4fd0616 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -225,6 +225,7 @@ if (ENABLE_PERFTRACING) UNITY_BUILD_BATCH_SIZE 0 ) target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) + target_link_libraries(eventpipe-mono-objects PUBLIC dn-containers) # Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries. if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects) target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $) From ed2a27e9804e176f3d41982c2012869edf720a9f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 Jun 2024 14:56:50 -0700 Subject: [PATCH 13/31] Make the EXTERN_C_* macros into function-style macros --- src/native/containers/dn-allocator.h | 4 ++-- src/native/containers/dn-fwd-list.h | 4 ++-- src/native/containers/dn-list.h | 4 ++-- src/native/containers/dn-queue.h | 4 ++-- src/native/containers/dn-umap.h | 4 ++-- src/native/containers/dn-utils.h | 8 ++++---- src/native/containers/dn-vector-priv.h | 4 ++-- src/native/containers/dn-vector.h | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/native/containers/dn-allocator.h b/src/native/containers/dn-allocator.h index 5fd5f31b081168..c7d443b2439db6 100644 --- a/src/native/containers/dn-allocator.h +++ b/src/native/containers/dn-allocator.h @@ -8,7 +8,7 @@ #include #include -EXTERN_C_BEGIN +EXTERN_C_BEGIN() #define DN_ALLOCATOR_MEM_ALIGN8 8 #define DN_ALLOCATOR_MEM_ALIGN16 16 @@ -106,6 +106,6 @@ dn_allocator_fixed_or_malloc_reset (dn_allocator_fixed_or_malloc_t *allocator); #define DN_DEFAULT_ALLOCATOR NULL #define DN_DEFAULT_LOCAL_ALLOCATOR(var_name, buffer_size) DN_ALLOCATOR_FIXED_OR_MALLOC (var_name, buffer_size) -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_ALLOCATOR_H__ */ diff --git a/src/native/containers/dn-fwd-list.h b/src/native/containers/dn-fwd-list.h index a7fd275bd4c066..4fc19688edbbd0 100644 --- a/src/native/containers/dn-fwd-list.h +++ b/src/native/containers/dn-fwd-list.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() typedef int32_t (DN_CALLBACK_CALLTYPE *dn_fwd_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_fwd_list_equal_func_t) (const void *a, const void *b); @@ -323,6 +323,6 @@ dn_fwd_list_find ( return dn_fwd_list_custom_find (list, data, NULL); } -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_FWD_LIST_H__ */ diff --git a/src/native/containers/dn-list.h b/src/native/containers/dn-list.h index 3e77eef842dce6..673e3b5baacfe3 100644 --- a/src/native/containers/dn-list.h +++ b/src/native/containers/dn-list.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() typedef int32_t (DN_CALLBACK_CALLTYPE *dn_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_list_equal_func_t) (const void *a, const void *b); @@ -373,6 +373,6 @@ dn_list_find ( return dn_list_custom_find (list, data, NULL); } -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_LIST_H__ */ diff --git a/src/native/containers/dn-queue.h b/src/native/containers/dn-queue.h index 75e3b2279e8a68..67838e5c0f5c59 100644 --- a/src/native/containers/dn-queue.h +++ b/src/native/containers/dn-queue.h @@ -8,7 +8,7 @@ #include "dn-allocator.h" #include "dn-list.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() typedef void (DN_CALLBACK_CALLTYPE *dn_queue_dispose_func_t) (void *data); @@ -146,6 +146,6 @@ dn_queue_clear (dn_queue_t *queue) dn_queue_custom_clear (queue, NULL); } -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_QUEUE_H__ */ diff --git a/src/native/containers/dn-umap.h b/src/native/containers/dn-umap.h index 549e475fd83259..7fa50ca5a16f9b 100644 --- a/src/native/containers/dn-umap.h +++ b/src/native/containers/dn-umap.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() typedef uint32_t (DN_CALLBACK_CALLTYPE *dn_umap_hash_func_t) (const void *key); typedef bool (DN_CALLBACK_CALLTYPE *dn_umap_equal_func_t) (const void *a, const void *b); @@ -276,6 +276,6 @@ uint32_t DN_CALLBACK_CALLTYPE dn_str_hash (const void *v1); -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_UMAP_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index b4f7cc3b4c3dc8..4463f369f96127 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -7,13 +7,13 @@ #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#define EXTERN_C_BEGIN extern "C" { -#define EXTERN_C_END } +#define EXTERN_C_BEGIN() extern "C" { +#define EXTERN_C_END() } #endif #else #include -#define EXTERN_C_BEGIN -#define EXTERN_C_END +#define EXTERN_C_BEGIN() +#define EXTERN_C_END() #endif #include diff --git a/src/native/containers/dn-vector-priv.h b/src/native/containers/dn-vector-priv.h index d75c58368daafe..5411d8e34f631b 100644 --- a/src/native/containers/dn-vector-priv.h +++ b/src/native/containers/dn-vector-priv.h @@ -8,7 +8,7 @@ #include "dn-allocator.h" #include "dn-vector-types.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() bool _dn_vector_ensure_capacity ( @@ -94,6 +94,6 @@ _dn_vector_find_adapter ( *found = _dn_vector_custom_find (vector, data, equal_func); } -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_VECTOR_PRIV_H__ */ diff --git a/src/native/containers/dn-vector.h b/src/native/containers/dn-vector.h index 0f7f76c393ce39..cff2f746b5961d 100644 --- a/src/native/containers/dn-vector.h +++ b/src/native/containers/dn-vector.h @@ -9,7 +9,7 @@ #include "dn-vector-types.h" #include "dn-vector-priv.h" -EXTERN_C_BEGIN +EXTERN_C_BEGIN() static inline dn_vector_it_t dn_vector_begin (dn_vector_t *vector) @@ -327,6 +327,6 @@ dn_vector_find ( return dn_vector_custom_find (vector, value, equal_func); } -EXTERN_C_END +EXTERN_C_END() #endif /* __DN_VECTOR_H__ */ From e6334b7289421fa174240d73ae11fceed0f1701a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 11 Jun 2024 14:15:09 -0700 Subject: [PATCH 14/31] Namespace-scope our extern-c block define --- src/native/containers/dn-allocator.h | 4 ++-- src/native/containers/dn-fwd-list.h | 4 ++-- src/native/containers/dn-list.h | 4 ++-- src/native/containers/dn-queue.h | 4 ++-- src/native/containers/dn-umap.h | 4 ++-- src/native/containers/dn-utils.h | 8 ++++---- src/native/containers/dn-vector-priv.h | 4 ++-- src/native/containers/dn-vector.h | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/native/containers/dn-allocator.h b/src/native/containers/dn-allocator.h index c7d443b2439db6..ecbe14e247d736 100644 --- a/src/native/containers/dn-allocator.h +++ b/src/native/containers/dn-allocator.h @@ -8,7 +8,7 @@ #include #include -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() #define DN_ALLOCATOR_MEM_ALIGN8 8 #define DN_ALLOCATOR_MEM_ALIGN16 16 @@ -106,6 +106,6 @@ dn_allocator_fixed_or_malloc_reset (dn_allocator_fixed_or_malloc_t *allocator); #define DN_DEFAULT_ALLOCATOR NULL #define DN_DEFAULT_LOCAL_ALLOCATOR(var_name, buffer_size) DN_ALLOCATOR_FIXED_OR_MALLOC (var_name, buffer_size) -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_ALLOCATOR_H__ */ diff --git a/src/native/containers/dn-fwd-list.h b/src/native/containers/dn-fwd-list.h index 4fc19688edbbd0..891c40ec3bd64d 100644 --- a/src/native/containers/dn-fwd-list.h +++ b/src/native/containers/dn-fwd-list.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() typedef int32_t (DN_CALLBACK_CALLTYPE *dn_fwd_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_fwd_list_equal_func_t) (const void *a, const void *b); @@ -323,6 +323,6 @@ dn_fwd_list_find ( return dn_fwd_list_custom_find (list, data, NULL); } -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_FWD_LIST_H__ */ diff --git a/src/native/containers/dn-list.h b/src/native/containers/dn-list.h index 673e3b5baacfe3..173f53e4db9126 100644 --- a/src/native/containers/dn-list.h +++ b/src/native/containers/dn-list.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() typedef int32_t (DN_CALLBACK_CALLTYPE *dn_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_list_equal_func_t) (const void *a, const void *b); @@ -373,6 +373,6 @@ dn_list_find ( return dn_list_custom_find (list, data, NULL); } -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_LIST_H__ */ diff --git a/src/native/containers/dn-queue.h b/src/native/containers/dn-queue.h index 67838e5c0f5c59..bb02c534e0628c 100644 --- a/src/native/containers/dn-queue.h +++ b/src/native/containers/dn-queue.h @@ -8,7 +8,7 @@ #include "dn-allocator.h" #include "dn-list.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() typedef void (DN_CALLBACK_CALLTYPE *dn_queue_dispose_func_t) (void *data); @@ -146,6 +146,6 @@ dn_queue_clear (dn_queue_t *queue) dn_queue_custom_clear (queue, NULL); } -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_QUEUE_H__ */ diff --git a/src/native/containers/dn-umap.h b/src/native/containers/dn-umap.h index 7fa50ca5a16f9b..41754cee065c13 100644 --- a/src/native/containers/dn-umap.h +++ b/src/native/containers/dn-umap.h @@ -7,7 +7,7 @@ #include "dn-utils.h" #include "dn-allocator.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() typedef uint32_t (DN_CALLBACK_CALLTYPE *dn_umap_hash_func_t) (const void *key); typedef bool (DN_CALLBACK_CALLTYPE *dn_umap_equal_func_t) (const void *a, const void *b); @@ -276,6 +276,6 @@ uint32_t DN_CALLBACK_CALLTYPE dn_str_hash (const void *v1); -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_UMAP_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index 4463f369f96127..5664c61232649b 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -7,13 +7,13 @@ #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#define EXTERN_C_BEGIN() extern "C" { -#define EXTERN_C_END() } +#define DN_UTILS_EXTERN_C_BEGIN() extern "C" { +#define DN_UTILS_EXTERN_C_END() } #endif #else #include -#define EXTERN_C_BEGIN() -#define EXTERN_C_END() +#define DN_UTILS_EXTERN_C_BEGIN() +#define DN_UTILS_EXTERN_C_END() #endif #include diff --git a/src/native/containers/dn-vector-priv.h b/src/native/containers/dn-vector-priv.h index 5411d8e34f631b..eea5a1af419eb6 100644 --- a/src/native/containers/dn-vector-priv.h +++ b/src/native/containers/dn-vector-priv.h @@ -8,7 +8,7 @@ #include "dn-allocator.h" #include "dn-vector-types.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() bool _dn_vector_ensure_capacity ( @@ -94,6 +94,6 @@ _dn_vector_find_adapter ( *found = _dn_vector_custom_find (vector, data, equal_func); } -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_VECTOR_PRIV_H__ */ diff --git a/src/native/containers/dn-vector.h b/src/native/containers/dn-vector.h index cff2f746b5961d..38712f50354e21 100644 --- a/src/native/containers/dn-vector.h +++ b/src/native/containers/dn-vector.h @@ -9,7 +9,7 @@ #include "dn-vector-types.h" #include "dn-vector-priv.h" -EXTERN_C_BEGIN() +DN_UTILS_EXTERN_C_BEGIN() static inline dn_vector_it_t dn_vector_begin (dn_vector_t *vector) @@ -327,6 +327,6 @@ dn_vector_find ( return dn_vector_custom_find (vector, value, equal_func); } -EXTERN_C_END() +DN_UTILS_EXTERN_C_END() #endif /* __DN_VECTOR_H__ */ From 847100de2b590f06ea6b8b2a1149ba1cda343782 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 11 Jun 2024 14:17:21 -0700 Subject: [PATCH 15/31] Reference diagnosticserver pal in NativeAOT. --- src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 3d3b8e985cbc31..9ed78f80fb03db 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -176,7 +176,7 @@ get_property(eventpipe_sources TARGET dn-eventpipe PROPERTY INTERFACE_SOURCES) set_source_files_properties(${diagnosticserver_sources} ${diagnosticserver_pal_sources} ${eventpipe_sources} PROPERTIES LANGUAGE CXX) add_library(eventpipe-shared-objects OBJECT) -target_link_libraries(eventpipe-shared-objects PRIVATE dn-diagnosticserver dn-eventpipe) +target_link_libraries(eventpipe-shared-objects PRIVATE dn-diagnosticserver dn-eventpipe dn-diagnosticserver-pal) # Build EventPipe and DiagnosticServer as unity-builds for better inlining. set_target_properties(eventpipe-shared-objects PROPERTIES UNITY_BUILD ON @@ -184,7 +184,7 @@ set_target_properties(eventpipe-shared-objects PROPERTIES ) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-shared-objects.GuardCF OBJECT) - target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-diagnosticserver dn-eventpipe) + target_link_libraries(eventpipe-shared-objects.GuardCF PRIVATE dn-diagnosticserver dn-eventpipe dn-diagnosticserver-pal) target_compile_options(eventpipe-shared-objects PRIVATE "/FI${RUNTIME_DIR}/eventpipe/NativeaotEventPipeSupport.h") From 4969670790d68c598abdd8f1243e99c17db0e7b5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 11:35:17 -0700 Subject: [PATCH 16/31] Fix Windows build in debug-pal and fix NativeAOT linkage issues. --- .../nativeaot/Runtime/eventpipe/CMakeLists.txt | 4 ++-- src/native/containers/CMakeLists.txt | 2 ++ src/native/eventpipe/CMakeLists.txt | 6 ++++++ src/native/eventpipe/ds-ipc-pal-socket.h | 14 +++++++------- src/native/eventpipe/ep-shared-config.h.in | 1 + 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 9ed78f80fb03db..01eee97bb12e30 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -218,7 +218,7 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES}) -target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects) +target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects dn-containers) add_dependencies(eventpipe-enabled aot_eventing_headers) if(CLR_CMAKE_TARGET_WIN32) add_dependencies(eventpipe-enabled aot_etw_headers) @@ -229,7 +229,7 @@ add_dependencies(eventpipe-disabled aot_eventing_headers) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) - target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF) + target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF dn-containers) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) diff --git a/src/native/containers/CMakeLists.txt b/src/native/containers/CMakeLists.txt index 7793a2dc1471f4..c7e06c92884446 100644 --- a/src/native/containers/CMakeLists.txt +++ b/src/native/containers/CMakeLists.txt @@ -21,3 +21,5 @@ configure_file(dn-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dn-config.h) target_include_directories(dn-containers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(dn-containers PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +set_target_properties(dn-containers PROPERTIES CLR_CONTROL_FLOW_GUARD ON) diff --git a/src/native/eventpipe/CMakeLists.txt b/src/native/eventpipe/CMakeLists.txt index 15ccd57cc69aba..311293ca5f45cc 100644 --- a/src/native/eventpipe/CMakeLists.txt +++ b/src/native/eventpipe/CMakeLists.txt @@ -1,4 +1,10 @@ include(CheckSymbolExists) +include(CheckIncludeFile) + +check_include_file( + sys/socket.h + HAVE_SYS_SOCKET_H +) check_symbol_exists( accept4 diff --git a/src/native/eventpipe/ds-ipc-pal-socket.h b/src/native/eventpipe/ds-ipc-pal-socket.h index cd8280aee64769..268b52a65fb9eb 100644 --- a/src/native/eventpipe/ds-ipc-pal-socket.h +++ b/src/native/eventpipe/ds-ipc-pal-socket.h @@ -12,18 +12,18 @@ #endif #include "ds-getter-setter.h" -#ifdef HOST_WIN32 -#include -typedef SOCKET ds_ipc_socket_t; -typedef SOCKADDR ds_ipc_socket_address_t; -typedef ADDRESS_FAMILY ds_ipc_socket_family_t; -typedef int ds_ipc_socket_len_t; -#else +#ifdef HAVE_SYS_SOCKET_H #include typedef int ds_ipc_socket_t; typedef struct sockaddr ds_ipc_socket_address_t; typedef int ds_ipc_socket_family_t; typedef socklen_t ds_ipc_socket_len_t; +#else +#include +typedef SOCKET ds_ipc_socket_t; +typedef SOCKADDR ds_ipc_socket_address_t; +typedef ADDRESS_FAMILY ds_ipc_socket_family_t; +typedef int ds_ipc_socket_len_t; #endif /* diff --git a/src/native/eventpipe/ep-shared-config.h.in b/src/native/eventpipe/ep-shared-config.h.in index 188f55fd32170c..94cb0e27d3c4ff 100644 --- a/src/native/eventpipe/ep-shared-config.h.in +++ b/src/native/eventpipe/ep-shared-config.h.in @@ -1,6 +1,7 @@ #ifndef EP_SHARED_CONFIG_H_INCLUDED #define EP_SHARED_CONFIG_H_INCLUDED +#cmakedefine01 HAVE_SYS_SOCKET_H /* This platforms supports setting flags atomically when accepting connections. */ #cmakedefine01 HAVE_ACCEPT4 From 292fac55a61cd601dce54174a93bb28eafbd8cc8 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 11:37:33 -0700 Subject: [PATCH 17/31] Correctly nest initializer for GCC --- src/native/containers/dn-umap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/containers/dn-umap.c b/src/native/containers/dn-umap.c index 6935a30c57de13..7693f9339ee46a 100644 --- a/src/native/containers/dn-umap.c +++ b/src/native/containers/dn-umap.c @@ -318,7 +318,7 @@ dn_umap_begin (dn_umap_t *map) index ++; } - dn_umap_it_t it = { map, map->_internal._buckets [index], index }; + dn_umap_it_t it = { { map, map->_internal._buckets [index], index } }; return it; } From 4d681a5990b19e066cf74738db13c4f0a76f2aa0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 11:40:52 -0700 Subject: [PATCH 18/31] Just directly extern "C" the headers --- src/native/containers/dn-allocator.h | 8 ++++++-- src/native/containers/dn-fwd-list.h | 8 ++++++-- src/native/containers/dn-list.h | 8 ++++++-- src/native/containers/dn-queue.h | 8 ++++++-- src/native/containers/dn-umap.h | 8 ++++++-- src/native/containers/dn-utils.h | 4 ---- src/native/containers/dn-vector-priv.h | 8 ++++++-- src/native/containers/dn-vector.h | 8 ++++++-- 8 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/native/containers/dn-allocator.h b/src/native/containers/dn-allocator.h index ecbe14e247d736..ee4f5093126a33 100644 --- a/src/native/containers/dn-allocator.h +++ b/src/native/containers/dn-allocator.h @@ -8,7 +8,9 @@ #include #include -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif #define DN_ALLOCATOR_MEM_ALIGN8 8 #define DN_ALLOCATOR_MEM_ALIGN16 16 @@ -106,6 +108,8 @@ dn_allocator_fixed_or_malloc_reset (dn_allocator_fixed_or_malloc_t *allocator); #define DN_DEFAULT_ALLOCATOR NULL #define DN_DEFAULT_LOCAL_ALLOCATOR(var_name, buffer_size) DN_ALLOCATOR_FIXED_OR_MALLOC (var_name, buffer_size) -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_ALLOCATOR_H__ */ diff --git a/src/native/containers/dn-fwd-list.h b/src/native/containers/dn-fwd-list.h index 891c40ec3bd64d..6cc376222d272c 100644 --- a/src/native/containers/dn-fwd-list.h +++ b/src/native/containers/dn-fwd-list.h @@ -7,7 +7,9 @@ #include "dn-utils.h" #include "dn-allocator.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif typedef int32_t (DN_CALLBACK_CALLTYPE *dn_fwd_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_fwd_list_equal_func_t) (const void *a, const void *b); @@ -323,6 +325,8 @@ dn_fwd_list_find ( return dn_fwd_list_custom_find (list, data, NULL); } -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_FWD_LIST_H__ */ diff --git a/src/native/containers/dn-list.h b/src/native/containers/dn-list.h index 173f53e4db9126..e96588c2ee9152 100644 --- a/src/native/containers/dn-list.h +++ b/src/native/containers/dn-list.h @@ -7,7 +7,9 @@ #include "dn-utils.h" #include "dn-allocator.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif typedef int32_t (DN_CALLBACK_CALLTYPE *dn_list_compare_func_t) (const void *a, const void *b); typedef bool (DN_CALLBACK_CALLTYPE *dn_list_equal_func_t) (const void *a, const void *b); @@ -373,6 +375,8 @@ dn_list_find ( return dn_list_custom_find (list, data, NULL); } -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_LIST_H__ */ diff --git a/src/native/containers/dn-queue.h b/src/native/containers/dn-queue.h index bb02c534e0628c..3003d4af87ae02 100644 --- a/src/native/containers/dn-queue.h +++ b/src/native/containers/dn-queue.h @@ -8,7 +8,9 @@ #include "dn-allocator.h" #include "dn-list.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif typedef void (DN_CALLBACK_CALLTYPE *dn_queue_dispose_func_t) (void *data); @@ -146,6 +148,8 @@ dn_queue_clear (dn_queue_t *queue) dn_queue_custom_clear (queue, NULL); } -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_QUEUE_H__ */ diff --git a/src/native/containers/dn-umap.h b/src/native/containers/dn-umap.h index 41754cee065c13..b83eba38755bdd 100644 --- a/src/native/containers/dn-umap.h +++ b/src/native/containers/dn-umap.h @@ -7,7 +7,9 @@ #include "dn-utils.h" #include "dn-allocator.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif typedef uint32_t (DN_CALLBACK_CALLTYPE *dn_umap_hash_func_t) (const void *key); typedef bool (DN_CALLBACK_CALLTYPE *dn_umap_equal_func_t) (const void *a, const void *b); @@ -276,6 +278,8 @@ uint32_t DN_CALLBACK_CALLTYPE dn_str_hash (const void *v1); -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_UMAP_H__ */ diff --git a/src/native/containers/dn-utils.h b/src/native/containers/dn-utils.h index 5664c61232649b..dab4160852b1fa 100644 --- a/src/native/containers/dn-utils.h +++ b/src/native/containers/dn-utils.h @@ -7,13 +7,9 @@ #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS -#define DN_UTILS_EXTERN_C_BEGIN() extern "C" { -#define DN_UTILS_EXTERN_C_END() } #endif #else #include -#define DN_UTILS_EXTERN_C_BEGIN() -#define DN_UTILS_EXTERN_C_END() #endif #include diff --git a/src/native/containers/dn-vector-priv.h b/src/native/containers/dn-vector-priv.h index eea5a1af419eb6..6ebe242a568a5e 100644 --- a/src/native/containers/dn-vector-priv.h +++ b/src/native/containers/dn-vector-priv.h @@ -8,7 +8,9 @@ #include "dn-allocator.h" #include "dn-vector-types.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif bool _dn_vector_ensure_capacity ( @@ -94,6 +96,8 @@ _dn_vector_find_adapter ( *found = _dn_vector_custom_find (vector, data, equal_func); } -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_VECTOR_PRIV_H__ */ diff --git a/src/native/containers/dn-vector.h b/src/native/containers/dn-vector.h index 38712f50354e21..4a810e72d5bb73 100644 --- a/src/native/containers/dn-vector.h +++ b/src/native/containers/dn-vector.h @@ -9,7 +9,9 @@ #include "dn-vector-types.h" #include "dn-vector-priv.h" -DN_UTILS_EXTERN_C_BEGIN() +#ifdef __cplusplus +extern "C" { +#endif static inline dn_vector_it_t dn_vector_begin (dn_vector_t *vector) @@ -327,6 +329,8 @@ dn_vector_find ( return dn_vector_custom_find (vector, value, equal_func); } -DN_UTILS_EXTERN_C_END() +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DN_VECTOR_H__ */ From 81a686e1eec8d613ce5f88f7e8f808911e14ecdc Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 14:56:57 -0700 Subject: [PATCH 19/31] if not ifdef --- src/native/eventpipe/ds-ipc-pal-socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/eventpipe/ds-ipc-pal-socket.h b/src/native/eventpipe/ds-ipc-pal-socket.h index 268b52a65fb9eb..04ba9f2273d8f7 100644 --- a/src/native/eventpipe/ds-ipc-pal-socket.h +++ b/src/native/eventpipe/ds-ipc-pal-socket.h @@ -12,7 +12,7 @@ #endif #include "ds-getter-setter.h" -#ifdef HAVE_SYS_SOCKET_H +#if HAVE_SYS_SOCKET_H #include typedef int ds_ipc_socket_t; typedef struct sockaddr ds_ipc_socket_address_t; From 5c136475aacab2d789b78c63139631289e9dc658 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 14:58:20 -0700 Subject: [PATCH 20/31] Try more directly including the container objects --- src/mono/mono/component/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index e191fca4fd0616..4a310205392b88 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -225,15 +225,14 @@ if (ENABLE_PERFTRACING) UNITY_BUILD_BATCH_SIZE 0 ) target_link_libraries(eventpipe-mono-objects PRIVATE component_base eglib_api dn-eventpipe dn-diagnosticserver dn-diagnosticserver-pal) - target_link_libraries(eventpipe-mono-objects PUBLIC dn-containers) # Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries. if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects) - target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $) + target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $ $) endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) - target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE eventpipe-mono-objects) + target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE eventpipe-mono-objects dn-containers) endif() - list(APPEND mono-components-objects $) + list(APPEND mono-components-objects $ $) endif() # define a list of mono-components-stubs objects that will be linked into From 44b7283af265cf45e964cadaab5c3be041ee9df6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 14:59:14 -0700 Subject: [PATCH 21/31] Fix other initialization syntax for GCC --- src/native/containers/dn-umap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/containers/dn-umap.c b/src/native/containers/dn-umap.c index 7693f9339ee46a..40848b41e834f6 100644 --- a/src/native/containers/dn-umap.c +++ b/src/native/containers/dn-umap.c @@ -541,7 +541,7 @@ dn_umap_custom_find ( for (dn_umap_node_t *node = map->_internal._buckets [hashcode]; node; node = node->next) { if (equal_func (node->key, key)) { - dn_umap_it_t found = { map, node, hashcode }; + dn_umap_it_t found = { { map, node, hashcode } }; return found; } } From f7f398b469a7f69f5a5023c860b999f056d914d0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 14 Jun 2024 16:44:35 -0700 Subject: [PATCH 22/31] Don't reference the diagnostic server PAL on cross-os builds --- src/coreclr/debug/debug-pal/CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index 9f7b1365d5af9d..b803de3b6db1ad 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -10,6 +10,7 @@ if(CLR_CMAKE_HOST_WIN32) include_directories(../../inc) #needed for warning control if(CLR_CMAKE_TARGET_WIN32) + set(DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER ON) set(TWO_WAY_PIPE_SOURCES ${EVENTPIPE_PAL_SOURCES} win/twowaypipe.cpp @@ -23,6 +24,7 @@ if(CLR_CMAKE_HOST_WIN32) endif(CLR_CMAKE_HOST_WIN32) if(CLR_CMAKE_HOST_UNIX) + set(DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER ON) add_definitions(-DPAL_IMPLEMENTATION) add_definitions(-D_POSIX_C_SOURCE=200809L) @@ -37,10 +39,12 @@ endif(CLR_CMAKE_HOST_UNIX) add_library_clr(debug-pal OBJECT ${TWO_WAY_PIPE_SOURCES}) -target_link_libraries(debug-pal PRIVATE dn-diagnosticserver-pal) +if (DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER) + target_link_libraries(debug-pal PRIVATE dn-diagnosticserver-pal) -# The DiagnosticServer Runtime implementation in CoreCLR is C++, -# but the Diagnostic Server PAL is written in C. -# Override those files to build as C++. -get_property(ds_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES) -set_source_files_properties(${ds_pal_sources} PROPERTIES LANGUAGE CXX) + # The DiagnosticServer Runtime implementation in CoreCLR is C++, + # but the Diagnostic Server PAL is written in C. + # Override those files to build as C++. + get_property(ds_pal_sources TARGET dn-diagnosticserver-pal PROPERTY INTERFACE_SOURCES) + set_source_files_properties(${ds_pal_sources} PROPERTIES LANGUAGE CXX) +endif() From e08a371770aedb854828d25c6c9f32f32cb47325 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 17 Jun 2024 18:32:35 +0000 Subject: [PATCH 23/31] Fix mono-aot-cross build --- src/mono/mono/component/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 4a310205392b88..8555bae62d304e 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -215,7 +215,7 @@ elseif(AOT_COMPONENTS OR (NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS)) endif() -if (ENABLE_PERFTRACING) +if (ENABLE_PERFTRACING AND "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}" IN_LIST components_to_build) # Build EventPipe and DiagnosticServer with the Mono runtime implementation as unity-builds. add_library(eventpipe-mono-objects OBJECT) set_target_properties( @@ -228,11 +228,11 @@ if (ENABLE_PERFTRACING) # Link the diagnostics_tracing component to the EventPipe and DiagnosticServer libraries. if (TARGET ${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects) target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $ $) + list(APPEND mono-components-objects $ $) endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE eventpipe-mono-objects dn-containers) endif() - list(APPEND mono-components-objects $ $) endif() # define a list of mono-components-stubs objects that will be linked into From 258221aab79bb343b6afdd6153a4ac53f44e906e Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 09:41:21 -0700 Subject: [PATCH 24/31] Fix win-x86 build. --- src/native/containers/dn-simdhash-utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/native/containers/dn-simdhash-utils.h b/src/native/containers/dn-simdhash-utils.h index 889127d4088a8b..ce14b810974281 100644 --- a/src/native/containers/dn-simdhash-utils.h +++ b/src/native/containers/dn-simdhash-utils.h @@ -179,6 +179,9 @@ MurmurHash3_32_streaming (const uint8_t *key, uint32_t seed) // end of reformulated murmur3-32 void +#ifdef _MSC_VER +__cdecl +#endif dn_simdhash_assert_fail (const char *file, int line, const char *condition); #define dn_simdhash_assert(expr) \ From 60cc39298434d40111485632fed759082109e8ea Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 09:45:06 -0700 Subject: [PATCH 25/31] Try using TARGET_OBJECTS to fix the static component libraries --- src/mono/mono/component/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 8555bae62d304e..5e561a65b7559a 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -231,7 +231,7 @@ if (ENABLE_PERFTRACING AND "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}" IN_LIST list(APPEND mono-components-objects $ $) endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) - target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE eventpipe-mono-objects dn-containers) + target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE $ $) endif() endif() From 95f8383b368a263a2dbdb49394884d5a275db4ba Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 09:45:26 -0700 Subject: [PATCH 26/31] Link dn-containers into Mono.framework --- src/mono/mono/mini/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index bc6db83f3fa1fe..93ff6c431ef03b 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -417,7 +417,7 @@ if(NOT DISABLE_SHARED_LIBS) endif() add_library(${frameworkconfig} SHARED $) target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT) - target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects dn-containers) target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS}) set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-compatibility_version -Wl,2.0 -Wl,-current_version -Wl,2.0") From a0fb40ba4dde535505fb0498a7f3590ae24212e9 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 09:52:12 -0700 Subject: [PATCH 27/31] Provide a no-lto flavor of the container library for NativeAOT. This will fix some of the NativeAOT warnings --- .../nativeaot/Runtime/eventpipe/CMakeLists.txt | 4 ++-- src/native/containers/CMakeLists.txt | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 01eee97bb12e30..5c083c2f6130d1 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -218,7 +218,7 @@ list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES add_library(eventpipe-enabled STATIC ${EVENTPIPE_SOURCES}) -target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects dn-containers) +target_link_libraries(eventpipe-enabled PRIVATE eventpipe-shared-objects dn-containers-no-lto) add_dependencies(eventpipe-enabled aot_eventing_headers) if(CLR_CMAKE_TARGET_WIN32) add_dependencies(eventpipe-enabled aot_etw_headers) @@ -229,7 +229,7 @@ add_dependencies(eventpipe-disabled aot_eventing_headers) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-enabled.GuardCF STATIC ${EVENTPIPE_SOURCES}) - target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF dn-containers) + target_link_libraries(eventpipe-enabled.GuardCF PRIVATE eventpipe-shared-objects.GuardCF dn-containers-no-lto) add_dependencies(eventpipe-enabled.GuardCF aot_eventing_headers) add_dependencies(eventpipe-enabled.GuardCF aot_etw_headers) add_library(eventpipe-disabled.GuardCF STATIC ${AOT_EVENTPIPE_DISABLED_SOURCES}) diff --git a/src/native/containers/CMakeLists.txt b/src/native/containers/CMakeLists.txt index c7e06c92884446..a277e82e57afbb 100644 --- a/src/native/containers/CMakeLists.txt +++ b/src/native/containers/CMakeLists.txt @@ -1,6 +1,4 @@ -add_library(dn-containers OBJECT) - -target_sources(dn-containers PRIVATE +set(SOURCES dn-allocator.c dn-fwd-list.c dn-list.c @@ -16,10 +14,20 @@ target_sources(dn-containers PRIVATE dn-simdhash-utils.c ) +# Build two variants of the container library as some of our scenarios +# are not compatible with LTO, (i.e. NativeAOT). +add_library(dn-containers OBJECT ${SOURCES}) +add_library(dn-containers-no-lto OBJECT ${SOURCES}) + configure_file(dn-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dn-config.h) target_include_directories(dn-containers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - target_include_directories(dn-containers PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - set_target_properties(dn-containers PROPERTIES CLR_CONTROL_FLOW_GUARD ON) + +target_include_directories(dn-containers-no-lto PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(dn-containers-no-lto PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +set_target_properties(dn-containers-no-lto + PROPERTIES + CLR_CONTROL_FLOW_GUARD ON + INTERPROCEDURAL_OPTIMIZATION OFF) From 78739e37c4f3ed4546a21de306f7200122bde27b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 15:34:34 -0700 Subject: [PATCH 28/31] Make the default impl also cdecl --- src/native/containers/dn-simdhash-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/containers/dn-simdhash-utils.c b/src/native/containers/dn-simdhash-utils.c index 7f10d9e18a47a0..32d740c83219f4 100644 --- a/src/native/containers/dn-simdhash-utils.c +++ b/src/native/containers/dn-simdhash-utils.c @@ -15,7 +15,7 @@ #define DEFINE_ALTERNATENAME_1(part) DEFINE_ALTERNATENAME_2(#part) #define DEFINE_ALTERNATENAME(alias, func) DEFINE_ALTERNATENAME_1(/ALTERNATENAME:alias=func) #ifdef _M_IX86 -#define DEFAULT_IMPLEMENTATION(func, impl, retval) DEFINE_ALTERNATENAME(_ ## func, _ ## impl) retval impl +#define DEFAULT_IMPLEMENTATION(func, impl, retval) DEFINE_ALTERNATENAME(_ ## func, _ ## impl) retval __cdecl impl #else #define DEFAULT_IMPLEMENTATION(func, impl, retval) DEFINE_ALTERNATENAME(func, impl) retval impl #endif From 6d2b05f585b044efef6bd2145ce8c9acca4231c4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 19 Jun 2024 16:12:26 -0700 Subject: [PATCH 29/31] Explicitly add eventpipe runtime objects to the static component library --- src/mono/mono/component/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 5e561a65b7559a..578ee25d3bd7e6 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -230,8 +230,11 @@ if (ENABLE_PERFTRACING AND "${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}" IN_LIST target_sources(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-objects PRIVATE $ $) list(APPEND mono-components-objects $ $) endif() + if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static) + target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-static PRIVATE $ $) + endif() if (TARGET mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}) - target_link_libraries(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE $ $) + target_sources(mono-component-${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME} PRIVATE $ $) endif() endif() From d4ed37067196b729d9a26ec5fbed5c03a8891fa6 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 20 Jun 2024 10:46:50 -0700 Subject: [PATCH 30/31] Install compile PDBs for each of the EP libs used in NativeAOT --- .../nativeaot/Runtime/eventpipe/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 5c083c2f6130d1..0f0c89662e1b73 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -181,6 +181,8 @@ target_link_libraries(eventpipe-shared-objects PRIVATE dn-diagnosticserver dn-ev set_target_properties(eventpipe-shared-objects PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 0 + COMPILE_PDB_NAME "eventpipe-shared-objects" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-shared-objects.GuardCF OBJECT) @@ -196,7 +198,18 @@ if (CLR_CMAKE_TARGET_WIN32) set_target_properties(eventpipe-shared-objects.GuardCF PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 0 - CLR_CONTROL_FLOW_GUARD ON) + CLR_CONTROL_FLOW_GUARD ON + COMPILE_PDB_NAME "eventpipe-shared-objects.GuardCF" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + + # Install the compile PDB for the eventpipe unity builds. + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/eventpipe-shared-objects.pdb" DESTINATION aotsdk COMPONENT nativeaot) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/eventpipe-shared-objects.GuardCF.pdb" DESTINATION aotsdk COMPONENT nativeaot) + # For the container library, we need to produce a compile PDB and install it + set_target_properties(dn-containers-no-lto PROPERTIES + COMPILE_PDB_NAME "dn-containers" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dn-containers.pdb" DESTINATION aotsdk COMPONENT nativeaot) endif() list(APPEND EVENTPIPE_SOURCES From fc10257c07a55d83eae72560ec4a9b1910dcaab3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 24 Jun 2024 11:02:10 -0700 Subject: [PATCH 31/31] Fix MSBuild build --- .../nativeaot/Runtime/eventpipe/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt index 0f0c89662e1b73..537e2f5f2b5f4b 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/eventpipe/CMakeLists.txt @@ -182,7 +182,7 @@ set_target_properties(eventpipe-shared-objects PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 0 COMPILE_PDB_NAME "eventpipe-shared-objects" - COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$" ) if (CLR_CMAKE_TARGET_WIN32) add_library(eventpipe-shared-objects.GuardCF OBJECT) @@ -200,16 +200,16 @@ if (CLR_CMAKE_TARGET_WIN32) UNITY_BUILD_BATCH_SIZE 0 CLR_CONTROL_FLOW_GUARD ON COMPILE_PDB_NAME "eventpipe-shared-objects.GuardCF" - COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$") # Install the compile PDB for the eventpipe unity builds. - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/eventpipe-shared-objects.pdb" DESTINATION aotsdk COMPONENT nativeaot) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/eventpipe-shared-objects.GuardCF.pdb" DESTINATION aotsdk COMPONENT nativeaot) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$/eventpipe-shared-objects.pdb" DESTINATION aotsdk COMPONENT nativeaot) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$/eventpipe-shared-objects.GuardCF.pdb" DESTINATION aotsdk COMPONENT nativeaot) # For the container library, we need to produce a compile PDB and install it set_target_properties(dn-containers-no-lto PROPERTIES COMPILE_PDB_NAME "dn-containers" - COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dn-containers.pdb" DESTINATION aotsdk COMPONENT nativeaot) + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$/dn-containers.pdb" DESTINATION aotsdk COMPONENT nativeaot) endif() list(APPEND EVENTPIPE_SOURCES