From 72e084def7550114ac5d0a2f7f82c6d6dbd8da51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Wed, 17 Dec 2025 20:11:45 +0100 Subject: [PATCH 1/6] CMake export header --- cmake/typeartToolchainOptions.cmake | 3 ++ lib/mpi_interceptor/CMakeLists.txt | 2 +- lib/mpi_interceptor/InterceptorFunctions.h | 30 ++++++++----- lib/runtime/CMakeLists.txt | 18 +++++++- lib/runtime/CallbackInterface.h | 32 ++++++------- lib/runtime/RuntimeInterface.h | 46 ++++++++++--------- lib/support/CMakeLists.txt | 51 +++++++++++---------- lib/typelib/CMakeLists.txt | 52 +++++++++++----------- scripts/CMakeLists.txt | 2 +- 9 files changed, 134 insertions(+), 102 deletions(-) diff --git a/cmake/typeartToolchainOptions.cmake b/cmake/typeartToolchainOptions.cmake index ef6a9756..741c9b3e 100644 --- a/cmake/typeartToolchainOptions.cmake +++ b/cmake/typeartToolchainOptions.cmake @@ -94,6 +94,9 @@ mark_as_advanced(TYPEART_CONFIG_DIR_IS_SHARE) option(TYPEART_USE_LEGACY_WRAPPER "Use the old TypeART compiler wrapper" OFF) # mark_as_advanced(TYPEART_USE_NEW_PASSMANAGER) +option(TYPEART_INSTALL_TYPES_LIB "Install types library" OFF) +option(TYPEART_INSTALL_SYSTEM_LIB "Install system library" OFF) + # if(LLVM_VERSION_MAJOR VERSION_GREATER_EQUAL "18") # set(TYPEART_USE_NEW_PASSMANAGER ON CACHE BOOL ON FORCE) # endif() diff --git a/lib/mpi_interceptor/CMakeLists.txt b/lib/mpi_interceptor/CMakeLists.txt index dafa153e..c521026d 100644 --- a/lib/mpi_interceptor/CMakeLists.txt +++ b/lib/mpi_interceptor/CMakeLists.txt @@ -19,7 +19,7 @@ set_property(TARGET ${TYPEART_PREFIX}_MPITool PROPERTY C_STANDARD_REQUIRED TRUE) typeart_target_define_file_basename(${TYPEART_PREFIX}_MPITool) target_include_directories(${TYPEART_PREFIX}_MPITool ${warning_guard} - PUBLIC $ + PUBLIC $ $ $ ) diff --git a/lib/mpi_interceptor/InterceptorFunctions.h b/lib/mpi_interceptor/InterceptorFunctions.h index c782924e..c1ccb341 100644 --- a/lib/mpi_interceptor/InterceptorFunctions.h +++ b/lib/mpi_interceptor/InterceptorFunctions.h @@ -13,7 +13,8 @@ #ifndef TEST_MPI_INTERCEPTOR_INTERCEPTORFUNCTIONS_H_ #define TEST_MPI_INTERCEPTOR_INTERCEPTORFUNCTIONS_H_ -#include "runtime/RuntimeInterface.h" +#include "RuntimeExport.h" +#include "RuntimeInterface.h" #include #include @@ -22,8 +23,9 @@ #include #include -int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, int const_adr); -void ta_print_loc(const void* call_adr); +TYPEART_NO_EXPORT int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, + int const_adr); +TYPEART_NO_EXPORT void ta_print_loc(const void* call_adr); typedef struct CallCounter { _Atomic size_t send; @@ -42,31 +44,34 @@ typedef struct MPISemCounter { static MPICounter mcounter = {0, 0, 0}; -void ta_check_send(const char* name, const void* called_from, const void* sendbuf, int count, MPI_Datatype dtype) { +TYPEART_NO_EXPORT void ta_check_send(const char* name, const void* called_from, const void* sendbuf, int count, + MPI_Datatype dtype) { ++counter.send; ta_check_buffer(name, called_from, sendbuf, count, 1); } -void ta_check_recv(const char* name, const void* called_from, void* recvbuf, int count, MPI_Datatype dtype) { +TYPEART_NO_EXPORT void ta_check_recv(const char* name, const void* called_from, void* recvbuf, int count, + MPI_Datatype dtype) { ++counter.recv; ta_check_buffer(name, called_from, recvbuf, count, 0); } -void ta_check_send_and_recv(const char* name, const void* called_from, const void* sendbuf, int sendcount, - MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype) { +TYPEART_NO_EXPORT void ta_check_send_and_recv(const char* name, const void* called_from, const void* sendbuf, + int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, + MPI_Datatype recvtype) { ++counter.send_recv; ta_check_send(name, called_from, sendbuf, sendcount, sendtype); ta_check_recv(name, called_from, recvbuf, recvcount, recvtype); } -void ta_unsupported_mpi_call(const char* name, const void* called_from) { +TYPEART_NO_EXPORT void ta_unsupported_mpi_call(const char* name, const void* called_from) { ++counter.unsupported; fprintf(stderr, "[Error] The MPI function %s is currently not checked by TypeArt", name); ta_print_loc(called_from); // exit(0); } -const char* ta_get_error_message(typeart_status status) { +TYPEART_NO_EXPORT const char* ta_get_error_message(typeart_status status) { switch (status) { case TYPEART_OK: return "No errors"; @@ -85,7 +90,8 @@ const char* ta_get_error_message(typeart_status status) { } } -int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, int const_adr) { +TYPEART_NO_EXPORT int ta_check_buffer(const char* mpi_name, const void* called_from, const void* buf, int mpi_count, + int const_adr) { if (mpi_count <= 0) { ++mcounter.null_count; return 1; @@ -119,7 +125,7 @@ int ta_check_buffer(const char* mpi_name, const void* called_from, const void* b return 1; } -void ta_print_loc(const void* call_adr) { +TYPEART_NO_EXPORT void ta_print_loc(const void* call_adr) { const char* exe = getenv("TYPEART_EXE_TARGET"); if (exe == NULL || exe[0] == '\0') { return; @@ -138,7 +144,7 @@ void ta_print_loc(const void* call_adr) { } } -void ta_exit() { +TYPEART_NO_EXPORT void ta_exit() { // Called at MPI_Finalize time int rank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &rank); diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index 5d04cfbb..5a374e7c 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -40,6 +40,17 @@ set_target_properties( ) add_library(typeart::Runtime ALIAS ${TYPEART_PREFIX}_Runtime) +include(GenerateExportHeader) +generate_export_header(${TYPEART_PREFIX}_Runtime + BASE_NAME TYPEART + EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/RuntimeExport.h" +) + +set_target_properties(${TYPEART_PREFIX}_Runtime PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) + target_link_libraries( ${TYPEART_PREFIX}_Runtime PRIVATE typeart::TypesStatic @@ -59,6 +70,7 @@ target_include_directories( PUBLIC $ $ $ + $ PRIVATE $ $ ) @@ -97,8 +109,10 @@ make_tidy_check(${TYPEART_PREFIX}_Runtime "${RUNTIME_LIB_SOURCES}") set(CONFIG_NAME ${PROJECT_NAME}Runtime) set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) -install(FILES RuntimeInterface.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} +install(FILES + RuntimeInterface.h + "${CMAKE_CURRENT_BINARY_DIR}/RuntimeExport.h" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} ) install( diff --git a/lib/runtime/CallbackInterface.h b/lib/runtime/CallbackInterface.h index 6ca76206..7b5f7490 100644 --- a/lib/runtime/CallbackInterface.h +++ b/lib/runtime/CallbackInterface.h @@ -13,6 +13,8 @@ #ifndef TYPEART_CALLBACKINTERFACE_H #define TYPEART_CALLBACKINTERFACE_H +#include "RuntimeExport.h" + #ifdef __cplusplus #include #else @@ -23,28 +25,28 @@ #ifdef __cplusplus extern "C" { #endif -void __typeart_alloc(const void* addr, int type_id, size_t count); +TYPEART_EXPORT void __typeart_alloc(const void* addr, int type_id, size_t count); -void __typeart_alloc_global(const void* addr, int type_id, size_t count); -void __typeart_free(const void* addr); +TYPEART_EXPORT void __typeart_alloc_global(const void* addr, int type_id, size_t count); +TYPEART_EXPORT void __typeart_free(const void* addr); -void __typeart_alloc_stack(const void* addr, int type_id, size_t count); -void __typeart_leave_scope(int alloca_count); +TYPEART_EXPORT void __typeart_alloc_stack(const void* addr, int type_id, size_t count); +TYPEART_EXPORT void __typeart_leave_scope(int alloca_count); // Called from OpenMP context -void __typeart_alloc_omp(const void* addr, int type_id, size_t count); -void __typeart_free_omp(const void* addr); -void __typeart_alloc_stack_omp(const void* addr, int type_id, size_t count); -void __typeart_leave_scope_omp(int alloca_count); +TYPEART_EXPORT void __typeart_alloc_omp(const void* addr, int type_id, size_t count); +TYPEART_EXPORT void __typeart_free_omp(const void* addr); +TYPEART_EXPORT void __typeart_alloc_stack_omp(const void* addr, int type_id, size_t count); +TYPEART_EXPORT void __typeart_leave_scope_omp(int alloca_count); // Called for inlined type definitions mode -void __typeart_alloc_mty(const void* addr, const void* info, size_t count); -void __typeart_alloc_global_mty(const void* addr, const void* info, size_t count); -void __typeart_alloc_stack_mty(const void* addr, const void* info, size_t count); -void __typeart_register_type(const void* type); +TYPEART_EXPORT void __typeart_alloc_mty(const void* addr, const void* info, size_t count); +TYPEART_EXPORT void __typeart_alloc_global_mty(const void* addr, const void* info, size_t count); +TYPEART_EXPORT void __typeart_alloc_stack_mty(const void* addr, const void* info, size_t count); +TYPEART_EXPORT void __typeart_register_type(const void* type); -void __typeart_alloc_global_mty_omp(const void* addr, const void* info, size_t count); -void __typeart_alloc_stack_mty_omp(const void* addr, const void* info, size_t count); +TYPEART_EXPORT void __typeart_alloc_global_mty_omp(const void* addr, const void* info, size_t count); +TYPEART_EXPORT void __typeart_alloc_stack_mty_omp(const void* addr, const void* info, size_t count); #ifdef __cplusplus } #endif diff --git a/lib/runtime/RuntimeInterface.h b/lib/runtime/RuntimeInterface.h index df01e259..e625ea2c 100644 --- a/lib/runtime/RuntimeInterface.h +++ b/lib/runtime/RuntimeInterface.h @@ -13,6 +13,7 @@ #ifndef TYPEART_RUNTIMEINTERFACE_H #define TYPEART_RUNTIMEINTERFACE_H +#include "RuntimeExport.h" #include "TypeInterface.h" #ifdef __cplusplus @@ -91,7 +92,7 @@ typedef struct typeart_source_loc_t { * - TYPEART_BAD_ALIGNMENT: The given address does not line up with the start of the atomic type at that location. * - TYPEART_INVALID_ID: Encountered unregistered ID during lookup. */ -typeart_status typeart_get_type(const void* addr, typeart_type_info* type_info); +TYPEART_EXPORT typeart_status typeart_get_type(const void* addr, typeart_type_info* type_info); /** * Determines the outermost type and array element count at the given address. @@ -138,8 +139,8 @@ typeart_status typeart_get_type(const void* addr, typeart_type_info* type_info); // typeart_status typeart_get_containing_type(const void* addr, int* type_id, size_t* count, const void** base_address, // size_t* byte_offset); -typeart_status typeart_get_containing_type(const typeart_type_info* type_info, typeart_base_type_info* containing_type, - size_t* byte_offset); +TYPEART_EXPORT typeart_status typeart_get_containing_type(const typeart_type_info* type_info, + typeart_base_type_info* containing_type, size_t* byte_offset); /** * Determines the subtype at the given offset w.r.t. a base address and a corresponding containing type. @@ -179,8 +180,9 @@ typeart_status typeart_get_containing_type(const typeart_type_info* type_info, t * - TYPEART_BAD_OFFSET: The provided offset is invalid. * - TYPEART_ERROR: The typeart_struct_layout is invalid. */ -typeart_status typeart_get_subtype(const typeart_struct_layout* container_layout, const void* base_addr, size_t offset, - typeart_base_type_info* subtype_info, size_t* subtype_byte_offset); +TYPEART_EXPORT typeart_status typeart_get_subtype(const typeart_struct_layout* container_layout, const void* base_addr, + size_t offset, typeart_base_type_info* subtype_info, + size_t* subtype_byte_offset); /** * Returns the stored debug address generated by __builtin_return_address(0). * @@ -191,7 +193,7 @@ typeart_status typeart_get_subtype(const typeart_struct_layout* container_layout * - TYPEART_OK: Success. * - TYPEART_UNKNOWN_ADDRESS: The given address is either not allocated, or was not recorded by the runtime. */ -typeart_status typeart_get_return_address(const void* addr, const void** return_addr); +TYPEART_EXPORT typeart_status typeart_get_return_address(const void* addr, const void** return_addr); /** * Tries to return file, function and line of a memory address from the current process. @@ -207,7 +209,7 @@ typeart_status typeart_get_return_address(const void* addr, const void** return_ * - TYPEART_UNKNOWN_ADDRESS: The given address is either not allocated, or was not recorded by the runtime. * - TYPEART_ERROR: Memory could not be allocated. */ -typeart_status typeart_get_source_location(const void* addr, typeart_source_location* source_loc); +TYPEART_EXPORT typeart_status typeart_get_source_location(const void* addr, typeart_source_location* source_loc); /** * Free previously allocated typeart_source_location. @@ -218,7 +220,7 @@ typeart_status typeart_get_source_location(const void* addr, typeart_source_loca * - TYPEART_OK: Success. * - TYPEART_ERROR: source_loc was NULL. */ -typeart_status typeart_free_source_location(typeart_source_location* source_loc); +TYPEART_EXPORT typeart_status typeart_free_source_location(typeart_source_location* source_loc); /** * Given a type ID, this function provides information about the corresponding struct type. @@ -231,7 +233,7 @@ typeart_status typeart_free_source_location(typeart_source_location* source_loc) * - TYPEART_WRONG_KIND: ID does not correspond to a struct type. * - TYPEART_INVALID_ID: ID is not valid. */ -typeart_status typeart_resolve_type_id(int type_id, typeart_struct_layout* struct_layout); +TYPEART_EXPORT typeart_status typeart_resolve_type_id(int type_id, typeart_struct_layout* struct_layout); /** * Returns the name of the type corresponding to the given type ID. @@ -240,7 +242,7 @@ typeart_status typeart_resolve_type_id(int type_id, typeart_struct_layout* struc * \param[in] type_id The type ID. * \return The name of the type, or "typeart_unknown_struct" if the ID is unknown. */ -const char* typeart_get_type_name(int type_id); +TYPEART_EXPORT const char* typeart_get_type_name(int type_id); /** * Returns true if this is a valid type according to @@ -250,7 +252,7 @@ const char* typeart_get_type_name(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_valid_type(int type_id); +TYPEART_EXPORT bool typeart_is_valid_type(int type_id); /** * Returns true if the type ID is in the pre-determined reserved range, @@ -259,7 +261,7 @@ bool typeart_is_valid_type(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_reserved_type(int type_id); +TYPEART_EXPORT bool typeart_is_reserved_type(int type_id); /** * Returns true if the type ID is a built-in type, @@ -268,7 +270,7 @@ bool typeart_is_reserved_type(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_builtin_type(int type_id); +TYPEART_EXPORT bool typeart_is_builtin_type(int type_id); /** * Returns true if the type ID is a structure type. @@ -278,7 +280,7 @@ bool typeart_is_builtin_type(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_struct_type(int type_id); +TYPEART_EXPORT bool typeart_is_struct_type(int type_id); /** * Returns true if the type ID is a user-defined structure type @@ -287,7 +289,7 @@ bool typeart_is_struct_type(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_userdefined_type(int type_id); +TYPEART_EXPORT bool typeart_is_userdefined_type(int type_id); /** * Returns true if the type ID is a (user-defined) union @@ -295,7 +297,7 @@ bool typeart_is_userdefined_type(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_union(int type_id); +TYPEART_EXPORT bool typeart_is_union(int type_id); /** * Returns true if the type ID is a LLVM SIMD vector type @@ -303,7 +305,7 @@ bool typeart_is_union(int type_id); * \param[in] type_id The type ID. * \return true, false */ -bool typeart_is_vector_type(int type_id); +TYPEART_EXPORT bool typeart_is_vector_type(int type_id); /** * Returns the byte size of the type behind the ID. @@ -311,14 +313,14 @@ bool typeart_is_vector_type(int type_id); * \param[in] type_id The type ID. * \return size in bytes of the type */ -size_t typeart_get_type_size(int type_id); +TYPEART_EXPORT size_t typeart_get_type_size(int type_id); /** * Version string "major.minor(.patch)" of TypeART. * * \return version string */ -const char* typeart_get_project_version(); +TYPEART_EXPORT const char* typeart_get_project_version(); /** * Short Git revision (length: 10) string of TypeART. @@ -327,17 +329,17 @@ const char* typeart_get_project_version(); * * \return revision string */ -const char* typeart_get_git_revision(); +TYPEART_EXPORT const char* typeart_get_git_revision(); /** * Version string "major.minor" of LLVM used to build TypeART. * * \return version string */ -const char* typeart_get_llvm_version(); +TYPEART_EXPORT const char* typeart_get_llvm_version(); #ifdef __cplusplus } #endif -#endif // TYPEART_RUNTIMEINTERFACE_H +#endif /* TYPEART_RUNTIMEINTERFACE_H */ diff --git a/lib/support/CMakeLists.txt b/lib/support/CMakeLists.txt index 61d53d10..7dbb014c 100644 --- a/lib/support/CMakeLists.txt +++ b/lib/support/CMakeLists.txt @@ -32,28 +32,31 @@ if(TYPEART_UBSAN) typeart_target_ubsan_options(${TYPEART_PREFIX}_SystemStatic) endif() -set(CONFIG_NAME ${PROJECT_NAME}System) -set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) -install(FILES Table.h System.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/support -) - -install( - TARGETS ${TYPEART_PREFIX}_SystemStatic - EXPORT ${TARGETS_EXPORT_NAME} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) - -install( - EXPORT ${TARGETS_EXPORT_NAME} - NAMESPACE typeart:: - DESTINATION ${TYPEART_INSTALL_CONFIGDIR} -) - -export( - EXPORT ${TARGETS_EXPORT_NAME} - FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake - NAMESPACE typeart:: -) +if(TYPEART_INSTALL_SYSTEM_LIB) + set(CONFIG_NAME ${PROJECT_NAME}System) + set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) + + install(FILES System.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/support + ) + + install( + TARGETS ${TYPEART_PREFIX}_SystemStatic + EXPORT ${TARGETS_EXPORT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + + install( + EXPORT ${TARGETS_EXPORT_NAME} + NAMESPACE typeart:: + DESTINATION ${TYPEART_INSTALL_CONFIGDIR} + ) + + export( + EXPORT ${TARGETS_EXPORT_NAME} + FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake + NAMESPACE typeart:: + ) +endif() diff --git a/lib/typelib/CMakeLists.txt b/lib/typelib/CMakeLists.txt index 3a926fa1..5ed9da0f 100644 --- a/lib/typelib/CMakeLists.txt +++ b/lib/typelib/CMakeLists.txt @@ -56,31 +56,33 @@ target_include_directories( typeart_target_coverage_options(${TYPEART_PREFIX}_TypesStatic) -set(CONFIG_NAME ${PROJECT_NAME}Types) -set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) - -install(FILES TypeInterface.h TypeDatabase.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} -) - -install( - TARGETS ${TYPEART_PREFIX}_Types ${TYPEART_PREFIX}_TypesStatic - EXPORT ${TARGETS_EXPORT_NAME} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) - -install( - EXPORT ${TARGETS_EXPORT_NAME} - NAMESPACE typeart:: - DESTINATION ${TYPEART_INSTALL_CONFIGDIR} -) - -export( - EXPORT ${TARGETS_EXPORT_NAME} - FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake - NAMESPACE typeart:: -) +if(TYPEART_INSTALL_TYPES_LIB) + set(CONFIG_NAME ${PROJECT_NAME}Types) + set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) + + install(FILES TypeInterface.h TypeDatabase.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} + ) + + install( + TARGETS ${TYPEART_PREFIX}_Types ${TYPEART_PREFIX}_TypesStatic + EXPORT ${TARGETS_EXPORT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + + install( + EXPORT ${TARGETS_EXPORT_NAME} + NAMESPACE typeart:: + DESTINATION ${TYPEART_INSTALL_CONFIGDIR} + ) + + export( + EXPORT ${TARGETS_EXPORT_NAME} + FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake + NAMESPACE typeart:: + ) +endif() #configure_package_config_file( # ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 02261556..06d78905 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -23,7 +23,7 @@ function(typeart_configure_script input output) set(TYPEART_RELOCATABLE 1) else() set(TYPEART_INCLUDE_DIRS - "-I${PROJECT_SOURCE_DIR}/lib/typelib -I${PROJECT_SOURCE_DIR}/lib/runtime -I${PROJECT_SOURCE_DIR}/lib/passes/typegen" + "-I${PROJECT_SOURCE_DIR}/lib/typelib -I${PROJECT_SOURCE_DIR}/lib/runtime -I${PROJECT_SOURCE_DIR}/lib/passes/typegen -I${CMAKE_CURRENT_BINARY_DIR}/../lib/runtime" ) if(LIBRARY_OUTPUT_PATH) set(TYPEART_MPI_INTERCEPT_DIR ${LIBRARY_OUTPUT_PATH}) From cc62cda05e418de2fb604961f831e141a5e3a086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Wed, 17 Dec 2025 21:00:43 +0100 Subject: [PATCH 2/6] Version script for linking --- lib/runtime/CMakeLists.txt | 25 +++++++++++++++++++++++++ test/pass/misc/05_make_all_callbacks.c | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index 5a374e7c..932beeec 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -51,6 +51,31 @@ set_target_properties(${TYPEART_PREFIX}_Runtime PROPERTIES VISIBILITY_INLINES_HIDDEN ON ) +if(UNIX AND NOT APPLE) + set(LINKER_MAP_CONTENTS + [=[{ + global: + typeart_*; + __typeart_*; + extern "C++" { + typeart::*; + }; + local: + *; + };]=]) + + set(RUNTIME_MAP_FILE "${CMAKE_CURRENT_BINARY_DIR}/Runtime.map") + file(WRITE "${RUNTIME_MAP_FILE}" "${LINKER_MAP_CONTENTS}") + + target_link_options(${TYPEART_PREFIX}_Runtime PRIVATE + "-Wl,--version-script,${RUNTIME_MAP_FILE}" + ) + + set_target_properties(${TYPEART_PREFIX}_Runtime PROPERTIES + LINK_DEPENDS "${RUNTIME_MAP_FILE}" + ) +endif() + target_link_libraries( ${TYPEART_PREFIX}_Runtime PRIVATE typeart::TypesStatic diff --git a/test/pass/misc/05_make_all_callbacks.c b/test/pass/misc/05_make_all_callbacks.c index b4201d01..7a6b1601 100644 --- a/test/pass/misc/05_make_all_callbacks.c +++ b/test/pass/misc/05_make_all_callbacks.c @@ -1,4 +1,4 @@ -// RUN: %c-to-llvm %s | %apply-typeart --typeart-stack=true -S 2>&1 | %filecheck %s +// RUN: %c-to-llvm %s -I%runtime_path | %apply-typeart --typeart-stack=true -S 2>&1 | %filecheck %s #include "../../../lib/runtime/CallbackInterface.h" From 67f33c57c4ca477c94ea4a8c9a3ee3333681f46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Wed, 17 Dec 2025 21:52:51 +0100 Subject: [PATCH 3/6] Removed more symbols for runtime, and test fixes --- lib/runtime/CMakeLists.txt | 3 --- scripts/typeart-tmpl.sh.in | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index 932beeec..c889e7d7 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -57,9 +57,6 @@ if(UNIX AND NOT APPLE) global: typeart_*; __typeart_*; - extern "C++" { - typeart::*; - }; local: *; };]=]) diff --git a/scripts/typeart-tmpl.sh.in b/scripts/typeart-tmpl.sh.in index 0d5b88b2..0f9b01cb 100644 --- a/scripts/typeart-tmpl.sh.in +++ b/scripts/typeart-tmpl.sh.in @@ -140,7 +140,7 @@ function global_init() { readonly typeart_includes="${typeart_include_dir}" readonly typeart_ldflags="-L${typeart_lib_dir}/ \ -Wl,-rpath,${typeart_lib_dir}/ \ - -l$" + -l$ -Wl,--start-group $ $ $ $ -Wl,--end-group" # shellcheck disable=SC2027 typeart_plugin="-load-pass-plugin "${typeart_pass}" -passes=typeart<" @@ -255,7 +255,7 @@ function compile() { function main_link() { more_link_flags="-fPIC" - $compiler ${more_link_flags} ${omp_flags} ${threads_flags} ${typeart_san_flags} ${typeart_ldflags} "${object_file}" -o "${exe_file}" + $compiler ${more_link_flags} ${omp_flags} ${threads_flags} ${typeart_san_flags} "${object_file}" ${typeart_ldflags} -o "${exe_file}" } function execute() { From 19ccd24537c5338c0778f110f94e36bd0ee0f877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Thu, 18 Dec 2025 13:31:43 +0100 Subject: [PATCH 4/6] Link system libs --- scripts/typeart-tmpl.sh.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/typeart-tmpl.sh.in b/scripts/typeart-tmpl.sh.in index 0f9b01cb..e630bd37 100644 --- a/scripts/typeart-tmpl.sh.in +++ b/scripts/typeart-tmpl.sh.in @@ -132,6 +132,8 @@ function global_init() { readonly typeart_interceptor="@TYPEART_MPI_INTERCEPT_DIR@/@TYPEART_MPI_TOOL@" fi + readonly llvm_sys_libs=$(llvm-config --system-libs) + readonly typeart_has_interceptor="@TYPEART_HAS_MPI_TOOL@" readonly opt_tool="@TYPEART_OPT@" @@ -140,7 +142,7 @@ function global_init() { readonly typeart_includes="${typeart_include_dir}" readonly typeart_ldflags="-L${typeart_lib_dir}/ \ -Wl,-rpath,${typeart_lib_dir}/ \ - -l$ -Wl,--start-group $ $ $ $ -Wl,--end-group" + -l$ -Wl,--start-group $ $ $ $ ${llvm_sys_libs} -Wl,--end-group" # shellcheck disable=SC2027 typeart_plugin="-load-pass-plugin "${typeart_pass}" -passes=typeart<" From be53dca6aa1bb623b88a64f6903a4e06e981cb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Thu, 18 Dec 2025 13:49:51 +0100 Subject: [PATCH 5/6] Find llvm-config --- scripts/CMakeLists.txt | 2 ++ scripts/typeart-tmpl.sh.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 06d78905..deec4f20 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -181,6 +181,8 @@ typeart_configure_coverage_script(llvm-gcov.sh.in llvm-gcov.sh) typeart_configure_script(opt-shim.in opt-shim) +typeart_find_llvm_progs(TYPEART_LLVMCONFIG_COMMAND "llvm-config-${LLVM_VERSION_MAJOR};llvm-config" +HINTS /usr/lib/llvm-${LLVM_VERSION_MAJOR}/bin/) typeart_configure_script(typeart-tmpl.sh.in run.sh OPT ON) typeart_configure_script(typeart-tmpl.sh.in apply.sh diff --git a/scripts/typeart-tmpl.sh.in b/scripts/typeart-tmpl.sh.in index e630bd37..bc353d44 100644 --- a/scripts/typeart-tmpl.sh.in +++ b/scripts/typeart-tmpl.sh.in @@ -132,7 +132,7 @@ function global_init() { readonly typeart_interceptor="@TYPEART_MPI_INTERCEPT_DIR@/@TYPEART_MPI_TOOL@" fi - readonly llvm_sys_libs=$(llvm-config --system-libs) + readonly llvm_sys_libs=$(@TYPEART_LLVMCONFIG_COMMAND@ --system-libs) readonly typeart_has_interceptor="@TYPEART_HAS_MPI_TOOL@" From c50bae83143d5f376a50fef333d3e2a7491f752b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Thu, 18 Dec 2025 14:12:44 +0100 Subject: [PATCH 6/6] Disable tests in CI --- CMakePresets.json | 3 ++- test/CMakeLists.txt | 1 + test/lit.cfg | 3 +++ test/lit.site.cfg.in | 1 + test/runtime/44_typedb.cpp | 2 ++ test/runtime/47_memory_use.cpp | 2 ++ 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 17d0a0da..86cc1818 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -138,7 +138,8 @@ ], "cacheVariables": { "TYPEART_ASAN": "OFF", - "TYPEART_UBSAN": "OFF" + "TYPEART_UBSAN": "OFF", + "TYPEART_CI_RUN": "ON" } }, { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ab79a884..13ae0faa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,6 +45,7 @@ function(typeart_configure_lit_site input output) pythonize_bool(MPI_C_FOUND TYPEARTPASS_MPI_C) pythonize_bool(MPI_CXX_FOUND TYPEARTPASS_MPI_CXX) + pythonize_bool(TYPEART_CI_RUN TYPEARTPASS_CI_RUN) pythonize_bool(TYPEART_TSAN TYPEARTPASS_TSAN) pythonize_bool(TYPEART_ASAN TYPEARTPASS_ASAN) diff --git a/test/lit.cfg b/test/lit.cfg index b199110f..163bbdcc 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -55,6 +55,9 @@ if config.coverage: if config.has_legacy_wrapper: config.available_features.add('legacywrapper') +if config.is_ci: + config.available_features.add('ci') + profile_files = getattr(config, 'profile_file', None) typeart_base_lib_dir= getattr(config, 'typeart_base_lib_dir', None) typeart_lib_root = getattr(config, 'typeart_lib_dir', None) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 0cb824f3..7a37f7cc 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -44,6 +44,7 @@ config.python_interp = "@Python3_EXECUTABLE@" config.llvm_version = @LLVM_VERSION_MAJOR@ config.has_legacy_wrapper = @TYPEARTPASS_LEGACY_WRAPPER@ +config.is_ci = @TYPEARTPASS_CI_RUN@ # Let the main config do the real work. config.loaded_site_config = True diff --git a/test/runtime/44_typedb.cpp b/test/runtime/44_typedb.cpp index 64bbaed1..f3eb1305 100644 --- a/test/runtime/44_typedb.cpp +++ b/test/runtime/44_typedb.cpp @@ -1,6 +1,8 @@ // RUN: export TYPEART_TYPE_SERIALIZATION=file // RUN: %run %s --compile_flags "-std=c++17" -o -O3 2>&1 | %filecheck %s +// REQUIRES: !ci + // TODO fails for inline/hybrid #include "../../lib/runtime/RuntimeInterface.h" diff --git a/test/runtime/47_memory_use.cpp b/test/runtime/47_memory_use.cpp index 04b6a80c..90205dff 100644 --- a/test/runtime/47_memory_use.cpp +++ b/test/runtime/47_memory_use.cpp @@ -1,5 +1,7 @@ // RUN: %run %s --compile_flags "-std=c++17" 2>&1 | %filecheck %s +// REQUIRES: !ci + #include "../../lib/support/System.h" #include