https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664
--- Comment #1 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
The bug exists in 11.3.0 and 12.1.0
The part of "make install-strip" that creates the issue is the following:
if [ "gcc-11" != "aarch64-apple-darwin21-gcc-11" ]; then \
rm -f
/private/tmp/gcc-20220519-78662-28g74h/gcc-11.3.0/build/../instdir/opt/homebrew/opt/gcc/bin/aarch64-apple-darwin21-gcc-11;
\
( cd
/private/tmp/gcc-20220519-78662-28g74h/gcc-11.3.0/build/../instdir/opt/homebrew/opt/gcc/bin
&& \
ln gcc-11 aarch64-apple-darwin21-gcc-11 ); \
fi; \
if [ ! -f gcc-cross ] \
&& [ "gcc-11" != "aarch64-apple-darwin21-gcc-11" ]; then \
rm -f
/private/tmp/gcc-20220519-78662-28g74h/gcc-11.3.0/build/../instdir/opt/homebrew/opt/gcc/bin/aarch64-apple-darwin21-gcc-tmp;
\
( cd
/private/tmp/gcc-20220519-78662-28g74h/gcc-11.3.0/build/../instdir/opt/homebrew/opt/gcc/bin
&& \
ln gcc-11 aarch64-apple-darwin21-gcc-tmp && \
mv -f aarch64-apple-darwin21-gcc-tmp
aarch64-apple-darwin21-gcc-11 ); \
fi; \
fi
which boils down to:
rm -f aarch64-apple-darwin21-gcc-11
ln gcc-11 aarch64-apple-darwin21-gcc-11
rm -f aarch64-apple-darwin21-gcc-tmp
ln gcc-11 aarch64-apple-darwin21-gcc-tmp
mv -f aarch64-apple-darwin21-gcc-tmp aarch64-apple-darwin21-gcc-11
The final "mv -f" does nothing, since the two files are the same: it does not
remove aarch64-apple-darwin21-gcc-tmp, and this is how we end up with that file
in the prefix.