Skip to content

Commit df5218b

Browse files
dschogitster
authored andcommitted
config.mak.uname: support MSys2
For a long time, Git for Windows lagged behind Git's 2.x releases because the Git for Windows developers wanted to let that big jump coincide with a well-needed jump away from MSys to MSys2. To understand why this is such a big issue, it needs to be noted that many parts of Git are not written in portable C, but instead Git relies on a POSIX shell and Perl to be available. To support the scripts, Git for Windows has to ship a minimal POSIX emulation layer with Bash and Perl thrown in, and when the Git for Windows effort started in August 2007, this developer settled on using MSys, a stripped down version of Cygwin. Consequently, the original name of the project was "msysGit" (which, sadly, caused a *lot* of confusion because few Windows users know about MSys, and even less care). To compile the C code of Git for Windows, MSys was used, too: it sports two versions of the GNU C Compiler: one that links implicitly to the POSIX emulation layer, and another one that targets the plain Win32 API (with a few convenience functions thrown in). Git for Windows' executables are built using the latter, and therefore they are really just Win32 programs. To discern executables requiring the POSIX emulation layer from the ones that do not, the latter are called MinGW (Minimal GNU for Windows) when the former are called MSys executables. This reliance on MSys incurred challenges, too, though: some of our changes to the MSys runtime -- necessary to support Git for Windows better -- were not accepted upstream, so we had to maintain our own fork. Also, the MSys runtime was not developed further to support e.g. UTF-8 or 64-bit, and apart from lacking a package management system until much later (when mingw-get was introduced), many packages provided by the MSys/MinGW project lag behind the respective source code versions, in particular Bash and OpenSSL. For a while, the Git for Windows project tried to remedy the situation by trying to build newer versions of those packages, but the situation quickly became untenable, especially with problems like the Heartbleed bug requiring swift action that has nothing to do with developing Git for Windows further. Happily, in the meantime the MSys2 project (https://msys2.github.io/) emerged, and was chosen to be the base of the Git for Windows 2.x. Just like MSys, MSys2 is a stripped down version of Cygwin, but it is actively kept up-to-date with Cygwin's source code. Thereby, it already supports Unicode internally, and it also offers the 64-bit support that we yearned for since the beginning of the Git for Windows project. MSys2 also ported the Pacman package management system from Arch Linux and uses it heavily. This brings the same convenience to which Linux users are used to from `yum` or `apt-get`, and to which MacOSX users are used to from Homebrew or MacPorts, or BSD users from the Ports system, to MSys2: a simple `pacman -Syu` will update all installed packages to the newest versions currently available. MSys2 is also *very* active, typically providing package updates multiple times per week. It still required a two-month effort to bring everything to a state where Git's test suite passes, many more months until the first official Git for Windows 2.x was released, and a couple of patches still await their submission to the respective upstream projects. Yet without MSys2, the modernization of Git for Windows would simply not have happened. This commit lays the ground work to supporting MSys2-based Git builds. Assisted-by: Waldek Maleska <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7548842 commit df5218b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

config.mak.uname

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
518518
NO_INET_NTOP = YesPlease
519519
NO_POSIX_GOODIES = UnfortunatelyYes
520520
DEFAULT_HELP_FORMAT = html
521-
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
521+
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
522522
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
523523
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
524524
compat/win32/pthread.o compat/win32/syslog.o \
@@ -541,8 +541,25 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
541541
INTERNAL_QSORT = YesPlease
542542
HAVE_LIBCHARSET_H = YesPlease
543543
NO_GETTEXT = YesPlease
544+
COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
544545
else
545-
NO_CURL = YesPlease
546+
ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
547+
# MSys2
548+
CC = gcc
549+
prefix = /mingw32
550+
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
551+
INSTALL = /bin/install
552+
NO_R_TO_GCC_LINKER = YesPlease
553+
INTERNAL_QSORT = YesPlease
554+
HAVE_LIBCHARSET_H = YesPlease
555+
NO_GETTEXT = YesPlease
556+
USE_LIBPCRE= YesPlease
557+
NO_CURL =
558+
USE_NED_ALLOCATOR = YesPlease
559+
else
560+
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
561+
NO_CURL = YesPlease
562+
endif
546563
endif
547564
endif
548565
ifeq ($(uname_S),QNX)

0 commit comments

Comments
 (0)