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

            Bug ID: 110651
           Summary: libgfortran.spec links twice with libgcc spec
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: burnus at gcc dot gnu.org, fxcoudert at gcc dot gnu.org,
                    iains at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-apple-darwin23.0.0
            Target: x86_64-apple-darwin23.0.0
             Build: x86_64-apple-darwin23.0.0

When bootstrapping current trunk on macOS 14.0 beta 3 with Xcode 15 beta 4,
every single fortran link test FAILs like

FAIL: gfortran.dg/c-interop/allocatable-dummy.f90   -O0  (test for excess
errors)
Excess errors: 
ld: warning: ignoring duplicate library '-lemutls_w'
ld: warning: ignoring duplicate library '-lgcc'

The link line ends in

-lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem
-no_compact_unwind -idsym -dsym

I could trace this to libgfortran.spec, which has

%rename lib liborig
*lib: %{static-libquadmath:libquadmath.a%s;:-lquadmath}  %(libgcc) %(liborig)

The libgcc spec is included twice, once explicitly here and another time in
%(liborig).  I have no idea why this is done this way: this already was in 
the original patch that introduced libgfortran.spec.in:

commit 1ec601bf9fb0fbc39b3a6cb90450500f857adae8
Author: Francois-Xavier Coudert <fxcoud...@gcc.gnu.org>
Date:   Tue Nov 16 21:23:19 2010 +0000

    re PR fortran/32049 (Support on x86_64 also kind=16)

I see quite a number of possible solutions:

* Get rid of %(libgcc) in libgfortran.spec.in.

* Include it conditionally depending on a configure test.

* Disable ld warnings with -w in the spec, probably using some
@TARGET_LDFLAGS@.

* Disable ld warnings globally in the Darwin driver code.  That may be
  undisable since it would disable possibly benign warnings, too.

Reply via email to