use consistent naming on Windows vs other platforms. Use mimalloc.dll.lib for the dll import library to avoid a clash with the static mimalloc.lib library

This commit is contained in:
daanx 2025-01-09 20:57:08 -08:00
parent 600ca88e87
commit 4fcf56af2e
7 changed files with 61 additions and 53 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.18)
project(mimalloc-test C CXX)
set(CMAKE_C_STANDARD 11)
@ -16,7 +16,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif()
# Import mimalloc (if installed)
find_package(mimalloc 1.7 REQUIRED NO_SYSTEM_ENVIRONMENT_PATH)
find_package(mimalloc 1.9 CONFIG REQUIRED)
message(STATUS "Found mimalloc installed at: ${MIMALLOC_LIBRARY_DIR} (${MIMALLOC_VERSION_DIR})")
# overriding with a dynamic library
@ -29,9 +29,9 @@ target_link_libraries(dynamic-override-cxx PUBLIC mimalloc)
# overriding with a static object file works reliable as the symbols in the
# object file have priority over those in library files
add_executable(static-override-obj main-override.c ${MIMALLOC_OBJECT_DIR}/mimalloc.o)
add_executable(static-override-obj main-override.c ${MIMALLOC_OBJECT_DIR}/mimalloc${CMAKE_C_OUTPUT_EXTENSION})
target_include_directories(static-override-obj PUBLIC ${MIMALLOC_INCLUDE_DIR})
target_link_libraries(static-override-obj PUBLIC pthread)
target_link_libraries(static-override-obj PUBLIC mimalloc-static)
# overriding with a static library works too if using the `mimalloc-override.h`

View file

@ -37,9 +37,9 @@ static void test_thread_local(); // issue #944
static void test_mixed1(); // issue #942
static void test_stl_allocators();
#if _WIN32
#if x_WIN32
#include "main-override-dep.h"
static void test_dep(); // issue #981: test overriding in another DLL
static void test_dep(); // issue #981: test overriding in another DLL
#else
static void test_dep() { };
#endif
@ -50,7 +50,7 @@ int main() {
test_mixed1();
test_dep();
//test_std_string();
//test_thread_local();
// heap_thread_free_huge();
@ -59,7 +59,7 @@ int main() {
heap_no_delete();
heap_late_free();
padding_shrink();
tsan_numa_test();
*/
/*
@ -112,8 +112,10 @@ static void various_tests() {
t->~Test();
delete[] tbuf;
#if _WIN32
const char* ptr = ::_Getdays(); // test _base overrid
free((void*)ptr);
#endif
}
class Static {
@ -143,7 +145,7 @@ static bool test_stl_allocator1() {
struct some_struct { int i; int j; double z; };
#if _WIN32
#if x_WIN32
static void test_dep()
{
TestAllocInDll t;
@ -236,7 +238,7 @@ static void test_mixed0() {
std::cout << "Running on " << threads.size() << " threads took " << duration
<< std::endl;
}
#endif
#endif
void asd() {
void* p = malloc(128);
@ -401,7 +403,7 @@ static void test_mt_shutdown()
// issue #372
static void fail_aslr() {
size_t sz = (4ULL << 40); // 4TiB
size_t sz = (size_t)(4ULL << 40); // 4TiB
void* p = malloc(sz);
printf("pointer p: %p: area up to %p\n", p, (uint8_t*)p + sz);
*(int*)0x5FFFFFFF000 = 0; // should segfault