non-cross GCC relies on PATH skulduggery
Describe the issue
- Microsoft Windows [Version 10.0.19043.1466]
- NTFS installation on the system drive C.
- Fully up-to-date install with
gccandbinutilsas well as the non-cross headers, as of 2022-01-28 15:06 CET
This is a standard msys2 installation, with gcc in /bin targetting x86_64-pc-msys. Binutils and cygwin headers are similarly installed.
Setting PATH to /bin breaks the non-cross compiler:
% PATH=/bin gcc foo.c
gcc: fatal error: cannot execute ‘cc1’: spawn: No such file or directory
Setting PATH to /usr/bin:/bin solves the issue, but /usr/bin is an alias so this should never happen. There's no cc1.exe there anyway.
But then there are more issues (say, building git 2.35.0):
checking for socklen_t equivalent... configure: error: Cannot find a type to use in place of socklen_t
Finally, this works (makepkg.conf was adjusted slightly for the environment to take precedence):
export CC='gcc -B /usr/lib/gcc/x86_64-pc-msys/11.2.0' CXX='g++ -B/usr/lib/gcc/x86_64-pc-msys/11.2.0'
A local toolchain rebuild with no patches would most likely work but the msys2 packages were meant so that there's no need to build gcc, whether cross or native msys2/cygwin.
but /usr/bin is an alias so this should never happen
Is it really true for msys2? In GNU/Linux distributions, /bin is a symbolic link to /usr/bin but not in msys2. Please correct me if I am wrong.
The output of ls /bin and ls /usr/bin is identical.
And there's nothing special in my /etc/fstab either:
# For a description of the file format, see the Users Guide
# https://cygwin.com/cygwin-ug-net/using.html#mount-table
# DO NOT REMOVE NEXT LINE. It remove cygdrive prefix from path
none / cygdrive binary,posix=0,noacl,user 0 0
C:/Users /home ntfs binary,posix=0,noacl,user 0 0
D:/Temp /tmp ntfs binary,posix=0,noacl,user 0 0
D:/Temp /var/cache/pacman/pkg ntfs binary,posix=0,noacl,user 0 0
FWIW, the last two are due to the use of an SSD.
Finally, here's env | sort:
env.txt