diff --git a/3party/gperftools/CMakeLists.txt b/3party/gperftools/CMakeLists.txt index 3fae6cd..1ae1c4b 100644 --- a/3party/gperftools/CMakeLists.txt +++ b/3party/gperftools/CMakeLists.txt @@ -864,6 +864,7 @@ if(GPERFTOOLS_BUILD_HEAP_CHECKER OR GPERFTOOLS_BUILD_HEAP_PROFILER) add_library(tcmalloc_internal INTERFACE) target_sources(tcmalloc_internal INTERFACE $) target_link_libraries(tcmalloc_internal INTERFACE ${libtcmalloc_internal_la_LIBADD}) + target_include_directories(tcmalloc_internal INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src) add_library(tcmalloc SHARED ${libtcmalloc_la_SOURCES}) target_compile_definitions(tcmalloc PRIVATE ${libtcmalloc_la_DEFINE}) @@ -939,6 +940,7 @@ if(GPERFTOOLS_BUILD_CPU_PROFILER) add_library(profiler SHARED ${libprofiler_la_SOURCES}) target_link_libraries(profiler PRIVATE ${libprofiler_la_LIBADD}) target_link_libraries(profiler PRIVATE Threads::Threads) + target_include_directories(profiler INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src) set_target_properties(profiler PROPERTIES VERSION ${PROFILER_SO_VERSION} SOVERSION ${PROFILER_SO_VERSION}) @@ -946,6 +948,7 @@ if(GPERFTOOLS_BUILD_CPU_PROFILER) if(GPERFTOOLS_BUILD_STATIC) add_library(profiler_static STATIC ${libprofiler_la_SOURCES}) target_link_libraries(profiler_static PRIVATE ${libprofiler_la_LIBADD}) + target_include_directories(profiler_static INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src) if(NOT MSVC) set_target_properties(profiler_static PROPERTIES OUTPUT_NAME profiler) endif() @@ -987,6 +990,7 @@ if(GPERFTOOLS_BUILD_HEAP_PROFILER OR GPERFTOOLS_BUILD_HEAP_CHECKER) add_library(tcmalloc_and_profiler_static STATIC ${libtcmalloc_la_SOURCES} ${libprofiler_la_SOURCES}) target_compile_definitions(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_DEFINE}) target_link_libraries(tcmalloc_and_profiler_static PRIVATE ${libtcmalloc_la_LIBADD}) + target_include_directories(tcmalloc_and_profiler_static INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src) if(NOT MSVC) set_target_properties(tcmalloc_and_profiler_static PROPERTIES OUTPUT_NAME tcmalloc_and_profiler) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2c4f49..5925e6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set(BUILD_EXAMPLES OFF) add_library(sled STATIC "") add_subdirectory(3party/gperftools EXCLUDE_FROM_ALL) -add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL) +# add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL) add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL) if (NOT TARGET marl) add_subdirectory(3party/marl EXCLUDE_FROM_ALL) @@ -72,11 +72,24 @@ target_sources( # set(BUILD_RTTR_DYNAMIC OFF) set(BUILD_UNIT_TESTS OFF) # set(BUILD_WITH_STATIC_RUNTIME_LIBS ON) set(BUILD_WITH_DOCUMENTATION OFF) # add_subdirectory(3party/rttr EXCLUDE_FROM_ALL) +include(CheckCCompilerFlag) +check_c_compiler_flag("-Wl,--whole-archive" SUPPORT_COMPILE_WHOLE_ARCHIVE) +if (SUPPORT_COMPILE_WHOLE_ARCHIVE) + set(WHOLE_ARCHIVE_WRAPPER_START "-Wl,--whole-archive") + set(WHOLE_ARCHIVE_WRAPPER_END "-Wl,--no-whole-archive") +endif() + target_link_libraries(sled - PUBLIC rpc_core fmt marl protobuf::libprotobuf cppuprofile tcmalloc_and_profiler_static + PUBLIC rpc_core fmt marl protobuf::libprotobuf # cppuprofile + # ${WHOLE_ARCHIVE_WRAPPER_START} + tcmalloc_and_profiler_static + # ${WHOLE_ARCHIVE_WRAPPER_END} ) +## set fPIC +set_target_properties(sled PROPERTIES POSITION_INDEPENDENT_CODE ON) + if(SLED_BUILD_BENCHMARK) if (NOT TARGET benchmark) find_package(benchmark REQUIRED) diff --git a/include/sled/lang/attributes.h b/include/sled/lang/attributes.h index ca29caf..2be4efb 100644 --- a/include/sled/lang/attributes.h +++ b/include/sled/lang/attributes.h @@ -2,7 +2,10 @@ #ifndef SLED_LANG_ATTRIBUTES_H #define SLED_LANG_ATTRIBUTES_H +#include + #define SLED_DEPRECATED() __attribute__((deprecated)) +#ifndef THREAD_ANNOTATION_ATTRIBUTE__ #if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) && !defined(SWIG) #define THREAD_ANNOTATION_ATTRIBUTE__(x) #elif defined(__clang__) @@ -10,12 +13,11 @@ #else #define THREAD_ANNOTATION_ATTRIBUTE__(x) #endif +#endif// THREAD_ANNOTATION_ATTRIBUTE__ -#if defined(GUARDED_BY) -#undef GUARDED_BY -#endif - +#ifndef GUARDED_BY #define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) +#endif #if defined(__clang__) #define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) @@ -24,14 +26,14 @@ #define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) -#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) +// #define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) #else// defined(__clang__) #define EXCLUSIVE_TRYLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock(__VA_ARGS__)) #define EXCLUSIVE_LOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock(__VA_ARGS__)) #define UNLOCK_FUNCTION(...) THREAD_ANNOTATION_ATTRIBUTE__(unlock(__VA_ARGS__)) -#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded_by(x)) +// #define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded_by(x)) #endif #endif// SLED_LANG_ATTRIBUTES_H diff --git a/src/include/sled/ubench.h b/src/include/sled/ubench.h deleted file mode 100644 index 17c211a..0000000 --- a/src/include/sled/ubench.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file : {{FILE}} - * @created : {{TIMESTAMP}} - * @license : {{LICENSE}} - **/ - -#ifndef{{MACRO_GUARD } } -#define{{MACRO_GUARD } } - -namespace { -{ - CURSOR -} -}// namespace - -{ - - class { - { - CAMEL_CLASS - } - } { - public: - - }; - -}// namespace - -#endif// {{MACRO_GUARD}} diff --git a/src/profiling/profiling.cc b/src/profiling/profiling.cc index f51447c..1d976ac 100644 --- a/src/profiling/profiling.cc +++ b/src/profiling/profiling.cc @@ -1,5 +1,6 @@ #include "sled/profiling/profiling.h" -#include + +// #include namespace sled { Profiling * @@ -12,7 +13,7 @@ Profiling::Instance() bool Profiling::Start(const std::string &file) { - uprofile::start(file.c_str()); + // uprofile::start(file.c_str()); started_ = true; return true; } @@ -20,53 +21,53 @@ Profiling::Start(const std::string &file) void Profiling::Stop() { - uprofile::stop(); + // uprofile::stop(); } void Profiling::TimeBegin(const std::string &name) { if (!started_) return; - uprofile::timeBegin(name); + // uprofile::timeBegin(name); } void Profiling::TimeEnd(const std::string &name) { if (!started_) return; - uprofile::timeEnd(name); + // uprofile::timeEnd(name); } void Profiling::StartProcessMemoryMonitoring(int period_ms) { if (!started_) return; - uprofile::startProcessMemoryMonitoring(period_ms); + // uprofile::startProcessMemoryMonitoring(period_ms); } void Profiling::StartSystemMemoryMonitoring(int period_ms) { if (!started_) return; - uprofile::startSystemMemoryMonitoring(period_ms); + // uprofile::startSystemMemoryMonitoring(period_ms); } void Profiling::StartCPUUsageMonitoring(int period_ms) { if (!started_) return; - uprofile::startCPUUsageMonitoring(period_ms); + // uprofile::startCPUUsageMonitoring(period_ms); } void Profiling::GetSystemMemory(int &total_mem, int &available_mem, int &free_mem) { - uprofile::getSystemMemory(total_mem, available_mem, free_mem); + // uprofile::getSystemMemory(total_mem, available_mem, free_mem); } void Profiling::GetProcessMemory(int &rss, int &shared) { - uprofile::getProcessMemory(rss, shared); + // uprofile::getProcessMemory(rss, shared); } }// namespace sled