MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

`/mingw64/bin/windres` fails silently under git-for-windows environment if its path contains spaces

Open zlaski opened this issue 3 years ago • 2 comments

Description

The issue arises when trying to build FFMPEG under MingW64. The MingW64 version of windres fails with error 127 (and does not produce output), whereas the MSYS version works fine.

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ rm fftools/fftoolsres.o
rm: cannot remove 'fftools/fftoolsres.o': No such file or directory

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ /mingw64/bin/windres -I. -I/d/git/zlaski/ffmpeg/ --preprocessor-arg -MMD --preprocessor-arg -MF --preprocessor-arg fft
ools/fftoolsres.d --preprocessor-arg -MT --preprocessor-arg fftools/fftoolsres.o -o fftools/fftoolsres.o /d/git/zlaski/f
fmpeg/fftools/fftoolsres.rc

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ echo $?
127

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ ls fftools/fftoolsres.o
ls: cannot access 'fftools/fftoolsres.o': No such file or directory

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ /usr/bin/windres -I. -I/d/git/zlaski/ffmpeg/ --preprocessor-arg -MMD --preprocessor-arg -MF --preprocessor-arg fftools
/fftoolsres.d --preprocessor-arg -MT --preprocessor-arg fftools/fftoolsres.o -o fftools/fftoolsres.o /d/git/zlaski/ffmpe
g/fftools/fftoolsres.rc

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ echo $?
0

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ ls fftools/fftoolsres.o
fftools/fftoolsres.o

Both the MSYS and MingW builds are of the same version of windres:

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ /mingw64/bin/windres --version
GNU windres (GNU Binutils) 2.39
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ /usr/bin/windres --version
GNU windres (GNU Binutils) 2.39
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

The pathname /mingw64/bin/windres.exe maps to C:\Program Files\Git\mingw64\bin\windes.exe, which contains spaces. When I copy /ming64/bin/windres.exe to my D:\ drive, things start working again!

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ cp /mingw64/bin/windres.exe /d

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ rm fftools/fftoolsres.o
rm: cannot remove 'fftools/fftoolsres.o': No such file or directory

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ /d/windres -I. -I/d/git/zlaski/ffmpeg/ --preprocessor-arg -MMD --preprocessor-arg -MF --preprocessor-arg fftools/fftoolsres.d --preprocessor-arg -MT --preprocessor-arg fftools/fftoolsres.o -o fftools/fftoolsres.o /d/git/zlaski/ffmpeg/fftools/fftoolsres.rc

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ echo $?
0

zlaski@RUMCAJS MINGW64 /tmp/.akibuild/build/x86_64-pc-msys-Debug/ffmpeg
$ ls fftools/fftoolsres.o
fftools/fftoolsres.o

Verification

  • [X] I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)

Windows Version

Microsoft Windows [Version 10.0.19044.1645] git-for-windows 2.38.1.1

MINGW environments affected

  • [X] MINGW64
  • [ ] MINGW32
  • [ ] UCRT64
  • [ ] CLANG64
  • [ ] CLANG32
  • [ ] CLANGARM64

Expected behavior

/mingw64/bin/windres.exe should produce the same behavior as /usr/bin/windres.exe

Actual behavior

/mingw64/bin/windres.exe exits with code 127 and does not produce any output.

Further investigation reveals that the culprit may be spaces contained in the NTFS (Windows) path of /mingw64/bin/windres.exe

Repro steps

See the "terminal dump" above.

Are you willing to submit a PR?

Yes. Please let me know if you'd like me to do so, and what to include.

zlaski avatar Nov 20 '22 02:11 zlaski

Further investigation reveals that the culprit may be spaces contained in the NTFS (Windows) path of /mingw64/bin/windres.exe

yeah, many gnu tools can't handle spaces in paths

lazka avatar Nov 20 '22 06:11 lazka

I'm finding an issue related to this one that may have clues of how to solve: The path I'm working now have some accents like /c/Consolação/ofw/examples/3d/3DPrimitivesExample and I'm already inside the last folder, and using windres with relative paths. It actually errors with invalid argument. Path name is now corrupt. It outputs absolute path even if I'm not using it. Same command works OK and completes if I'm calling /ucrt64/bin/windres instead

dimitre avatar May 13 '24 13:05 dimitre