Re: [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it

Johannes Schindelin <[email protected]> Thu, 6 Aug 2026 14:50:44 +0200 (CEST)
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Hi Junio,

On Wed, 5 Aug 2026, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <[email protected]>
> writes:
> [...]
> > diff --git a/meson.build b/meson.build
> > index 7073d5844d..6ddc461873 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -1318,7 +1318,6 @@ elif host_machine.system() == 'windows'
> >  
> >    libgit_c_args += [
> >      '-DDETECT_MSYS_TTY',
> > -    '-DENSURE_MSYSTEM_IS_SET',
> >      '-DNATIVE_CRLF',
> >      '-DNOGDI',
> >      '-DNO_POSIX_GOODIES',
> > @@ -1328,6 +1327,18 @@ elif host_machine.system() == 'windows'
> >      '-D__USE_MINGW_ANSI_STDIO=0',
> >    ]
> >  
> > +  msystem = get_option('msystem')
> > +  if msystem != ''
> > +    mingw_prefix = get_option('mingw_prefix')
> > +    if mingw_prefix == ''
> > +      mingw_prefix = '/' + msystem.to_lower()
> > +    endif
> > +    libgit_c_args += [
> > +      '-DENSURE_MSYSTEM_IS_SET="' + msystem + '"',
> > +      '-DMINGW_PREFIX="' + mingw_prefix + '"'
> > +    ]
> > +  endif
> 
> Lowercase mingw_prefix in Meson world corresponds to MINGW_PREFIX in
> Make world, I guess.  -DMINGW_PRFIX gets mingw_prefix which begins
> with a slash.
> 
> I do not do Windows or Meson, but doesn't this contradict with what
> we have in [12/12], part of which says:
> 
> diff --git a/config.mak.uname b/config.mak.uname
> index 2f7d445eb3..0b63be10b7 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -535,7 +535,9 @@ endif
>  		compat/win32/pthread.o compat/win32/syslog.o \
>  		compat/win32/trace2_win32_process_info.o \
>  		compat/win32/dirent.o
> -	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
> +	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \
> +		-DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \
> +		-DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
>  	BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
>  	# invalidcontinue.obj allows Git's source code to close the same file
>  	# handle twice, or to access the osfhandle of an already-closed stdout
> 
> 
> IOW, -DMINGW_PREFIX passed to the compiler strips leading slash from
> $(MINGW_PREFIX).
> 
> Isn't it necessary to strip the leading slash from ming_prefix also
> on the Meson side?

Correct. Since Git for Windows does not use Meson to build the project,
and since the Visual C-based builds (including CI's `windows-meson-build`)
do not use `MSYSTEM`, this was not caught earlier. The next iteration will
have the fix.

Ciao,
Johannes