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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2022-12-21 14:07:30 +01:00
parent 7052e78c41
commit e7d4c50480

View File

@@ -2075,15 +2075,17 @@ ifdef USE_MIMALLOC
$(MIMALLOC_OBJS): COMPAT_CFLAGS += -DBANNED_H
ifdef DEVELOPER
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
-Wno-attributes \
-Wno-pedantic \
-Wno-unknown-pragmas \
-Wno-array-bounds
ifdef DEVELOPER
$(MIMALLOC_OBJS): COMPAT_CFLAGS += \
-Wno-pedantic \
-Wno-declaration-after-statement \
-Wno-old-style-definition \
-Wno-missing-prototypes \
-Wno-array-bounds
-Wno-missing-prototypes
endif
endif