|
From: | Kirill Makurin |
Subject: | bug#75939: setting $MSYS2_ARG_CONV_EXCL in compile script? |
Date: | Mon, 3 Feb 2025 08:25:55 +0000 |
I applied patches and they work for Msys2.
I also tested it with (what I assume is) "Msys-based MinGW" (https://osdn.net/projects/mingw/) and it fails. Its `uname -s` reports `MINGW32_NT-6.2` and it has `MSYSTEM` set , and it lacks `cygpath`.
Should we even distinguish between "original MinGW" and "Msys-based MinGW"? I think they both lack `cygpath` and should be treated the same. I may not know something about "original MinGW" though.
The `/etc/msystem` file does not exist with this "Msys-based MinGW".
The `uname -r` method mentioned in the attached file seems outdated. Current Msys2's `uname-r` has `x86_64` suffix instead of `msys` in its output (regardless of environment).
---
I explicitly set `file_conv` to `mingw` in compile just for testing with this MinGW and there are no issues with double conversion.
- Kirill Makurin
From: Bruno Haible <bruno@clisp.org>
Sent: Monday, February 3, 2025 2:38 PM To: bug-gnulib@gnu.org <bug-gnulib@gnu.org>; Karl Berry <karl@freefriends.org> Cc: Kirill Makurin <maiddaisuki@outlook.com>; 75939@debbugs.gnu.org <75939@debbugs.gnu.org> Subject: Re: setting $MSYS2_ARG_CONV_EXCL in compile script? 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 |
[Prev in Thread] | Current Thread | [Next in Thread] |