From c42347d025b29e993a12925a3ddf58c0c9bb7f7b Mon Sep 17 00:00:00 2001 From: Dino Viehland Date: Tue, 31 Oct 2023 11:54:35 -0700 Subject: [PATCH] gh-90815: Exclude mimalloc .c files from Windows build (#111532) * Don't include mimalloc .c's in Windows build * Fix warnings on Windows related to mimalloc --- Objects/obmalloc.c | 19 ++++++------ PC/pyconfig.h | 3 ++ PCbuild/_freeze_module.vcxproj | 14 --------- PCbuild/_freeze_module.vcxproj.filters | 42 -------------------------- PCbuild/pythoncore.vcxproj | 14 --------- PCbuild/pythoncore.vcxproj.filters | 42 -------------------------- 6 files changed, 13 insertions(+), 121 deletions(-) diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d230bbdad3c..2761c774209 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -2730,22 +2730,23 @@ static bool _collect_alloc_stats( static void py_mimalloc_print_stats(FILE *out) { - fprintf(out, "Small block threshold = %ld, in %u size classes.\n", + fprintf(out, "Small block threshold = %zd, in %u size classes.\n", MI_SMALL_OBJ_SIZE_MAX, MI_BIN_HUGE); - fprintf(out, "Medium block threshold = %ld\n", + fprintf(out, "Medium block threshold = %zd\n", MI_MEDIUM_OBJ_SIZE_MAX); - fprintf(out, "Large object max size = %ld\n", + fprintf(out, "Large object max size = %zd\n", MI_LARGE_OBJ_SIZE_MAX); mi_heap_t *heap = mi_heap_get_default(); - struct _alloc_stats stats = {}; + struct _alloc_stats stats; + memset(&stats, 0, sizeof(stats)); mi_heap_visit_blocks(heap, false, &_collect_alloc_stats, &stats); - fprintf(out, " Allocated Blocks: %ld\n", stats.allocated_blocks); - fprintf(out, " Allocated Bytes: %ld\n", stats.allocated_bytes); - fprintf(out, " Allocated Bytes w/ Overhead: %ld\n", stats.allocated_with_overhead); - fprintf(out, " Bytes Reserved: %ld\n", stats.bytes_reserved); - fprintf(out, " Bytes Committed: %ld\n", stats.bytes_committed); + fprintf(out, " Allocated Blocks: %zd\n", stats.allocated_blocks); + fprintf(out, " Allocated Bytes: %zd\n", stats.allocated_bytes); + fprintf(out, " Allocated Bytes w/ Overhead: %zd\n", stats.allocated_with_overhead); + fprintf(out, " Bytes Reserved: %zd\n", stats.bytes_reserved); + fprintf(out, " Bytes Committed: %zd\n", stats.bytes_committed); } #endif diff --git a/PC/pyconfig.h b/PC/pyconfig.h index ac20129cd30..e6b368caffe 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -511,6 +511,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 +/* Define if you want to compile in mimalloc memory allocator. */ +#define WITH_MIMALLOC 1 + /* Define if you want to compile in object freelists optimization */ #define WITH_FREELISTS 1 diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 05b8bfdc38a..20d800a6959 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -147,20 +147,6 @@ - - - - - - - - - - - - - - diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index d6cbd2d3d47..40256a22fb5 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -253,48 +253,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 954a59a0bc7..4d3621a6146 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -498,20 +498,6 @@ - - - - - - - - - - - - - - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 2f8b206f973..69d8e0312e0 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -1130,48 +1130,6 @@ Objects - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - - - Objects\mimalloc - Objects