GNU bug report logs - #75939
bug in compile wrapper when using MSVC from Msys2

Previous Next

Package: automake;

Reported by: Kirill Makurin <maiddaisuki <at> outlook.com>

Date: Thu, 30 Jan 2025 04:59:02 UTC

Severity: normal

Done: Karl Berry <karl <at> freefriends.org>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 75939 <at> debbugs.gnu.org (full text, mbox):

From: Bruno Haible <bruno <at> clisp.org>
To: bug-gnulib <at> gnu.org, Karl Berry <karl <at> freefriends.org>
Cc: Kirill Makurin <maiddaisuki <at> outlook.com>, 75939 <at> debbugs.gnu.org
Subject: Re: setting $MSYS2_ARG_CONV_EXCL in compile script?
Date: Mon, 03 Feb 2025 06:38:52 +0100
[Message part 1 (text/plain, inline)]
Kirill Makurin wrote:
> I was going to just say that this patch is good and go ahead with it, but I decided to check it and turns out it fixes this issue only partially, but the patch itself is good.
> 
> Msys2 has multiple environments (see https://www.msys2.org/docs/environments/) and this patch works only for `MSYS`. For all other environments `uname` will report a string starting with `MINGW64` and `compile` will set `file_conv` variable to `mingw`. This, unfortunately, overlaps with mingw32 which does not have `cygpath`.
> 
> For `mingw` the filename is converted in `compile` as follows:
> 
> ```
> mingw/*)
>       file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
> ```
> 
> The resulting converted filename has forward slashes as with `cygpath -m` and suffers from the same double conversion issue.
> 
> In theory we could prepend `cygpath` invocation in this branch like this:
> 
> ```
> mingw/*)
>       file=`cygpath -w  "$file" 2>/dev/null || cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
> ```
> 
> However, compilation is still going to fail if there is no `cygpath` (also ,`cygpath` is not installed with Msys2 by default).
> 
> I think a better solution may be to add additional sed invocation in the pipe to convert forward slashes to backslashes.
> 
> I also was wondering if passing `mingw` as the second argument into `func_file_conv ` in this branch could help, but unfortunately `/filename` in resulting `-Tp/filename` is not converted by Msys2.
> 
> ```
> *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
>         func_file_conv "$1"
> ```
> 
> I hope I didn't cause too much confusion about `MSYS2_ARG_CONV_EXCL`, I was a bit in a hurry and probably didn't make it clear that I meant setting `MSYS2_ARG_CONV_EXCL` more like an external user-side workaround (e.g. I was setting it in my build script).
> 
> - Kirill Makurin

Thanks for testing.

> For all other environments `uname` will report a string starting with `MINGW64`
> and `compile` will set `file_conv` variable to `mingw`.

OK, so what you saying is the detection / distinction of environments
is not working. Which is quite plausible, since the original code was
written in 2010 (when MSYS2 did not exist) and Paul's patch from 2019-11-11
was apparently not well tested (Paul is not using Windows environments).

So, let's fix this environment distinction. This is better than applying
workarounds that will affect behaviour on the original MinGW.

Here are 3 proposed patches:

0001) This is a cleanup of Paul's patch from 2019-11-11. Since $file_conv
      can only have one of the three values 'mingw', 'cygwin', 'wine',
      it is pointless to test whether this value is 'msys'.

0002) This patch extends the distinction of environments. Since I don't
      have first-hand info about these environments, I asked the prior
      knowledge summarization engine. Results are attached. I trust these
      answers, because MinGW + MSYS is a topic that is widely discussed
      on the web.

0003) This patch is the same as already proposed: use backslashed filenames
      instead of forward-slashes ones (that MSYS2 would interpret a second
      time).

Kirill: Testing of this patch series in your environment (MSYS2 + MSVC)
        is welcome.

Bruno
[0001-compile-Simplify.patch (text/x-patch, attachment)]
[0002-compile-Distinguish-various-MinGW-MSYS-MSYS2-environ.patch (text/x-patch, attachment)]
[0003-compile-Improve-support-for-C-compilations-on-MSYS2.patch (text/x-patch, attachment)]
[mingw-msys-environments.odt (application/vnd.oasis.opendocument.text, attachment)]

This bug report was last modified 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.