Skip to content

Commit c6ce1b9

Browse files
committed
mingw: fix CPU reporting in git version --build-options
We cannot rely on `uname -m` in Git for Windows' SDK to tell us what architecture we are compiling for, as we can compile both 32-bit and 64-bit `git.exe` from a 64-bit SDK, but the `uname -m` in that SDK will always report `x86_64`. So let's go back to our original design. And make it explicitly Windows-specific. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent eca28c6 commit c6ce1b9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

compat/mingw.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ typedef _sigset_t sigset_t;
66
#include <winsock2.h>
77
#include <ws2tcpip.h>
88

9+
#ifdef __MINGW64_VERSION_MAJOR
10+
/*
11+
* In Git for Windows, we cannot rely on `uname -m` to report the correct
12+
* architecture: /usr/bin/uname.exe will report the architecture with which the
13+
* current MSYS2 runtime was built, not the architecture for which we are
14+
* currently compiling (both 32-bit and 64-bit `git.exe` is built in the 64-bit
15+
* Git for Windows SDK).
16+
*/
17+
#undef GIT_HOST_CPU
18+
/* This was figured out by looking at `cpp -dM </dev/null`'s output */
19+
#if defined(__x86_64__)
20+
#define GIT_HOST_CPU "x86_64"
21+
#elif defined(__i686__)
22+
#define GIT_HOST_CPU "i686"
23+
#else
24+
#error "Unknown architecture"
25+
#endif
26+
#endif
27+
928
/* MinGW-w64 reports to have flockfile, but it does not actually have it. */
1029
#ifdef __MINGW64_VERSION_MAJOR
1130
#undef _POSIX_THREAD_SAFE_FUNCTIONS

0 commit comments

Comments
 (0)