git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Fix compile errors with MSys2
@ 2016-01-13 13:30 Johannes Schindelin
  2016-01-13 13:30 ` [PATCH 1/5] config.mak.uname: support MSys2 Johannes Schindelin
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Git for Windows 2.x is based on MSys2, and its first official version
was released already almost half a year ago, yet it is still impossible
even to compile Git from the official, platform-independent Git source
code.

This patch series merely fixes the compile errors, and will be followed
by other patch series that fix the compile warnings and test failures.
The idea is to move all Windows-specific patches of Git for Windows'
fork to upstream Git proper.


Johannes Schindelin (5):
  config.mak.uname: support MSys2
  config.mak.uname: supporting 64-bit MSys2
  nedmalloc: allow compiling with MSys2's compiler
  compat/mingw: support MSys2-based MinGW build
  compat/winansi: support compiling with MSys2

 compat/mingw.h              | 24 +++++++++++++++++++++++-
 compat/nedmalloc/malloc.c.h |  6 ++++++
 compat/winansi.c            |  2 ++
 config.mak.uname            | 31 ++++++++++++++++++++++++++++---
 4 files changed, 59 insertions(+), 4 deletions(-)

-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/5] config.mak.uname: support MSys2
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
@ 2016-01-13 13:30 ` Johannes Schindelin
  2016-01-13 16:11   ` Jeff King
  2016-01-13 13:31 ` [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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 <weakcamel@users.github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index f34dcaa..b0592c1 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -518,7 +518,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_INET_NTOP = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
-	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
@@ -541,8 +541,25 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
 	INTERNAL_QSORT = YesPlease
 	HAVE_LIBCHARSET_H = YesPlease
 	NO_GETTEXT = YesPlease
+	COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
 else
-	NO_CURL = YesPlease
+	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
+		# MSys2
+		CC = gcc
+		prefix = /mingw32
+		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
+		INSTALL = /bin/install
+		NO_R_TO_GCC_LINKER = YesPlease
+		INTERNAL_QSORT = YesPlease
+		HAVE_LIBCHARSET_H = YesPlease
+		NO_GETTEXT = YesPlease
+		USE_LIBPCRE= YesPlease
+		NO_CURL =
+		USE_NED_ALLOCATOR = YesPlease
+	else
+		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
+		NO_CURL = YesPlease
+	endif
 endif
 endif
 ifeq ($(uname_S),QNX)
-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
  2016-01-13 13:30 ` [PATCH 1/5] config.mak.uname: support MSys2 Johannes Schindelin
@ 2016-01-13 13:31 ` Johannes Schindelin
  2016-01-21 10:36   ` SZEDER Gábor
  2016-01-13 13:31 ` [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

This just makes things compile, the test suite needs extra tender loving
care in addition to this change. We will address these issues in later
commits.

While at it, also allow building MSys2 Git (i.e. a Git that uses MSys2's
POSIX emulation layer).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index b0592c1..4b2e1b8 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -518,13 +518,12 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_INET_NTOP = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
-	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
 		compat/win32/dirent.o
 	BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
-	BASIC_LDFLAGS += -Wl,--large-address-aware
 	EXTLIBS += -lws2_32
 	GITLIBS += git.res
 	PTHREAD_LIBS =
@@ -545,8 +544,17 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
 else
 	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
 		# MSys2
+		prefix = /usr/
+		ifeq (MINGW32,$(MSYSTEM))
+			prefix = /mingw32
+		endif
+		ifeq (MINGW64,$(MSYSTEM))
+			prefix = /mingw64
+		else
+			COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
+			BASIC_LDFLAGS += -Wl,--large-address-aware
+		endif
 		CC = gcc
-		prefix = /mingw32
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease
-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
  2016-01-13 13:30 ` [PATCH 1/5] config.mak.uname: support MSys2 Johannes Schindelin
  2016-01-13 13:31 ` [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
@ 2016-01-13 13:31 ` Johannes Schindelin
  2016-01-13 19:28   ` Junio C Hamano
  2016-01-13 13:31 ` [PATCH 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

With MSys2's GCC, `ReadWriteBarrier` is already defined, and FORCEINLINE
unfortunately gets defined incorrectly.

Let's work around both problems, using the MSys2-specific
__MINGW64_VERSION_MAJOR constant to guard them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/nedmalloc/malloc.c.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
index f216a2a..18634e3 100644
--- a/compat/nedmalloc/malloc.c.h
+++ b/compat/nedmalloc/malloc.c.h
@@ -720,6 +720,9 @@ struct mallinfo {
   inlining are defined as macros, so these aren't used for them.
 */
 
+#ifdef __MINGW64_VERSION_MAJOR
+#undef FORCEINLINE
+#endif
 #ifndef FORCEINLINE
   #if defined(__GNUC__)
 #define FORCEINLINE __inline __attribute__ ((always_inline))
@@ -1382,6 +1385,9 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
 
   /*** Atomic operations ***/
   #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
+    #ifdef __MINGW64_VERSION_MAJOR
+      #undef _ReadWriteBarrier
+    #endif
     #define _ReadWriteBarrier() __sync_synchronize()
   #else
     static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)
-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/5] compat/mingw: support MSys2-based MinGW build
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
                   ` (2 preceding siblings ...)
  2016-01-13 13:31 ` [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
@ 2016-01-13 13:31 ` Johannes Schindelin
  2016-01-13 13:31 ` [PATCH 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

The excellent MSys2 project brings a substantially updated MinGW
environment including newer GCC versions and new headers. To support
compiling Git, let's special-case the new MinGW (tell-tale: the
_MINGW64_VERSION_MAJOR constant is defined).

Note: this commit only addresses compile failures, not compile warnings
(that task is left for a future patch).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.h | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/compat/mingw.h b/compat/mingw.h
index b3e5044..a2da783 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -1,14 +1,26 @@
+#ifdef __MINGW64_VERSION_MAJOR
+#include <stdint.h>
+#include <wchar.h>
+typedef _sigset_t sigset_t;
+#endif
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
+/* MinGW-w64 reports to have flockfile, but it does not actually have it. */
+#ifdef __MINGW64_VERSION_MAJOR
+#undef _POSIX_THREAD_SAFE_FUNCTIONS
+#endif
+
 /*
  * things that are not available in header files
  */
 
-typedef int pid_t;
 typedef int uid_t;
 typedef int socklen_t;
+#ifndef __MINGW64_VERSION_MAJOR
+typedef int pid_t;
 #define hstrerror strerror
+#endif
 
 #define S_IFLNK    0120000 /* Symbolic link */
 #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
@@ -100,8 +112,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
 { errno = ENOSYS; return -1; }
 static inline int fchmod(int fildes, mode_t mode)
 { errno = ENOSYS; return -1; }
+#ifndef __MINGW64_VERSION_MAJOR
 static inline pid_t fork(void)
 { errno = ENOSYS; return -1; }
+#endif
 static inline unsigned int alarm(unsigned int seconds)
 { return 0; }
 static inline int fsync(int fd)
@@ -176,8 +190,10 @@ int pipe(int filedes[2]);
 unsigned int sleep (unsigned int seconds);
 int mkstemp(char *template);
 int gettimeofday(struct timeval *tv, void *tz);
+#ifndef __MINGW64_VERSION_MAJOR
 struct tm *gmtime_r(const time_t *timep, struct tm *result);
 struct tm *localtime_r(const time_t *timep, struct tm *result);
+#endif
 int getpagesize(void);	/* defined in MinGW's libgcc.a */
 struct passwd *getpwuid(uid_t uid);
 int setitimer(int type, struct itimerval *in, struct itimerval *out);
@@ -301,8 +317,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
 /*
  * Use mingw specific stat()/lstat()/fstat() implementations on Windows.
  */
+#ifndef __MINGW64_VERSION_MAJOR
 #define off_t off64_t
 #define lseek _lseeki64
+#endif
 
 /* use struct stat with 64 bit st_size */
 #ifdef stat
@@ -383,8 +401,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
 int mingw_offset_1st_component(const char *path);
 #define offset_1st_component mingw_offset_1st_component
 #define PATH_SEP ';'
+#ifndef __MINGW64_VERSION_MAJOR
 #define PRIuMAX "I64u"
 #define PRId64 "I64d"
+#else
+#include <inttypes.h>
+#endif
 
 void mingw_open_html(const char *path);
 #define open_html mingw_open_html
-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/5] compat/winansi: support compiling with MSys2
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
                   ` (3 preceding siblings ...)
  2016-01-13 13:31 ` [PATCH 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
@ 2016-01-13 13:31 ` Johannes Schindelin
  2016-01-13 19:31 ` [PATCH 0/5] Fix compile errors " Junio C Hamano
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 13:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

MSys2 already defines the _CONSOLE_FONT_INFOEX structure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/winansi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/compat/winansi.c b/compat/winansi.c
index ceff55b..3aa5535 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -23,6 +23,7 @@ static HANDLE hthread, hread, hwrite;
 static HANDLE hconsole1, hconsole2;
 
 #ifdef __MINGW32__
+#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5
 typedef struct _CONSOLE_FONT_INFOEX {
 	ULONG cbSize;
 	DWORD nFont;
@@ -32,6 +33,7 @@ typedef struct _CONSOLE_FONT_INFOEX {
 	WCHAR FaceName[LF_FACESIZE];
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
 #endif
+#endif
 
 typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
 		PCONSOLE_FONT_INFOEX);
-- 
2.6.3.windows.1.300.g1c25e49

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/5] config.mak.uname: support MSys2
  2016-01-13 13:30 ` [PATCH 1/5] config.mak.uname: support MSys2 Johannes Schindelin
@ 2016-01-13 16:11   ` Jeff King
  2016-01-13 16:45     ` Johannes Schindelin
  2016-01-13 19:23     ` Dennis Kaarsemaker
  0 siblings, 2 replies; 23+ messages in thread
From: Jeff King @ 2016-01-13 16:11 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git

On Wed, Jan 13, 2016 at 02:30:53PM +0100, Johannes Schindelin wrote:

> 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.
> [...]

I can't say much about the patch itself, but I think this commit is
worth it for the message alone. Now I finally know the subtle
differences between all of those systems!

-Peff

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/5] config.mak.uname: support MSys2
  2016-01-13 16:11   ` Jeff King
@ 2016-01-13 16:45     ` Johannes Schindelin
  2016-01-13 19:23     ` Dennis Kaarsemaker
  1 sibling, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-13 16:45 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, git

Hi Peff,

On Wed, 13 Jan 2016, Jeff King wrote:

> On Wed, Jan 13, 2016 at 02:30:53PM +0100, Johannes Schindelin wrote:
> 
> > 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.
> > [...]
> 
> I can't say much about the patch itself, but I think this commit is
> worth it for the message alone. Now I finally know the subtle
> differences between all of those systems!

Thanks! I spent some quality time on reworking this particular commit
message this morning, so I am extra glad about your positive feedback!

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/5] config.mak.uname: support MSys2
  2016-01-13 16:11   ` Jeff King
  2016-01-13 16:45     ` Johannes Schindelin
@ 2016-01-13 19:23     ` Dennis Kaarsemaker
  1 sibling, 0 replies; 23+ messages in thread
From: Dennis Kaarsemaker @ 2016-01-13 19:23 UTC (permalink / raw)
  To: Jeff King, Johannes Schindelin; +Cc: Junio C Hamano, git

On wo, 2016-01-13 at 11:11 -0500, Jeff King wrote:
> On Wed, Jan 13, 2016 at 02:30:53PM +0100, Johannes Schindelin wrote:
> 
> > 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.
> > [...]
> 
> I can't say much about the patch itself, but I think this commit is
> worth it for the message alone. Now I finally know the subtle
> differences between all of those systems!

Agreed. It might even make sense to have that explanation somewhere in
Documentation/technical/

-- 
Dennis Kaarsemaker
www.kaarsemaker.net

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler
  2016-01-13 13:31 ` [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
@ 2016-01-13 19:28   ` Junio C Hamano
  0 siblings, 0 replies; 23+ messages in thread
From: Junio C Hamano @ 2016-01-13 19:28 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> With MSys2's GCC, `ReadWriteBarrier` is already defined, and FORCEINLINE
> unfortunately gets defined incorrectly.
>
> Let's work around both problems, using the MSys2-specific
> __MINGW64_VERSION_MAJOR constant to guard them.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---

Thanks.  I actually do not think #undef _ReadWriteBarrier needs to
be inside any #ifdef, though.  It isn't like it is an error to
#undef that you did not #define before.

>  compat/nedmalloc/malloc.c.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
> index f216a2a..18634e3 100644
> --- a/compat/nedmalloc/malloc.c.h
> +++ b/compat/nedmalloc/malloc.c.h
> @@ -720,6 +720,9 @@ struct mallinfo {
>    inlining are defined as macros, so these aren't used for them.
>  */
>  
> +#ifdef __MINGW64_VERSION_MAJOR
> +#undef FORCEINLINE
> +#endif
>  #ifndef FORCEINLINE
>    #if defined(__GNUC__)
>  #define FORCEINLINE __inline __attribute__ ((always_inline))
> @@ -1382,6 +1385,9 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
>  
>    /*** Atomic operations ***/
>    #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
> +    #ifdef __MINGW64_VERSION_MAJOR
> +      #undef _ReadWriteBarrier
> +    #endif
>      #define _ReadWriteBarrier() __sync_synchronize()
>    #else
>      static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/5] Fix compile errors with MSys2
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
                   ` (4 preceding siblings ...)
  2016-01-13 13:31 ` [PATCH 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
@ 2016-01-13 19:31 ` Junio C Hamano
  2016-01-14  6:53   ` Johannes Schindelin
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
  6 siblings, 1 reply; 23+ messages in thread
From: Junio C Hamano @ 2016-01-13 19:31 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

It would really be nice to see the endgame of what this series
starts sometime not in too distant a future.  Many users in Windows
land would appreciate this effort, I am sure.

Thanks, will queue.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/5] Fix compile errors with MSys2
  2016-01-13 19:31 ` [PATCH 0/5] Fix compile errors " Junio C Hamano
@ 2016-01-14  6:53   ` Johannes Schindelin
  0 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14  6:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi Junio,

On Wed, 13 Jan 2016, Junio C Hamano wrote:

> It would really be nice to see the endgame of what this series
> starts sometime not in too distant a future.

That is indeed the intention:

	https://github.com/git-for-windows/git/issues/285

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 0/5] Fix compile errors with MSys2
  2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
                   ` (5 preceding siblings ...)
  2016-01-13 19:31 ` [PATCH 0/5] Fix compile errors " Junio C Hamano
@ 2016-01-14 16:51 ` Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 1/5] config.mak.uname: support MSys2 Johannes Schindelin
                     ` (6 more replies)
  6 siblings, 7 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Git for Windows 2.x is based on MSys2, and its first official version
was released already almost half a year ago, yet it is still impossible
even to compile Git from the official, platform-independent Git source
code.

This patch series merely fixes the compile errors, and will be followed
by other patch series that fix the compile warnings and test failures.
The idea is to move all Windows-specific patches of Git for Windows'
fork to upstream Git proper.

Relative to v1, I only removed the guards about the "#undef
ReadWriteBarrier".

Johannes Schindelin (5):
  config.mak.uname: support MSys2
  config.mak.uname: supporting 64-bit MSys2
  nedmalloc: allow compiling with MSys2's compiler
  compat/mingw: support MSys2-based MinGW build
  compat/winansi: support compiling with MSys2

 compat/mingw.h              | 24 +++++++++++++++++++++++-
 compat/nedmalloc/malloc.c.h |  4 ++++
 compat/winansi.c            |  2 ++
 config.mak.uname            | 31 ++++++++++++++++++++++++++++---
 4 files changed, 57 insertions(+), 4 deletions(-)

Interdiff vs v1:

 diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
 index 18634e3..bf70037 100644
 --- a/compat/nedmalloc/malloc.c.h
 +++ b/compat/nedmalloc/malloc.c.h
 @@ -1385,9 +1385,7 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
  
    /*** Atomic operations ***/
    #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
 -    #ifdef __MINGW64_VERSION_MAJOR
 -      #undef _ReadWriteBarrier
 -    #endif
 +    #undef _ReadWriteBarrier
      #define _ReadWriteBarrier() __sync_synchronize()
    #else
      static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)

-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/5] config.mak.uname: support MSys2
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
@ 2016-01-14 16:51   ` Johannes Schindelin
  2016-01-14 21:45     ` Johannes Sixt
  2016-01-14 16:51   ` [PATCH v2 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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 <weakcamel@users.github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index f34dcaa..b0592c1 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -518,7 +518,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_INET_NTOP = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
-	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
@@ -541,8 +541,25 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
 	INTERNAL_QSORT = YesPlease
 	HAVE_LIBCHARSET_H = YesPlease
 	NO_GETTEXT = YesPlease
+	COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
 else
-	NO_CURL = YesPlease
+	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
+		# MSys2
+		CC = gcc
+		prefix = /mingw32
+		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
+		INSTALL = /bin/install
+		NO_R_TO_GCC_LINKER = YesPlease
+		INTERNAL_QSORT = YesPlease
+		HAVE_LIBCHARSET_H = YesPlease
+		NO_GETTEXT = YesPlease
+		USE_LIBPCRE= YesPlease
+		NO_CURL =
+		USE_NED_ALLOCATOR = YesPlease
+	else
+		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
+		NO_CURL = YesPlease
+	endif
 endif
 endif
 ifeq ($(uname_S),QNX)
-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/5] config.mak.uname: supporting 64-bit MSys2
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 1/5] config.mak.uname: support MSys2 Johannes Schindelin
@ 2016-01-14 16:51   ` Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

This just makes things compile, the test suite needs extra tender loving
care in addition to this change. We will address these issues in later
commits.

While at it, also allow building MSys2 Git (i.e. a Git that uses MSys2's
POSIX emulation layer).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index b0592c1..4b2e1b8 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -518,13 +518,12 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_INET_NTOP = YesPlease
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	DEFAULT_HELP_FORMAT = html
-	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
+	COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
 		compat/win32/pthread.o compat/win32/syslog.o \
 		compat/win32/dirent.o
 	BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
-	BASIC_LDFLAGS += -Wl,--large-address-aware
 	EXTLIBS += -lws2_32
 	GITLIBS += git.res
 	PTHREAD_LIBS =
@@ -545,8 +544,17 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
 else
 	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
 		# MSys2
+		prefix = /usr/
+		ifeq (MINGW32,$(MSYSTEM))
+			prefix = /mingw32
+		endif
+		ifeq (MINGW64,$(MSYSTEM))
+			prefix = /mingw64
+		else
+			COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
+			BASIC_LDFLAGS += -Wl,--large-address-aware
+		endif
 		CC = gcc
-		prefix = /mingw32
 		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
 		INSTALL = /bin/install
 		NO_R_TO_GCC_LINKER = YesPlease
-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/5] nedmalloc: allow compiling with MSys2's compiler
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 1/5] config.mak.uname: support MSys2 Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
@ 2016-01-14 16:51   ` Johannes Schindelin
  2016-01-14 16:51   ` [PATCH v2 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

With MSys2's GCC, `ReadWriteBarrier` is already defined, and FORCEINLINE
unfortunately gets defined incorrectly.

Let's work around both problems, using the MSys2-specific
__MINGW64_VERSION_MAJOR constant to guard the FORCEINLINE definition so
as not to affect other platforms.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/nedmalloc/malloc.c.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
index f216a2a..bf70037 100644
--- a/compat/nedmalloc/malloc.c.h
+++ b/compat/nedmalloc/malloc.c.h
@@ -720,6 +720,9 @@ struct mallinfo {
   inlining are defined as macros, so these aren't used for them.
 */
 
+#ifdef __MINGW64_VERSION_MAJOR
+#undef FORCEINLINE
+#endif
 #ifndef FORCEINLINE
   #if defined(__GNUC__)
 #define FORCEINLINE __inline __attribute__ ((always_inline))
@@ -1382,6 +1385,7 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
 
   /*** Atomic operations ***/
   #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
+    #undef _ReadWriteBarrier
     #define _ReadWriteBarrier() __sync_synchronize()
   #else
     static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)
-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 4/5] compat/mingw: support MSys2-based MinGW build
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
                     ` (2 preceding siblings ...)
  2016-01-14 16:51   ` [PATCH v2 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
@ 2016-01-14 16:51   ` Johannes Schindelin
  2016-01-14 16:52   ` [PATCH v2 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

The excellent MSys2 project brings a substantially updated MinGW
environment including newer GCC versions and new headers. To support
compiling Git, let's special-case the new MinGW (tell-tale: the
_MINGW64_VERSION_MAJOR constant is defined).

Note: this commit only addresses compile failures, not compile warnings
(that task is left for a future patch).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.h | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/compat/mingw.h b/compat/mingw.h
index b3e5044..a2da783 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -1,14 +1,26 @@
+#ifdef __MINGW64_VERSION_MAJOR
+#include <stdint.h>
+#include <wchar.h>
+typedef _sigset_t sigset_t;
+#endif
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
+/* MinGW-w64 reports to have flockfile, but it does not actually have it. */
+#ifdef __MINGW64_VERSION_MAJOR
+#undef _POSIX_THREAD_SAFE_FUNCTIONS
+#endif
+
 /*
  * things that are not available in header files
  */
 
-typedef int pid_t;
 typedef int uid_t;
 typedef int socklen_t;
+#ifndef __MINGW64_VERSION_MAJOR
+typedef int pid_t;
 #define hstrerror strerror
+#endif
 
 #define S_IFLNK    0120000 /* Symbolic link */
 #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
@@ -100,8 +112,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
 { errno = ENOSYS; return -1; }
 static inline int fchmod(int fildes, mode_t mode)
 { errno = ENOSYS; return -1; }
+#ifndef __MINGW64_VERSION_MAJOR
 static inline pid_t fork(void)
 { errno = ENOSYS; return -1; }
+#endif
 static inline unsigned int alarm(unsigned int seconds)
 { return 0; }
 static inline int fsync(int fd)
@@ -176,8 +190,10 @@ int pipe(int filedes[2]);
 unsigned int sleep (unsigned int seconds);
 int mkstemp(char *template);
 int gettimeofday(struct timeval *tv, void *tz);
+#ifndef __MINGW64_VERSION_MAJOR
 struct tm *gmtime_r(const time_t *timep, struct tm *result);
 struct tm *localtime_r(const time_t *timep, struct tm *result);
+#endif
 int getpagesize(void);	/* defined in MinGW's libgcc.a */
 struct passwd *getpwuid(uid_t uid);
 int setitimer(int type, struct itimerval *in, struct itimerval *out);
@@ -301,8 +317,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
 /*
  * Use mingw specific stat()/lstat()/fstat() implementations on Windows.
  */
+#ifndef __MINGW64_VERSION_MAJOR
 #define off_t off64_t
 #define lseek _lseeki64
+#endif
 
 /* use struct stat with 64 bit st_size */
 #ifdef stat
@@ -383,8 +401,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
 int mingw_offset_1st_component(const char *path);
 #define offset_1st_component mingw_offset_1st_component
 #define PATH_SEP ';'
+#ifndef __MINGW64_VERSION_MAJOR
 #define PRIuMAX "I64u"
 #define PRId64 "I64d"
+#else
+#include <inttypes.h>
+#endif
 
 void mingw_open_html(const char *path);
 #define open_html mingw_open_html
-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 5/5] compat/winansi: support compiling with MSys2
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
                     ` (3 preceding siblings ...)
  2016-01-14 16:51   ` [PATCH v2 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
@ 2016-01-14 16:52   ` Johannes Schindelin
  2016-01-14 20:21   ` [PATCH v2 0/5] Fix compile errors " Junio C Hamano
  2016-01-14 21:57   ` Johannes Sixt
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-14 16:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

MSys2 already defines the _CONSOLE_FONT_INFOEX structure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/winansi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/compat/winansi.c b/compat/winansi.c
index ceff55b..3aa5535 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -23,6 +23,7 @@ static HANDLE hthread, hread, hwrite;
 static HANDLE hconsole1, hconsole2;
 
 #ifdef __MINGW32__
+#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5
 typedef struct _CONSOLE_FONT_INFOEX {
 	ULONG cbSize;
 	DWORD nFont;
@@ -32,6 +33,7 @@ typedef struct _CONSOLE_FONT_INFOEX {
 	WCHAR FaceName[LF_FACESIZE];
 } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
 #endif
+#endif
 
 typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
 		PCONSOLE_FONT_INFOEX);
-- 
2.7.0.windows.1.7.g55a05c8

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/5] Fix compile errors with MSys2
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
                     ` (4 preceding siblings ...)
  2016-01-14 16:52   ` [PATCH v2 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
@ 2016-01-14 20:21   ` Junio C Hamano
  2016-01-14 21:57   ` Johannes Sixt
  6 siblings, 0 replies; 23+ messages in thread
From: Junio C Hamano @ 2016-01-14 20:21 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Thanks.  Let's see if there is anything else people discover in this
series and merge it to 'next'.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 1/5] config.mak.uname: support MSys2
  2016-01-14 16:51   ` [PATCH v2 1/5] config.mak.uname: support MSys2 Johannes Schindelin
@ 2016-01-14 21:45     ` Johannes Sixt
  0 siblings, 0 replies; 23+ messages in thread
From: Johannes Sixt @ 2016-01-14 21:45 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git

Am 14.01.2016 um 17:51 schrieb Johannes Schindelin:
> diff --git a/config.mak.uname b/config.mak.uname
> index f34dcaa..b0592c1 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -518,7 +518,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
>   	NO_INET_NTOP = YesPlease
>   	NO_POSIX_GOODIES = UnfortunatelyYes
>   	DEFAULT_HELP_FORMAT = html
> -	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
> +	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
>   	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
>   	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
>   		compat/win32/pthread.o compat/win32/syslog.o \
> @@ -541,8 +541,25 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
>   	INTERNAL_QSORT = YesPlease
>   	HAVE_LIBCHARSET_H = YesPlease
>   	NO_GETTEXT = YesPlease
> +	COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
>   else
> -	NO_CURL = YesPlease
> +	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
> +		# MSys2
> +		CC = gcc
> +		prefix = /mingw32

Hmm. Setting the prefix like this is certainly ideal for Git for Windows 
(the installer), but it is very uncommon to set the prefix in 
config.mak.uname.

> +		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
> +		INSTALL = /bin/install
> +		NO_R_TO_GCC_LINKER = YesPlease
> +		INTERNAL_QSORT = YesPlease
> +		HAVE_LIBCHARSET_H = YesPlease
> +		NO_GETTEXT = YesPlease
> +		USE_LIBPCRE= YesPlease
> +		NO_CURL =
> +		USE_NED_ALLOCATOR = YesPlease

USE_NED_ALLOCATOR is already set in the common section (line 510).

> +	else
> +		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO

Did you mean to set -D__USE_MINGW_ACCESS here? But, as I noticed, it 
doesn't make a whole lot of a difference; my build (which picks this 
branch, if I'm not mistaken) still passes the test suite.

> +		NO_CURL = YesPlease
> +	endif
>   endif
>   endif
>   ifeq ($(uname_S),QNX)
>

-- Hannes

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/5] Fix compile errors with MSys2
  2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
                     ` (5 preceding siblings ...)
  2016-01-14 20:21   ` [PATCH v2 0/5] Fix compile errors " Junio C Hamano
@ 2016-01-14 21:57   ` Johannes Sixt
  6 siblings, 0 replies; 23+ messages in thread
From: Johannes Sixt @ 2016-01-14 21:57 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git

Am 14.01.2016 um 17:51 schrieb Johannes Schindelin:
> Git for Windows 2.x is based on MSys2, and its first official version
> was released already almost half a year ago, yet it is still impossible
> even to compile Git from the official, platform-independent Git source
> code.
>
> This patch series merely fixes the compile errors, and will be followed
> by other patch series that fix the compile warnings and test failures.
> The idea is to move all Windows-specific patches of Git for Windows'
> fork to upstream Git proper.
>
> Relative to v1, I only removed the guards about the "#undef
> ReadWriteBarrier".
>
> Johannes Schindelin (5):
>    config.mak.uname: support MSys2
>    config.mak.uname: supporting 64-bit MSys2
>    nedmalloc: allow compiling with MSys2's compiler
>    compat/mingw: support MSys2-based MinGW build
>    compat/winansi: support compiling with MSys2
>
>   compat/mingw.h              | 24 +++++++++++++++++++++++-
>   compat/nedmalloc/malloc.c.h |  4 ++++
>   compat/winansi.c            |  2 ++
>   config.mak.uname            | 31 ++++++++++++++++++++++++++++---
>   4 files changed, 57 insertions(+), 4 deletions(-)
>
> Interdiff vs v1:
>
>   diff --git a/compat/nedmalloc/malloc.c.h b/compat/nedmalloc/malloc.c.h
>   index 18634e3..bf70037 100644
>   --- a/compat/nedmalloc/malloc.c.h
>   +++ b/compat/nedmalloc/malloc.c.h
>   @@ -1385,9 +1385,7 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
>
>      /*** Atomic operations ***/
>      #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
>   -    #ifdef __MINGW64_VERSION_MAJOR
>   -      #undef _ReadWriteBarrier
>   -    #endif
>   +    #undef _ReadWriteBarrier
>        #define _ReadWriteBarrier() __sync_synchronize()
>      #else
>        static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)
>

It is very considerate of you to keep compatibility with the old MSYS 
build environment, which I'm still using. (The new Git for Windows build 
environment is already on my disk, but I haven't found time to get 
familiar with it.) So, it doesn't mean a whole lot, unfortunatley, when 
I report that I've tested v1, and that it passes the test suite, because 
I've exercised almost none of the new code.

-- Hannes

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2
  2016-01-13 13:31 ` [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
@ 2016-01-21 10:36   ` SZEDER Gábor
  2016-01-21 13:51     ` Johannes Schindelin
  0 siblings, 1 reply; 23+ messages in thread
From: SZEDER Gábor @ 2016-01-21 10:36 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: SZEDER Gábor, git, Junio C Hamano

> This just makes things compile, the test suite needs extra tender loving
> care in addition to this change. We will address these issues in later
> commits.
> 
> While at it, also allow building MSys2 Git (i.e. a Git that uses MSys2's
> POSIX emulation layer).
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  config.mak.uname | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/config.mak.uname b/config.mak.uname
> index b0592c1..4b2e1b8 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -518,13 +518,12 @@ ifneq (,$(findstring MINGW,$(uname_S)))
>  	NO_INET_NTOP = YesPlease
>  	NO_POSIX_GOODIES = UnfortunatelyYes
>  	DEFAULT_HELP_FORMAT = html
> -	COMPAT_CFLAGS += -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
> +	COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
>  	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
>  	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
>  		compat/win32/pthread.o compat/win32/syslog.o \
>  		compat/win32/dirent.o
>  	BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
> -	BASIC_LDFLAGS += -Wl,--large-address-aware
>  	EXTLIBS += -lws2_32
>  	GITLIBS += git.res
>  	PTHREAD_LIBS =

(On Windows I only used git, and only briefly, and it was back in the
v1.9.x era, so please pardon my ignorance...)

I'm puzzled by the if statements in the hunk below:

> @@ -545,8 +544,17 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
>  else
>  	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
>  		# MSys2
> +		prefix = /usr/
> +		ifeq (MINGW32,$(MSYSTEM))
> +			prefix = /mingw32

Here prefix is set for 32 bit MSys2.  OK.

> +		endif
> +		ifeq (MINGW64,$(MSYSTEM))
> +			prefix = /mingw64

Here prefix is set for 64 bit MSys2.  Still OK.

> +		else
> +			COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
> +			BASIC_LDFLAGS += -Wl,--large-address-aware

But then these flags are set for any MSys2 that is not 64 bit, which
also includes MINGW32, which we've already dealt with above
explicitly.  Hmm.

Is this intentional?  It would be easier to follow if the settings
specific to MINGW32 weren't scattered in two discontinuous blocks.
What values can MSYSTEM have here besides MINGW32 and MINGW64?

Thanks,
Gábor

> +		endif
>  		CC = gcc
> -		prefix = /mingw32
>  		COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
>  		INSTALL = /bin/install
>  		NO_R_TO_GCC_LINKER = YesPlease
> -- 
> 2.6.3.windows.1.300.g1c25e49

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2
  2016-01-21 10:36   ` SZEDER Gábor
@ 2016-01-21 13:51     ` Johannes Schindelin
  0 siblings, 0 replies; 23+ messages in thread
From: Johannes Schindelin @ 2016-01-21 13:51 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: git, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 2923 bytes --]

Hi Gábor,

On Thu, 21 Jan 2016, SZEDER Gábor wrote:

> > This just makes things compile, the test suite needs extra tender
> > loving care in addition to this change. We will address these issues
> > in later commits.

Please note this statement:

> > While at it, also allow building MSys2 Git (i.e. a Git that uses MSys2's
> > POSIX emulation layer).
> > [...]
> > diff --git a/config.mak.uname b/config.mak.uname
> > index b0592c1..4b2e1b8 100644
> > --- a/config.mak.uname
> > +++ b/config.mak.uname
> > @@ -545,8 +544,17 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
> >  else

... and that this here condition triggers only for MSYS2 [*1*], but in all
modes, i.e. 32-bit/64-bit MSYS2/MINGW...

> >  	ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
> >  		# MSys2
> > +		prefix = /usr/
> > +		ifeq (MINGW32,$(MSYSTEM))
> > +			prefix = /mingw32
> 
> Here prefix is set for 32 bit MSys2.  OK.

Actually, it is not 32-bit MSYS2 but 32-bit MINGW. Please remember that
MSYS2 programs use the MSYS2 runtime (in essence a portable version of
Cygwin's runtime), i.e. a POSIX emulation layer, while MINGW programs do
not.

As a consequence, MINGW programs are 1) faster, and 2) cannot use POSIX
functionality such as fork().

So yes, this triggers when we are using the 32-bit MINGW environment,
which is just a mode in which you can start MSYS2 (or for that matter, the
Git for Windows SDK), simply by setting the environment variable `MSYSTEM`
accordingly.

The modes are MINGW32, MINGW64 and MSYS. You cannot switch between 32-bit
MSYS2 and 64-bit MSYS2 that way because you can run either with 32-bit
MSYS2 runtime & programs or 64-bit MSYS2 runtime & programs. You can
easily mix & match 32-bit and 64-bit MINGW programs, though.

> > +		endif
> > +		ifeq (MINGW64,$(MSYSTEM))
> > +			prefix = /mingw64
> 
> Here prefix is set for 64 bit MSys2.  Still OK.

Well, 64-bit *MINGW*, not 64-bit *MSYS2*.

> > +		else
> > +			COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
> > +			BASIC_LDFLAGS += -Wl,--large-address-aware
> 
> But then these flags are set for any MSys2 that is not 64 bit, which
> also includes MINGW32, which we've already dealt with above
> explicitly.  Hmm.

Remember the second paragraph of the commit message here, please: we want
MSYS2 Git to be compiled, too. As opposed to MINGW Git. It is slower, yes,
but by being able to use POSIX functionality, it can side-step any bugs in
our Windows-specific code, if any.

And even 64-bit MSYS2's tools can handle those C and LD flags, last time I
checked, it is just 64-bit MINGW's tools that cannot.

Ciao,
Johannes

Footnote *1*: While "MSYS2" suggests that it is a four-letter acronym
rather than a two-letter one (it really only stands for "*M*inimal
*Sys*tem" version 2), at least one of the MSYS2 developers is adamant
about using all-caps. It's a fight I don't need, so I don't fight it.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2016-01-21 13:51 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 13:30 [PATCH 0/5] Fix compile errors with MSys2 Johannes Schindelin
2016-01-13 13:30 ` [PATCH 1/5] config.mak.uname: support MSys2 Johannes Schindelin
2016-01-13 16:11   ` Jeff King
2016-01-13 16:45     ` Johannes Schindelin
2016-01-13 19:23     ` Dennis Kaarsemaker
2016-01-13 13:31 ` [PATCH 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
2016-01-21 10:36   ` SZEDER Gábor
2016-01-21 13:51     ` Johannes Schindelin
2016-01-13 13:31 ` [PATCH 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
2016-01-13 19:28   ` Junio C Hamano
2016-01-13 13:31 ` [PATCH 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
2016-01-13 13:31 ` [PATCH 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
2016-01-13 19:31 ` [PATCH 0/5] Fix compile errors " Junio C Hamano
2016-01-14  6:53   ` Johannes Schindelin
2016-01-14 16:51 ` [PATCH v2 " Johannes Schindelin
2016-01-14 16:51   ` [PATCH v2 1/5] config.mak.uname: support MSys2 Johannes Schindelin
2016-01-14 21:45     ` Johannes Sixt
2016-01-14 16:51   ` [PATCH v2 2/5] config.mak.uname: supporting 64-bit MSys2 Johannes Schindelin
2016-01-14 16:51   ` [PATCH v2 3/5] nedmalloc: allow compiling with MSys2's compiler Johannes Schindelin
2016-01-14 16:51   ` [PATCH v2 4/5] compat/mingw: support MSys2-based MinGW build Johannes Schindelin
2016-01-14 16:52   ` [PATCH v2 5/5] compat/winansi: support compiling with MSys2 Johannes Schindelin
2016-01-14 20:21   ` [PATCH v2 0/5] Fix compile errors " Junio C Hamano
2016-01-14 21:57   ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).