From 8aae7e11356f101efd4f1944d4a074b9d7e3666f Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 19 Mar 2024 17:28:09 +0800 Subject: [PATCH 1/5] Install mimalloc headers --- Makefile.pre.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile.pre.in b/Makefile.pre.in index 404e7ee3e42054..980181b199ff4b 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2581,6 +2581,11 @@ inclinstall: $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \ else true; \ fi + @if test ! -d $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; then \ + echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ + else true; \ + fi @for i in $(srcdir)/Include/*.h; \ do \ echo $(INSTALL_DATA) $$i $(INCLUDEPY); \ @@ -2596,6 +2601,12 @@ inclinstall: echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ done + $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc + @for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ + done $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h # Install the library and miscellaneous stuff needed for extending/embedding From deef17cc65f18428534c0f1fbba73f307c52e513 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Tue, 19 Mar 2024 22:34:45 +0800 Subject: [PATCH 2/5] add echo --- Makefile.pre.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 980181b199ff4b..cfe719faaf72ad 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2601,12 +2601,14 @@ inclinstall: echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ done - $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc + echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h + $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h @for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ do \ echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ done + echo $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h # Install the library and miscellaneous stuff needed for extending/embedding From 78c228bf1abd98b997c99583d2f9e528583876af Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 20 Mar 2024 10:31:16 +0800 Subject: [PATCH 3/5] Install mimalloc header only when enabled --- Makefile.pre.in | 28 +++++++++++++++++----------- configure | 1 + configure.ac | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index cfe719faaf72ad..cfd2394030c909 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -227,6 +227,9 @@ LIBHACL_SHA2_A= Modules/_hacl/libHacl_Hash_SHA2.a # Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var TZPATH=@TZPATH@ +# If to install mimalloc headers +WITH_MIMALLOC=@WITH_MIMALLOC@ + # Modes for directories, executables and data files created by the # install process. Default to user-only-writable for all file types. DIRMODE= 755 @@ -2581,10 +2584,11 @@ inclinstall: $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \ else true; \ fi - @if test ! -d $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; then \ - echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc"; \ - $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ - else true; \ + @if test "$(WITH_MIMALLOC)" == "yes"; then \ + if test ! -d $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; then \ + echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc"; \ + $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ + fi; \ fi @for i in $(srcdir)/Include/*.h; \ do \ @@ -2601,13 +2605,15 @@ inclinstall: echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ done - echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h - $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h - @for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ - do \ - echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \ - $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ - done + @if test "$(WITH_MIMALLOC)" == "yes"; then \ + echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ + $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ + for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ + do \ + echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ + done; \ + fi echo $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h diff --git a/configure b/configure index 07dce38c92724f..136333905f72ae 100755 --- a/configure +++ b/configure @@ -17301,6 +17301,7 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_mimalloc" >&5 printf "%s\n" "$with_mimalloc" >&6; } +WITH_MIMALLOC=$with_mimalloc diff --git a/configure.ac b/configure.ac index 3e676c56693a3c..1d137f61324315 100644 --- a/configure.ac +++ b/configure.ac @@ -4752,7 +4752,7 @@ elif test "$disable_gil" = "yes"; then fi AC_MSG_RESULT([$with_mimalloc]) -AC_SUBST([WITH_MIMALLOC]) +AC_SUBST([WITH_MIMALLOC], $with_mimalloc) AC_SUBST([MIMALLOC_HEADERS]) # Check for Python-specific malloc support From 207e87b858f97c3a724f1c1c1187a53c0e020816 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 20 Mar 2024 10:57:40 +0800 Subject: [PATCH 4/5] Rename `WITH_MIMALLOC` to avoid different var with same name --- Makefile.pre.in | 6 +++--- configure | 4 ++-- configure.ac | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index cfd2394030c909..c883889622bdac 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -228,7 +228,7 @@ LIBHACL_SHA2_A= Modules/_hacl/libHacl_Hash_SHA2.a TZPATH=@TZPATH@ # If to install mimalloc headers -WITH_MIMALLOC=@WITH_MIMALLOC@ +INSTALL_MIMALLOC=@INSTALL_MIMALLOC@ # Modes for directories, executables and data files created by the # install process. Default to user-only-writable for all file types. @@ -2584,7 +2584,7 @@ inclinstall: $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \ else true; \ fi - @if test "$(WITH_MIMALLOC)" == "yes"; then \ + @if test "$(INSTALL_MIMALLOC)" == "yes"; then \ if test ! -d $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; then \ echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc"; \ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \ @@ -2605,7 +2605,7 @@ inclinstall: echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \ done - @if test "$(WITH_MIMALLOC)" == "yes"; then \ + @if test "$(INSTALL_MIMALLOC)" == "yes"; then \ echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \ for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \ diff --git a/configure b/configure index 136333905f72ae..aad5d04c41351c 100755 --- a/configure +++ b/configure @@ -869,7 +869,7 @@ DTRACE_OBJS DTRACE_HEADERS DFLAGS DTRACE -WITH_MIMALLOC +INSTALL_MIMALLOC MIMALLOC_HEADERS GDBM_LIBS GDBM_CFLAGS @@ -17301,7 +17301,7 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_mimalloc" >&5 printf "%s\n" "$with_mimalloc" >&6; } -WITH_MIMALLOC=$with_mimalloc +INSTALL_MIMALLOC=$with_mimalloc diff --git a/configure.ac b/configure.ac index 1d137f61324315..ac7f2160509112 100644 --- a/configure.ac +++ b/configure.ac @@ -4752,7 +4752,7 @@ elif test "$disable_gil" = "yes"; then fi AC_MSG_RESULT([$with_mimalloc]) -AC_SUBST([WITH_MIMALLOC], $with_mimalloc) +AC_SUBST([INSTALL_MIMALLOC], $with_mimalloc) AC_SUBST([MIMALLOC_HEADERS]) # Check for Python-specific malloc support From cf7d0cf0c7f2c0222f814de17f791d0ce92a2d25 Mon Sep 17 00:00:00 2001 From: Yichen Yan Date: Wed, 20 Mar 2024 17:59:18 +0800 Subject: [PATCH 5/5] Update configure.ac Co-authored-by: Erlend E. Aasland --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ac7f2160509112..4c8580b254e6f3 100644 --- a/configure.ac +++ b/configure.ac @@ -4752,7 +4752,7 @@ elif test "$disable_gil" = "yes"; then fi AC_MSG_RESULT([$with_mimalloc]) -AC_SUBST([INSTALL_MIMALLOC], $with_mimalloc) +AC_SUBST([INSTALL_MIMALLOC], [$with_mimalloc]) AC_SUBST([MIMALLOC_HEADERS]) # Check for Python-specific malloc support