Re: [PATCH 18/46] entry, lto: Mark raw_irqentry_exit_cond_resched() as __visible

Peter Zijlstra
2022-11-17T08:41:17Z

On Thu, Nov 17, 2022 at 12:30:34AM +0100, Thomas Gleixner wrote:
> On Mon, Nov 14 2022 at 12:43, Jiri Slaby wrote:
> > Symbols referenced from assembler (either directly or e.f. from
>
> from assembler? I'm not aware that the assembler references anything.
>
> Also what does e.f. mean? Did you want to write e.g.?
>
> > DEFINE_STATIC_KEY()) need to be global and visible in gcc LTO because
> > they could end up in a different object file than the assembler. This
>
> than the assembler? Are we shipping the assembler in an object file?
>
> > can lead to linker errors without this patch.
>
> git grep -i 'this patch' Documentation/process/
>
> > So mark raw_irqentry_exit_cond_resched() as __visible.
>
> And all that tells me what? I know what you want to say, but it's not
> there.
>
> Symbols in different compilation units which are referenced from
> assembly code either directly or indirectly, e.g. from
> DEFINE_STATIC_KEY(), must be marked visible for GCC based LTO builds.
>
> Add the missing __visible annotation to raw_irqentry_exit_cond_resched().
>
> See?
>
> There is no 'global' because it's obvious that a symbol in a different
> compilation unit must be global to be resolvable. It's also obvious that
> code in different compilation units ends up in different object files.
>
> So stating that it's a 'must' to have such symbols marked visible is
> good enough for an argument because that tells the reader that this is a
> mandatory requirement for an GCC based LTO build.
>
> No?

I still don't understand any of it -- this symbol is not static (and
thus lives in the global namespace and it's name must not be mangled
lest it breaks ABI), this symbol has it's address taken, so it must not
be eliminated.

WTF does this crazy LTO thing require __visible on it?

The original Changelog babbles something about multiple object files,
which doesn't make sense either, there is only a single object file with
LTO -- that's sort of the whole point. The translation unit output
becomes some intermediate gunk -- to be used as input for the LTO pass,
but it is not an ELF object file.

The linker takes all these intermediate files, does the global
optimization thing and then generates a real ELF object file.

Anyway; I think we can drop all this crazy on the floor again, since per
the 0/n (which I didn't get) there isn't any actual benefit from using
GCC-LTO, so why should we bother with all this ugly.

I would suggest GCC implement this integrated assembler and follow the
clang lead here -- or people who want LTO use clang. GCC is clearly
inferior here.