public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105664] New: Install with suffix creates extra file
@ 2022-05-19 16:39 fxcoudert at gcc dot gnu.org
  2022-05-19 16:43 ` [Bug bootstrap/105664] " fxcoudert at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-05-19 16:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

            Bug ID: 105664
           Summary: Install with suffix creates extra file
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org
  Target Milestone: ---

Building gcc-11.3.0 from source on darwin with --program-suffix=-11 leads to
the following files being installed in the prefix:

-r-xr-xr-x  3 fx  admin  1397936 May 19 18:25
/opt/homebrew/Cellar/gcc/11.3.0_1/bin/aarch64-apple-darwin21-gcc-11
-r-xr-xr-x  3 fx  admin  1397936 May 19 18:25
/opt/homebrew/Cellar/gcc/11.3.0_1/bin/aarch64-apple-darwin21-gcc-tmp
-r-xr-xr-x  3 fx  admin  1397936 May 19 18:25
/opt/homebrew/Cellar/gcc/11.3.0_1/bin/gcc-11

That's three hard links of the gcc driver: gcc-11 and
aarch64-apple-darwin21-gcc-11 are expected, but aarch64-apple-darwin21-gcc-tmp
should not be present.

The full configure line is:

configure --prefix=/opt/homebrew/opt/gcc
--libdir=/opt/homebrew/opt/gcc/lib/gcc/11 --disable-nls
--enable-checking=release --with-gcc-major-version-only
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11
--build=aarch64-apple-darwin21 --with-system-zlib
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk && make
install-strip

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
@ 2022-05-19 16:43 ` fxcoudert at gcc dot gnu.org
  2022-05-19 16:45 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-05-19 16:43 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
  2022-05-19 16:43 ` [Bug bootstrap/105664] " fxcoudert at gcc dot gnu.org
@ 2022-05-19 16:45 ` pinskia at gcc dot gnu.org
  2022-05-19 16:47 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 16:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
install-driver: installdirs xgcc$(exeext)
        -rm -f $(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext)
        -$(INSTALL_PROGRAM) xgcc$(exeext)
$(DESTDIR)$(bindir)/$(GCC_INSTALL_NAME)$(exeext)
        -if test "$(enable_as_accelerator)" != "yes" ; then \
          if [ "$(GCC_INSTALL_NAME)" != "$(target_noncanonical)-gcc-$(version)"
]; then \
            rm -f $(DESTDIR)$(bindir)/$(FULL_DRIVER_NAME); \
            ( cd $(DESTDIR)$(bindir) && \
              $(LN) $(GCC_INSTALL_NAME)$(exeext) $(FULL_DRIVER_NAME) ); \
          fi; \
          if [ ! -f gcc-cross$(exeext) ] \
              && [ "$(GCC_INSTALL_NAME)" != "$(GCC_TARGET_INSTALL_NAME)" ];
then \
            rm -f $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-tmp$(exeext);
\
            ( cd $(DESTDIR)$(bindir) && \
              $(LN) $(GCC_INSTALL_NAME)$(exeext)
$(target_noncanonical)-gcc-tmp$(exeext) && \
              mv -f $(target_noncanonical)-gcc-tmp$(exeext)
$(GCC_TARGET_INSTALL_NAME)$(exeext) ); \
          fi; \
        fi

The last mv is failing ....

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
  2022-05-19 16:43 ` [Bug bootstrap/105664] " fxcoudert at gcc dot gnu.org
  2022-05-19 16:45 ` pinskia at gcc dot gnu.org
@ 2022-05-19 16:47 ` pinskia at gcc dot gnu.org
  2022-05-19 16:52 ` fxcoudert at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 16:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://pubs.opengroup.org/onlinepubs/009604599/utilities/mv.html

https://pubs.opengroup.org/onlinepubs/009604599/functions/rename.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-05-19 16:47 ` pinskia at gcc dot gnu.org
@ 2022-05-19 16:52 ` fxcoudert at gcc dot gnu.org
  2022-05-19 17:56 ` fxcoudert at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-05-19 16:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #4 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
1. I've reproduced it on x86_64-linux, so it's not a weird macOS mv bug

2. I have reasons to think (no hard proof, though) that it's a new bug: we're
hitting it during Homebrew testing, but it wasn't the case before. Yet, this is
confusing, because the install-driver target in gcc/Makefile.in has not been
changed in years.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-05-19 16:52 ` fxcoudert at gcc dot gnu.org
@ 2022-05-19 17:56 ` fxcoudert at gcc dot gnu.org
  2022-05-19 19:28 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-05-19 17:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #5 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
I can reproduce it with various combinations of configure options, with and
without bootstrap. It appears that the triggering factor is the combination of
two options:

--with-gcc-major-version-only
--program-suffix=-11

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-05-19 17:56 ` fxcoudert at gcc dot gnu.org
@ 2022-05-19 19:28 ` schwab@linux-m68k.org
  2022-05-19 20:27 ` fxcoudert at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2022-05-19 19:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #6 from Andreas Schwab <schwab@linux-m68k.org> ---
Perhaps the macos mv has recently been upgraded to POSIX.1-2018.  Step 2 of the
mv operation didn't exist in the 2004 edition.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-05-19 19:28 ` schwab@linux-m68k.org
@ 2022-05-19 20:27 ` fxcoudert at gcc dot gnu.org
  2022-05-20  6:41 ` rguenth at gcc dot gnu.org
  2023-04-21 13:44 ` fxcoudert at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2022-05-19 20:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #7 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
So, to summarise my understanding:

- the problem is not specific to darwin, I can fully reproduce on
x86_64-linux-gnu

- the problem only arises if you configure with a --program-suffix that is
equal to the version. Then $(target_noncanonical)-gcc-$(version) is equal to
$(GCC_TARGET_INSTALL_NAME) and this triggers the issue.


I am not sure if it is the cleanest way to fix things, but I think we can
safely remove the temporary file after "mv", in all cases, like this:


diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 97e5450ecb5..602c382e86e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3780,6 +3780,7 @@ install-driver: installdirs xgcc$(exeext)
            ( cd $(DESTDIR)$(bindir) && \
              $(LN) $(GCC_INSTALL_NAME)$(exeext)
$(target_noncanonical)-gcc-tmp$(exeext) && \
              mv -f $(target_noncanonical)-gcc-tmp$(exeext)
$(GCC_TARGET_INSTALL_NAME)$(exeext) ); \
+           rm -f $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-tmp$(exeext);
\
          fi; \
        fi


I can confirm this fixes the issue.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-05-19 20:27 ` fxcoudert at gcc dot gnu.org
@ 2022-05-20  6:41 ` rguenth at gcc dot gnu.org
  2023-04-21 13:44 ` fxcoudert at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-20  6:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Francois-Xavier Coudert from comment #7)
> So, to summarise my understanding:
> 
> - the problem is not specific to darwin, I can fully reproduce on
> x86_64-linux-gnu
> 
> - the problem only arises if you configure with a --program-suffix that is
> equal to the version. Then $(target_noncanonical)-gcc-$(version) is equal to
> $(GCC_TARGET_INSTALL_NAME) and this triggers the issue.
> 
> 
> I am not sure if it is the cleanest way to fix things, but I think we can
> safely remove the temporary file after "mv", in all cases, like this:
> 
> 
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 97e5450ecb5..602c382e86e 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -3780,6 +3780,7 @@ install-driver: installdirs xgcc$(exeext)
>             ( cd $(DESTDIR)$(bindir) && \
>               $(LN) $(GCC_INSTALL_NAME)$(exeext)
> $(target_noncanonical)-gcc-tmp$(exeext) && \
>               mv -f $(target_noncanonical)-gcc-tmp$(exeext)
> $(GCC_TARGET_INSTALL_NAME)$(exeext) ); \
> +           rm -f
> $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-tmp$(exeext); \
>           fi; \
>         fi
>  
> 
> I can confirm this fixes the issue.

Testing whether $(GCC_TARGET_INSTALL_NAME)$(exeext) is present before
creating the link might also work?  Or testing whether it is the same
as $(target_noncanonical)-gcc-$(version)?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug bootstrap/105664] Install with suffix creates extra file
  2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-05-20  6:41 ` rguenth at gcc dot gnu.org
@ 2023-04-21 13:44 ` fxcoudert at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2023-04-21 13:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-04-21
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #9 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Present in gcc-13.1.0-RC-20230421

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-21 13:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 16:39 [Bug c/105664] New: Install with suffix creates extra file fxcoudert at gcc dot gnu.org
2022-05-19 16:43 ` [Bug bootstrap/105664] " fxcoudert at gcc dot gnu.org
2022-05-19 16:45 ` pinskia at gcc dot gnu.org
2022-05-19 16:47 ` pinskia at gcc dot gnu.org
2022-05-19 16:52 ` fxcoudert at gcc dot gnu.org
2022-05-19 17:56 ` fxcoudert at gcc dot gnu.org
2022-05-19 19:28 ` schwab@linux-m68k.org
2022-05-19 20:27 ` fxcoudert at gcc dot gnu.org
2022-05-20  6:41 ` rguenth at gcc dot gnu.org
2023-04-21 13:44 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).