From cf8815854cb0eff64394ef324a2f693d15dab91a Mon Sep 17 00:00:00 2001 From: daan Date: Tue, 9 Jul 2019 11:32:24 -0700 Subject: [PATCH 1/2] fix cmake issues with OBJECT install --- CMakeLists.txt | 3 ++- cmake/mimalloc-config.cmake | 1 + test/CMakeLists.txt | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88734360..d6216384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,8 @@ target_include_directories(mimalloc-obj PUBLIC $ ) -install(TARGETS mimalloc-obj EXPORT mimalloc DESTINATION ${mi_install_dir}) +# seems to lead to cmake warnings/errors on some systems, disable for now :-( +# install(TARGETS mimalloc-obj EXPORT mimalloc DESTINATION ${mi_install_dir}) install(FILES $ DESTINATION ${mi_install_dir} diff --git a/cmake/mimalloc-config.cmake b/cmake/mimalloc-config.cmake index b7ced994..12da076e 100644 --- a/cmake/mimalloc-config.cmake +++ b/cmake/mimalloc-config.cmake @@ -1 +1,2 @@ include(${CMAKE_CURRENT_LIST_DIR}/mimalloc.cmake) +get_filename_component(MIMALLOC_TARGET_DIR "${CMAKE_CURRENT_LIST_DIR}" PATH) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a9efaff9..42d4a2f4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,7 +31,7 @@ target_link_libraries(static-override PUBLIC mimalloc-static) add_executable(static-override-cxx main-override.cpp) target_link_libraries(static-override-cxx PUBLIC mimalloc-static) -# and with a static object file; need to link with pthread explicitly :-( -add_executable(static-override-obj main-override.c $) -target_include_directories(static-override-obj PUBLIC $) +# and with a static object file +add_executable(static-override-obj main-override.c ${MIMALLOC_TARGET_DIR}/mimalloc.o) +target_include_directories(static-override-obj PUBLIC ${MIMALLOC_TARGET_DIR}/include) target_link_libraries(static-override-obj PUBLIC pthread) From 8ef37e6c0b19dec90b3589d42b8e348fcb8786a7 Mon Sep 17 00:00:00 2001 From: daan Date: Tue, 9 Jul 2019 14:56:43 -0700 Subject: [PATCH 2/2] update atomic exchange memory model annotations for unix --- include/mimalloc-atomic.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mimalloc-atomic.h b/include/mimalloc-atomic.h index b295aae2..7b7cb383 100644 --- a/include/mimalloc-atomic.h +++ b/include/mimalloc-atomic.h @@ -139,15 +139,15 @@ static inline uint32_t mi_atomic_subtract32(volatile uint32_t* p, uint32_t sub) } static inline bool mi_atomic_compare_exchange32(volatile uint32_t* p, uint32_t exchange, uint32_t compare) { MI_USING_STD - return atomic_compare_exchange_weak_explicit((volatile _Atomic(uint32_t)*)p, &compare, exchange, memory_order_relaxed, memory_order_seq_cst); + return atomic_compare_exchange_weak_explicit((volatile _Atomic(uint32_t)*)p, &compare, exchange, memory_order_release, memory_order_relaxed); } static inline bool mi_atomic_compare_exchange(volatile uintptr_t* p, uintptr_t exchange, uintptr_t compare) { MI_USING_STD - return atomic_compare_exchange_weak_explicit((volatile atomic_uintptr_t*)p, &compare, exchange, memory_order_relaxed, memory_order_seq_cst); + return atomic_compare_exchange_weak_explicit((volatile atomic_uintptr_t*)p, &compare, exchange, memory_order_release, memory_order_relaxed); } static inline uintptr_t mi_atomic_exchange(volatile uintptr_t* p, uintptr_t exchange) { MI_USING_STD - return atomic_exchange_explicit((volatile atomic_uintptr_t*)p, exchange, memory_order_relaxed); + return atomic_exchange_explicit((volatile atomic_uintptr_t*)p, exchange, memory_order_acquire); } #if defined(__cplusplus)