Skip to content

Commit e0e7d91

Browse files
committed
Add support for CLANGARM64 target (#3916)
**This requires an ARM64-machine with Windows 11 installed (which supports x64 emulation for MSYS2)** ### The main idea - Use the main MSYS2/git-sdk-64 setup, which works on Windows 11 on ARM thanks to x64-emulation - Configure the official `clangarm64` MSYS2 repo - Install `mingw-w64-clang-aarch64-toolchain` which contains the ARM64-native Clang compiler
2 parents 29cb626 + c1cc10c commit e0e7d91

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CLANG build ARM64
2+
3+
on:
4+
workflow_dispatch:
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
clang-build:
12+
runs-on: [Windows, ARM64]
13+
env:
14+
NO_PERL: 1
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: git-for-windows/setup-git-for-windows-sdk@v1
18+
with:
19+
flavor: makepkg-git
20+
architecture: aarch64
21+
# This assumes that the job is running on a self-hosted runner,
22+
# in which case we need to cleanup SDK files.
23+
cleanup: true
24+
- name: Build Git CLANGARM64
25+
run: make -j`nproc`

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ else
711711
prefix = /mingw64
712712
HOST_CPU = x86_64
713713
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
714+
else ifeq (CLANGARM64,$(MSYSTEM))
715+
prefix = /clangarm64
716+
HOST_CPU = aarch64
717+
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
714718
else
715719
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
716720
BASIC_LDFLAGS += -Wl,--large-address-aware

0 commit comments

Comments
 (0)