Skip to content

Commit b50795d

Browse files
committed
Merge branch 'js/windows-arm64'
Update to arm64 Windows port. * js/windows-arm64: max_tree_depth: lower it for clangarm64 on Windows mingw(arm64): do move the `/etc/git*` location msvc: do handle builds on Windows/ARM64 mingw: do not use nedmalloc on Windows/ARM64 config.mak.uname: add support for clangarm64 bswap.h: add support for built-in bswap functions
2 parents 6c0bd1f + 436a422 commit b50795d

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

compat/bswap.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ static inline uint64_t default_bswap64(uint64_t val)
3535
#undef bswap32
3636
#undef bswap64
3737

38-
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
38+
/**
39+
* __has_builtin is available since Clang 10 and GCC 10.
40+
* Below is a fallback for older compilers.
41+
*/
42+
#ifndef __has_builtin
43+
#define __has_builtin(x) 0
44+
#endif
45+
46+
#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)
47+
#define bswap32(x) __builtin_bswap32((x))
48+
#define bswap64(x) __builtin_bswap64((x))
49+
50+
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
3951

4052
#define bswap32 git_bswap32
4153
static inline uint32_t git_bswap32(uint32_t x)

config.mak.uname

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,11 @@ ifeq ($(uname_S),Windows)
439439
ifeq (MINGW32,$(MSYSTEM))
440440
prefix = /mingw32
441441
else
442-
prefix = /mingw64
442+
ifeq (CLANGARM64,$(MSYSTEM))
443+
prefix = /clangarm64
444+
else
445+
prefix = /mingw64
446+
endif
443447
endif
444448
# Prepend MSVC 64-bit tool-chain to PATH.
445449
#
@@ -492,7 +496,7 @@ ifeq ($(uname_S),Windows)
492496
NO_POSIX_GOODIES = UnfortunatelyYes
493497
NATIVE_CRLF = YesPlease
494498
DEFAULT_HELP_FORMAT = html
495-
ifeq (/mingw64,$(subst 32,64,$(prefix)))
499+
ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
496500
# Move system config into top-level /etc/
497501
ETC_GITCONFIG = ../etc/gitconfig
498502
ETC_GITATTRIBUTES = ../etc/gitattributes
@@ -731,6 +735,10 @@ ifeq ($(uname_S),MINGW)
731735
prefix = /mingw64
732736
HOST_CPU = x86_64
733737
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
738+
else ifeq (CLANGARM64,$(MSYSTEM))
739+
prefix = /clangarm64
740+
HOST_CPU = aarch64
741+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
734742
else
735743
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
736744
BASIC_LDFLAGS += -Wl,--large-address-aware
@@ -745,8 +753,10 @@ ifeq ($(uname_S),MINGW)
745753
HAVE_LIBCHARSET_H = YesPlease
746754
USE_GETTEXT_SCHEME = fallthrough
747755
USE_LIBPCRE = YesPlease
748-
USE_NED_ALLOCATOR = YesPlease
749-
ifeq (/mingw64,$(subst 32,64,$(prefix)))
756+
ifneq (CLANGARM64,$(MSYSTEM))
757+
USE_NED_ALLOCATOR = YesPlease
758+
endif
759+
ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
750760
# Move system config into top-level /etc/
751761
ETC_GITCONFIG = ../etc/gitconfig
752762
ETC_GITATTRIBUTES = ../etc/gitattributes

environment.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ int max_allowed_tree_depth =
8181
* the stack overflow can occur.
8282
*/
8383
512;
84+
#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
85+
/*
86+
* Similar to Visual C, it seems that on Windows/ARM64 the clang-based
87+
* builds have a smaller stack space available. When running out of
88+
* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
89+
* Git command was run from an MSYS2 Bash, this unfortunately results
90+
* in an exit code 127. Let's prevent that by lowering the maximal
91+
* tree depth; This value seems to be low enough.
92+
*/
93+
1280;
8494
#else
8595
2048;
8696
#endif

0 commit comments

Comments
 (0)