Subject: bug#75939: closed (Re: bug#75939: setting $MSYS2_ARG_CONV_EXCL in compile script?)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 03 Feb 2025 22:21:02 +0000

Your bug report

#75939: bug in compile wrapper when using MSVC from Msys2

which was filed against the automake package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
75939: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75939
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#75939: setting $MSYS2_ARG_CONV_EXCL in compile script?
From: Karl Berry <[email-masked]>
To: [email-masked], [email-masked], [email-masked]
Date: Mon, 3 Feb 2025 23:20:02 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

    the three patches from the preceding mail are ready to commit.

Thanks very much for all your work (and explanations) on this, Bruno.
Committed. -k

Subject: bug in compile wrapper when using MSVC from Msys2
From: Kirill Makurin <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Wed, 29 Jan 2025 23:09:40 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I would like to report one quite annoying issue related to Automake's `compile` wrapper when it is used with `cl.exe` to compile some C++ files from Msys2.

I was building some GNU packages with MSVC's `cl.exe`, and compilation of some C++ source files was failing with `cl.exe` reporting non-sensual filenames like `H:E:/Msys2/{builddir}/somefile.cxx`.

Apparently, the issue is double conversion of a unix-style filename by Msys2's shell. In example above, Msys2 is installed to `E:/Msys2` and builddir is `/h/{builddir}`.

As I figured out later, it was happening because `compile` was converting `/h/{builddir}/somefile.cxx` to `H:/{builddir}/somefile.cxx` and passing it as `-TpH:/{builddir}/somefile.cxx` to `cl.exe`. However, Msys2 was interpreting `/{builddir}/somefile.cxx` as a unix-style path and converted it again, resulting in `-TpH:E:/Msys2/{builddir}/somefile.cxx`.

One way to work around this issue is :

```
export MSYS2_ARG_CONV_EXCL='-Tp'
```

However, this must be set by the user, which is inconvenient. I wonder if anything can be done in the `compile` wrapper to fix this.

I am using latest versions of MSVC tools and `cl.exe` allows to pass argument to `-Tp` as a separate argument and this seems to work correctly. However, I don't know whether older versions of `cl.exe` allow it.

- Kirill Makurin