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

--- Comment #40 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #39)
> (In reply to Iain Sandoe from comment #38)
> > (In reply to Richard Biener from comment #37)
> > > Oh, and FYI a cc1 cross from x86_64 to x86_64-apple-darwin19.6.0 doesn't 
> > > seem
> > > to reproduce the issue with the reduced testcase (I seee no call to
> > > ___UTF_8_put remaining with -O3 -fPIC -fno-strict-aliasing -fwrapv).
> > 
> > I think my interestingness test isn't strict enough - the creduced code
> > resulting doesn't have an extern for ___UTF_8_put and only seems to not
> > inline that fn because the interface has been mangled. [ so that the fn is
> > legitimately binds_localP as the pasted case ].
> > 
> > if you still have the build around, out of curiosity, does it fail on the
> > original .i file attached here?
> > 
> > and with -fno-trapping-math -fno-math-errno -fschedule-insns2
> > -fomit-frame-pointer
> > 
> > ( I only need O2 to get a fail ).
> 
> Yes, with -O2 -fno-trapping-math -fno-math-errno -fschedule-insns2
> -fomit-frame-pointer it produces the problematical
> 
>         .align 4,0x90
> L945:
>         movl    0(%rbp,%r10,4), %esi
>         call    ____UTF_8_put
>         movq    %r10, %rax
>         addq    $1, %r10
>         cmpq    %rax, %r12
>         jne     L945
> 
> code.  But then ___UTF_8_put isn't interposable so I wonder why the linker
> even has to resolve anything.  Adding -fPIC OTOH should definitely make the
> symbol interposable but the same code is still generated ...
> 
> Note the 'extern' declaration shouldn't change anything, only that we
> see a definition is relevant.
> 
> breaking on darwin_binds_local_p I see ___UTF_8_put is considered binding
> local even with -fPIC.  So GCC thinks there will be no linker stub involved.
> 
> Note 'shlib' is passed as false to default_binds_local_p_3 computed as
> 
> 3140         on earlier system versions, and with a TODO to complete.  */
> 3141      bool force_overridable = TARGET_KEXTABI && DARWIN_VTABLE_P (decl);
> 3142      return default_binds_local_p_3 (decl, force_overridable /* shlib
> */,
> 3143                                      false /* weak dominate */,
> 
> and default_binds_local_p_3 would do
> 
>   /* If PIC, then assume that any global name can be overridden by
>      symbols resolved from other modules.  */
>   if (shlib)
>     return false;
> 
> ix86_binds_local_p simply passes flag_shlib != 0 as this argument.

So it looks like darwin should pass

  flag_shlib != 0 || force_overridable

instead?

Reply via email to