gh-90815: Exclude mimalloc .c files from Windows build (#111532)
https://github.com/python/cpython/commit/c42347d025b29e993a12925a3ddf58c0c9b... commit: c42347d025b29e993a12925a3ddf58c0c9bb7f7b branch: main author: Dino Viehland <dinoviehland@fb.com> committer: DinoV <dinoviehland@gmail.com> date: 2023-10-31T11:54:35-07:00 summary: 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 files: M Objects/obmalloc.c M PC/pyconfig.h M PCbuild/_freeze_module.vcxproj M PCbuild/_freeze_module.vcxproj.filters M PCbuild/pythoncore.vcxproj M PCbuild/pythoncore.vcxproj.filters diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d230bbdad3c4c..2761c77420978 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 ac20129cd30fc..e6b368caffe28 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 05b8bfdc38a99..20d800a695955 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -147,20 +147,6 @@ <ClCompile Include="..\Objects\longobject.c" /> <ClCompile Include="..\Objects\memoryobject.c" /> <ClCompile Include="..\Objects\methodobject.c" /> - <ClCompile Include="..\Objects\mimalloc\alloc-aligned.c" /> - <ClCompile Include="..\Objects\mimalloc\alloc.c" /> - <ClCompile Include="..\Objects\mimalloc\arena.c" /> - <ClCompile Include="..\Objects\mimalloc\bitmap.c" /> - <ClCompile Include="..\Objects\mimalloc\heap.c" /> - <ClCompile Include="..\Objects\mimalloc\init.c" /> - <ClCompile Include="..\Objects\mimalloc\options.c" /> - <ClCompile Include="..\Objects\mimalloc\os.c" /> - <ClCompile Include="..\Objects\mimalloc\page.c" /> - <ClCompile Include="..\Objects\mimalloc\prim\prim.c" /> - <ClCompile Include="..\Objects\mimalloc\random.c" /> - <ClCompile Include="..\Objects\mimalloc\segment.c" /> - <ClCompile Include="..\Objects\mimalloc\segment-map.c" /> - <ClCompile Include="..\Objects\mimalloc\stats.c" /> <ClCompile Include="..\Objects\moduleobject.c" /> <ClCompile Include="..\Objects\namespaceobject.c" /> <ClCompile Include="..\Objects\object.c" /> diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index d6cbd2d3d4736..40256a22fb556 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -253,48 +253,6 @@ <ClCompile Include="..\Objects\methodobject.c"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\Objects\mimalloc\alloc-aligned.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\alloc.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\arena.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\bitmap.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\heap.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\init.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\options.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\os.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\page.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\prim\prim.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\random.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\segment.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\segment-map.c"> - <Filter>Source Files</Filter> - </CLCompile> - <ClCompile Include="..\Objects\mimalloc\stats.c"> - <Filter>Source Files</Filter> - </CLCompile> <ClCompile Include="..\Python\modsupport.c"> <Filter>Source Files</Filter> </ClCompile> diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 954a59a0bc701..4d3621a614680 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -498,20 +498,6 @@ <ClCompile Include="..\Objects\longobject.c" /> <ClCompile Include="..\Objects\memoryobject.c" /> <ClCompile Include="..\Objects\methodobject.c" /> - <ClCompile Include="..\Objects\mimalloc\alloc-aligned.c" /> - <ClCompile Include="..\Objects\mimalloc\alloc.c" /> - <ClCompile Include="..\Objects\mimalloc\arena.c" /> - <ClCompile Include="..\Objects\mimalloc\bitmap.c" /> - <ClCompile Include="..\Objects\mimalloc\heap.c" /> - <ClCompile Include="..\Objects\mimalloc\init.c" /> - <ClCompile Include="..\Objects\mimalloc\options.c" /> - <ClCompile Include="..\Objects\mimalloc\os.c" /> - <ClCompile Include="..\Objects\mimalloc\page.c" /> - <ClCompile Include="..\Objects\mimalloc\prim\prim.c" /> - <ClCompile Include="..\Objects\mimalloc\random.c" /> - <ClCompile Include="..\Objects\mimalloc\segment.c" /> - <ClCompile Include="..\Objects\mimalloc\segment-map.c" /> - <ClCompile Include="..\Objects\mimalloc\stats.c" /> <ClCompile Include="..\Objects\moduleobject.c" /> <ClCompile Include="..\Objects\namespaceobject.c" /> <ClCompile Include="..\Objects\object.c" /> diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 2f8b206f973f3..69d8e0312e016 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -1130,48 +1130,6 @@ <ClCompile Include="..\Objects\methodobject.c"> <Filter>Objects</Filter> </ClCompile> - <ClCompile Include="..\Objects\mimalloc\alloc.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\alloc-aligned.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\arena.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\bitmap.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\heap.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\init.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\options.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\os.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\page.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\prim\prim.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\random.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\segment.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\segment-map.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> - <ClCompile Include="..\Objects\mimalloc\stats.c"> - <Filter>Objects\mimalloc</Filter> - </ClCompile> <ClCompile Include="..\Objects\moduleobject.c"> <Filter>Objects</Filter> </ClCompile>
participants (1)
-
DinoV