<div dir="ltr"><div dir="ltr">On Fri, Jun 12, 2020 at 3:40 AM kinke via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Monday, 8 June 2020 at 14:22:50 UTC, Manu wrote:<br>
> On Mon, Jun 8, 2020 at 8:30 PM kinke via Digitalmars-d <<br>
>> In its owning module, the function is emitted as a regular<br>
>> function, as a fallback for non-inlined cases (and for when <br>
>> people take its address etc.). Our opinions diverge wrt. <br>
>> whether that's a problem - to me it's clearly no big deal, as <br>
>> the function is a) most likely small, and b) subject to linker <br>
>> stripping if unreferenced.<br>
><br>
><br>
> a) most likely small, but still not nothing; the symbol table <br>
> is public ABI<br>
> material, and in some projects I've worked on, the symbol table <br>
> is<br>
> carefully curated.<br>
> b) linker stripped is not reliable. We are unnecessarily <br>
> inviting issues in<br>
> some cases, and there's just no reason for that.<br>
><br>
> If we're confident that link stripping is 100% reliable when a <br>
> symbol is not referenced, then I have no complaint here.<br>
><br>
> Can you show what case a hard-symbol in the owning CU solves? <br>
> Non-inlined<br>
> cases will still find it locally if it has internal linkage (or <br>
> whatever<br>
> that link flag is called).<br>
> I think it's the same flag that `static` (or `inline`) in C++ <br>
> specifies<br>
> right?<br>
<br>
Internal linkage (C(++) static), AFAIK, means that you may end up <br>
with multiple identical functions in the final linked binary. <br>
Some linkers may be able to still fold them, such as the MS <br>
linker and lld with /OPT:ICF (identical COMDAT folding).<br></blockquote><div><br></div><div>Actually, I might be wrong about what the link flag is called.</div><div>I'm fairly sure C++ uses the link flag that LLVM calls "choose one".</div><div>It's in the C++ spec that all inlines collapse to the same one. We should be using the same flag.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Linkonce_odr linkage (C++ templates and `inline` functions) on <br>
the other hand means that you end up with either 0 or 1 function <br>
in the final binary, even when multiple object files define it; <br>
AFAIK, without having to rely on /OPT:REF or --gc-sections etc. <br>
At least for LLVM, linkonce_odr additionally means that the <br>
definition is discarded early if unused and might not make it to <br>
the object file at all.<br>
<br>
Weak_odr linkage (current D templates) is similar to linkonce_odr <br>
but not 'officially' discardable (if unreferenced) for the final <br>
binary (and thus always making it to the object file). This can <br>
be overridden by /OPT:REF and --gc-sections etc., the success of <br>
which also depends on symbol visibility and/or --export-dynamic <br>
etc.<br>
</blockquote></div></div>