From 87ce6a064bc2a8df6d5fff26f09219420e03ab23 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 08:37:13 +0000 Subject: [PATCH 1/8] fixup! mingw: add a cache below mingw's lstat and dirent implementations Clang has newly developed an antipathy for unions and arrays of structs that contain flex arrays... Let's just pat clang's head and move on. Signed-off-by: Johannes Schindelin --- compat/win32/fscache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index 7f6214cc0a92e2..eb13ce35a58b6e 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -78,12 +78,15 @@ struct fsentry { }; #pragma GCC diagnostic pop +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wflexible-array-extensions" struct heap_fsentry { union { struct fsentry ent; char dummy[sizeof(struct fsentry) + MAX_LONG_PATH]; } u; }; +#pragma GCC diagnostic pop /* * Compares the paths of two fsentry structures for equality. @@ -596,7 +599,10 @@ void fscache_flush(void) int fscache_lstat(const char *filename, struct stat *st) { int dirlen, base, len; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wflexible-array-extensions" struct heap_fsentry key[2]; +#pragma GCC diagnostic pop struct fsentry *fse; struct fscache *cache = fscache_getcache(); From 46fe8c94075bd98d637be8777209edfcac8566b5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 10:07:51 +0000 Subject: [PATCH 2/8] fixup! fscache: implement an FSCache-aware is_mount_point() This is needed because clang now complains about arrays of structs that contain flex array members. Signed-off-by: Johannes Schindelin --- compat/win32/fscache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index eb13ce35a58b6e..74517691e8a9a1 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -665,7 +665,10 @@ int fscache_lstat(const char *filename, struct stat *st) int fscache_is_mount_point(struct strbuf *path) { int dirlen, base, len; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wflexible-array-extensions" struct heap_fsentry key[2]; +#pragma GCC diagnostic pop struct fsentry *fse; struct fscache *cache = fscache_getcache(); From 0c5dcab4496ebdc37dc0f46e707c86888151ce17 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 10:17:12 +0000 Subject: [PATCH 3/8] msvc: do handle builds on Windows/ARM64 Git for Windows/ARM64 settled on using `clang` to compile `git.exe`, and hence needs to run in a system where `MSYSTEM` is set to `CLANGARM64` and the prefix to use is `/clangarm64`. We already did that in the `MINGW` arm, i.e. for regular Git for Windows builds using MINGW GCC (or `clang`'s shim pretending to be GCC), now it is time to do the same in the MS Visual C part. Signed-off-by: Johannes Schindelin --- config.mak.uname | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index c1355eff9d6bd8..a16a447ad70639 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -432,7 +432,11 @@ ifeq ($(uname_S),Windows) ifeq (MINGW32,$(MSYSTEM)) prefix = /mingw32 else - prefix = /mingw64 + ifeq (CLANGARM64,$(MSYSTEM)) + prefix = /clangarm64 + else + prefix = /mingw64 + endif endif # Prepend MSVC 64-bit tool-chain to PATH. # From 8c928879e35a328bf9bd79a52e3e6401fb0b1ba9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 10:21:52 +0000 Subject: [PATCH 4/8] mingw(arm64): do move the `/etc/git*` location In fb5e3378f8 (mingw: move Git for Windows' system config where users expect it, 2021-06-22), I moved the location of Git for Windows' system config and system Git attributes file to the top-level `/etc/` directory (because it is a much more obvious location than, say, `/mingw64/etc/`). The patch relied on a very specific scenario that the newly-supported Windows/ARM64 builds of `git.exe` fails to fall into. So let's broaden the condition a bit, so that Windows/ARM64 builds also use that location (instead of the even more obscure `/clangarm64/etc/` directory). This fixes https://github.com/git-for-windows/git/issues/5431. Signed-off-by: Johannes Schindelin --- config.mak.uname | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index a16a447ad70639..563e0db23368d6 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -490,7 +490,7 @@ ifeq ($(uname_S),Windows) NATIVE_CRLF = YesPlease DEFAULT_HELP_FORMAT = html SKIP_DASHED_BUILT_INS = YabbaDabbaDoo -ifeq (/mingw64,$(subst 32,64,$(prefix))) +ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) # Move system config into top-level /etc/ ETC_GITCONFIG = ../etc/gitconfig ETC_GITATTRIBUTES = ../etc/gitattributes @@ -753,7 +753,7 @@ ifeq ($(uname_S),MINGW) USE_LIBPCRE = YesPlease USE_MIMALLOC = YesPlease NO_PYTHON = - ifeq (/mingw64,$(subst 32,64,$(prefix))) + ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) # Move system config into top-level /etc/ ETC_GITCONFIG = ../etc/gitconfig ETC_GITATTRIBUTES = ../etc/gitattributes From e2874e2aeb6d72db3dbf557bc1ff290b3c59cf56 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 10:26:18 +0000 Subject: [PATCH 5/8] fixup! config.mak.uname: add support for clangarm64 This commit introduced an `else ifeq` pattern that is arguably more elegant than the previous pattern, so let's adjust the existing conditional block, too. Signed-off-by: Johannes Schindelin --- config.mak.uname | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index 563e0db23368d6..c634f28c0bc6a5 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -728,8 +728,7 @@ ifeq ($(uname_S),MINGW) prefix = /mingw32 HOST_CPU = i686 BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup - endif - ifeq (MINGW64,$(MSYSTEM)) + else ifeq (MINGW64,$(MSYSTEM)) prefix = /mingw64 HOST_CPU = x86_64 BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup From d5953d8d4521a08b821c57157a39536d8cc19853 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 10:37:27 +0000 Subject: [PATCH 6/8] fixup! mingw: add a Makefile target to copy test artifacts This makes the code a bit less fragile by being less dependent on multiple adjustments for any new `MSYSTEM` value. Signed-off-by: Johannes Schindelin --- config.mak.uname | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index c634f28c0bc6a5..c161ddeeeade94 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -757,12 +757,7 @@ ifeq ($(uname_S),MINGW) ETC_GITCONFIG = ../etc/gitconfig ETC_GITATTRIBUTES = ../etc/gitattributes endif -ifeq (i686,$(uname_M)) - MINGW_PREFIX := mingw32 -endif -ifeq (x86_64,$(uname_M)) - MINGW_PREFIX := mingw64 -endif + MINGW_PREFIX := $(subst /,,$(prefix)) DESTDIR_WINDOWS = $(shell cygpath -aw '$(DESTDIR_SQ)') DESTDIR_MIXED = $(shell cygpath -am '$(DESTDIR_SQ)') From 56c4f543d02f369fd93b99d2ef6eefbaf26c030e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 11:37:08 +0000 Subject: [PATCH 7/8] fixup! 87ce6a064bc2a8df6d5fff26f09219420e03ab23 This needs to be guarded against GCC complaining that it does not know this option... _sigh_ Signed-off-by: Johannes Schindelin --- compat/win32/fscache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index 74517691e8a9a1..589d9c81315f42 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -79,7 +79,9 @@ struct fsentry { #pragma GCC diagnostic pop #pragma GCC diagnostic push +#ifdef __clang__ #pragma GCC diagnostic ignored "-Wflexible-array-extensions" +#endif struct heap_fsentry { union { struct fsentry ent; @@ -600,7 +602,9 @@ int fscache_lstat(const char *filename, struct stat *st) { int dirlen, base, len; #pragma GCC diagnostic push +#ifdef __clang__ #pragma GCC diagnostic ignored "-Wflexible-array-extensions" +#endif struct heap_fsentry key[2]; #pragma GCC diagnostic pop struct fsentry *fse; From d16eadf7d1e6f631a0039f23a73b6ce2e2478d4a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 25 Feb 2025 11:37:08 +0000 Subject: [PATCH 8/8] fixup! 46fe8c94075bd98d637be8777209edfcac8566b5 This needs to be guarded against GCC complaining that it does not know this option... _sigh_ Signed-off-by: Johannes Schindelin --- compat/win32/fscache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index 589d9c81315f42..cbd90ececf6b37 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -670,7 +670,9 @@ int fscache_is_mount_point(struct strbuf *path) { int dirlen, base, len; #pragma GCC diagnostic push +#ifdef __clang__ #pragma GCC diagnostic ignored "-Wflexible-array-extensions" +#endif struct heap_fsentry key[2]; #pragma GCC diagnostic pop struct fsentry *fse;