Skip to content

Commit e7d4c50

Browse files
committed
amend! mimalloc: offer a build-time option to enable it
mimalloc: offer a build-time option to enable it By defining `USE_MIMALLOC`, Git can now be compiled with that nicely-fast and small allocator. Note that we have to disable a couple `DEVELOPER` options to build mimalloc's source code, as it makes heavy use of declarations after statements, among other things that disagree with Git's conventions. We even have to silence some GCC warnings in non-DEVELOPER mode. For example, the `-Wno-array-bounds` flag is needed because in `-O2` builds, trying to call `NtCurrentTeb()` (which `_mi_thread_id()` does on Windows) causes the bogus warning about a system header, likely related to https://sourceforge.net/p/mingw-w64/mailman/message/37674519/ and to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578: C:/git-sdk-64-minimal/mingw64/include/psdk_inc/intrin-impl.h:838:1: error: array subscript 0 is outside array bounds of 'long long unsigned int[0]' [-Werror=array-bounds] 838 | __buildreadseg(__readgsqword, unsigned __int64, "gs", "q") | ^~~~~~~~~~~~~~ Also: The `mimalloc` library uses C11-style atomics, therefore we must require that standard when compiling with GCC if we want to use `mimalloc` (instead of requiring "only" C99). This is what we do in the CMake definition already, therefore this commit does not need to touch `contrib/buildsystems/`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7052e78 commit e7d4c50

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -2075,15 +2075,17 @@ ifdef USE_MIMALLOC
20752075

20762076
$(MIMALLOC_OBJS): COMPAT_CFLAGS += -DBANNED_H
20772077

2078-
ifdef DEVELOPER
20792078
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
20802079
-Wno-attributes \
2081-
-Wno-pedantic \
20822080
-Wno-unknown-pragmas \
2081+
-Wno-array-bounds
2082+
2083+
ifdef DEVELOPER
2084+
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
2085+
-Wno-pedantic \
20832086
-Wno-declaration-after-statement \
20842087
-Wno-old-style-definition \
2085-
-Wno-missing-prototypes \
2086-
-Wno-array-bounds
2088+
-Wno-missing-prototypes
20872089
endif
20882090
endif
20892091

0 commit comments

Comments
 (0)