Git development
 help / color / mirror / Atom feed
* [PATCH] mingw: stop using nedmalloc
@ 2026-05-03 12:29 Johannes Schindelin via GitGitGadget
  2026-05-05  6:09 ` Patrick Steinhardt
  2026-05-07 16:00 ` [PATCH v2 0/6] " Johannes Schindelin via GitGitGadget
  0 siblings, 2 replies; 20+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-05-03 12:29 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The vendored nedmalloc allocator under compat/nedmalloc/ has been
unmaintained upstream for a very long time: the original repository at
https://github.com/ned14/nedmalloc received its last commit on July 5,
2014, and was archived (made read-only) by its owner on March 15, 2019.
Our copy has been carried forward unchanged ever since.

The Git for Windows commit that introduced mimalloc as a replacement
on Windows ("mingw: use mimalloc", 2019-06-24, present in the Git for
Windows branch thicket but not upstream) already observed at that time
that nedmalloc had ceased to see any updates for several years.

This came to a head when the Git for Windows SDK upgraded to GCC 16:
the `add_segment()` function in `compat/nedmalloc/malloc.c.h` declares
`int nfences = 0` and only references it inside an `assert()`, which
GCC 16 now flags as `-Wunused-but-set-variable`. Combined with the
`-Werror` enabled by `DEVELOPER=1`, this turns into a hard build
failure:

	compat/nedmalloc/malloc.c.h: In function 'add_segment':
	compat/nedmalloc/malloc.c.h:3897:7: error: variable 'nfences' set but not used [-Werror=unused-but-set-variable=]
	 3897 |   int nfences = 0;
	      |       ^~~~~~~
	cc1.exe: all warnings being treated as errors

The same source built without complaint under GCC 15.2.0; the
regression was bisected to the SDK package update at
https://github.com/git-for-windows/git-sdk-64/commit/188d93dd455
(`mingw-w64-x86_64-gcc 15.2.0-14 -> 16.1.0-1`), with the failing CI
run captured at
https://github.com/git-for-windows/git-sdk-64/actions/runs/25244795074.

Rather than patch the unmaintained vendored sources to silence the
warning, stop opting into nedmalloc altogether on MINGW. The platform
allocator is what every non-MINGW build already uses, and a fresh
build of git.git's master against a minimal Git for Windows SDK
upgraded to GCC 16, with `USE_NED_ALLOCATOR` removed from the MINGW
section, completes successfully.

The compat/nedmalloc/ subtree itself is left in place to keep this
change minimal; nothing in the build links against it any longer, so
it can be removed in a follow-up if desired.

Assisted-by: Claude Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    mingw: stop using nedmalloc
    
    Git for Windows' SDK wants to update GCC to v16. Since it is used in the
    CI builds also of the git/git repository, it is crucial that GCC can
    compile even the latter all right, but currently it does not, see
    https://github.com/git-for-windows/git-sdk-64/actions/runs/25244795074.
    
    Git for Windows switched away from nedmalloc to mimalloc a long time
    ago, anyway. I plan on upstreaming this soon-ish, after this here patch
    lands.
    
    Note that with this patch, I reverse the order I indicated in
    https://lore.kernel.org/git/00fd3145-b3d2-ddab-466d-d06fd27298ec@gmx.de/:
    I first disable nedmalloc for MINGW builds (and possibly drop the
    vendored-in nedmalloc from Git's source code). The reason is that I am
    still trying to figure out the best way to integrate mimalloc:
    https://github.com/git-for-windows/git/commit/d67535b61dd (Import the
    source code of mimalloc v2.2.7, 2026-01-16) in patch form would weigh
    some ~700kB, which would not only be rejected by the Git mailing list,
    but which I myself would reject if I was the Git maintainer merely on
    the basis of the sheer size of the patch. Probably the best course of
    action is to add support for a non-vendored-in mimalloc first, then keep
    the vendored-in copy in Git for Windows (where no mailing list stands in
    the way of large patches). Whatever it will be, it's best to fast-track
    this here patch to disable nedmalloc for Windows builds, so that the CI
    builds can switch to using GCC 16 (and the current Git for Windows SDK)
    on Windows.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2104%2Fdscho%2Fstop-using-nedmalloc-with-mingw-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2104/dscho/stop-using-nedmalloc-with-mingw-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2104

 config.mak.uname | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index 5feb582558..3636b98238 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -758,9 +758,6 @@ ifeq ($(uname_S),MINGW)
 	HAVE_LIBCHARSET_H = YesPlease
 	USE_GETTEXT_SCHEME = fallthrough
 	USE_LIBPCRE = YesPlease
-        ifneq (CLANGARM64,$(MSYSTEM))
-		USE_NED_ALLOCATOR = YesPlease
-        endif
         ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
 		# Move system config into top-level /etc/
 		ETC_GITCONFIG = ../etc/gitconfig

base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-05-10  2:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 12:29 [PATCH] mingw: stop using nedmalloc Johannes Schindelin via GitGitGadget
2026-05-05  6:09 ` Patrick Steinhardt
2026-05-07 16:00 ` [PATCH v2 0/6] " Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 1/6] " Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 2/6] mingw: drop the build-system plumbing for nedmalloc Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 3/6] mingw: drop the small nedmalloc auxiliary files Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 4/6] mingw: drop the first chunk of compat/nedmalloc/malloc.c.h Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 5/6] mingw: drop the second " Johannes Schindelin via GitGitGadget
2026-05-07 16:00   ` [PATCH v2 6/6] mingw: drop the rest " Johannes Schindelin via GitGitGadget
2026-05-08  2:56   ` [PATCH v2 0/6] mingw: stop using nedmalloc Junio C Hamano
2026-05-08 14:15     ` Jeff King
2026-05-08 12:50   ` [PATCH v3 " Johannes Schindelin via GitGitGadget
2026-05-08 12:50     ` [PATCH v3 1/6] " Johannes Schindelin via GitGitGadget
2026-05-08 12:50     ` [PATCH v3 2/6] mingw: drop the build-system plumbing for nedmalloc Johannes Schindelin via GitGitGadget
2026-05-08 12:50     ` [PATCH v3 3/6] mingw: remove the vendored compat/nedmalloc/ subtree Johannes Schindelin via GitGitGadget
2026-05-08 12:50     ` [PATCH v3 4/6] to be squashed into 3/6 (chunk 1 of 3) Johannes Schindelin via GitGitGadget
2026-05-08 12:51     ` [PATCH v3 5/6] to be squashed into 3/6 (chunk 2 " Johannes Schindelin via GitGitGadget
2026-05-08 12:51     ` [PATCH v3 6/6] to be squashed into 3/6 (chunk 3 " Johannes Schindelin via GitGitGadget
2026-05-08 13:17     ` [PATCH v3 0/6] mingw: stop using nedmalloc Patrick Steinhardt
2026-05-10  2:31     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox