On Mar 3, 2023, Alexandre Oliva <[email protected]> wrote:
> Hello, Florian,
> On Mar 3, 2023, Florian Weimer <[email protected]> wrote:
>> * Alexandre Oliva via Gcc-patches:
>>> + // Make sure it's not optimized out, not even with LTO.
>>> + asm ("" : : "rm" (depend));
>> If the m constraint is used, this may never emit the symbol name and
>> thus not create a reference after all.
> But that is no longer the pthread symbol itself, it's the symbol of a
> static member function with vague linkage that, because the compiler
> believes the asm statement will reference it, will still be output, and
> it's that function body that will refer to and thus pull in the symbols
> we need.
> Now, hmm, maybe with per-function sections, the compiler will emit it,
> but with section gc, the linker may drop it, so we might lose the needed
> function body. When performing LTO with an LTO-enabled libstdc++.
Wait, no, you had me going but it's really fine. What would be in
memory is a *pointer* to the function, so the function would still be
referenced by whatever initialized the pointer, so it wouldn't get GCed.
--
Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/
Free Software Activist GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts. Ask me about <https://stallmansupport.org>