On 11/5/26 3:26 AM, Richard Biener wrote:
On Wed, Nov 4, 2026 at 10:55 PM Jason Merrill <[email protected]> wrote:

On 11/4/26 11:49 AM, Iain Sandoe wrote:


On 4 Nov 2026, at 15:02, Richard Biener <[email protected]> wrote:

On Wed, Nov 4, 2026 at 4:00 PM Michael Matz <[email protected]> wrote:

Hello,

On Wed, 4 Nov 2026, Iain Sandoe wrote:

At -Os, -fdeclone-ctor-dtor is enabled, which splits a cdtor into a unified
body (C4) plus C1/C2 thunks.

A TU that inlines a thunk therefore materialises a call to a C4 whose
own offline body is DECL_EXTERNAL (but emitted by nobody), and the
link fails with an undefined reference.

And if the C1/2 thunks are not inlined: which entity emits their body?
And why is that entity then not also the responsible one for emitting the
C4 body?  This all sounds rather like a problem in setting up the
properties of the C1/2/4 symbols and not in the inliner?

Or rather if the C4 body has no public symbol, why is it also covered by
this rule, thus why is it DECL_EXTERNAL as well and not simply static?

On HAVE_COMDAT_GROUPS targets it's static; on other targets we don't
want to bloat by emitting a static copy in every TU, so we emit a
weak/one-only copy to go with the C1/2 that uses it.  Except in this
case the extern template tells us not to emit it, so we don't.

I don't know if DECL_EXTERNAL is the right test or if get_availability
would be better?

The situation seems to be

   C4 thunk -> C4 body

C1/C2 thunks -> C4 body

where the C4 thunk symbol is externally available, the C4 body is not but
both bodies are available for inlining.  So we somehow have to mark the
callgraph edge between the thunk and the body as to not materializable.
I don't think there's a way to do that.  Thus my original suggestion to
instead force emitting of the C4 body locally when there is such edge in the
program?

We do normally, but the code told us not to emit anything for this constructor.

This is fine for C1/2 where they are emitted according to the ABI, but
it does not work for C4 which is an internal implementation detail and
is not emitted (and we do not want to emit it).

And why not?  It seems to me that when (a) C1/2 are emitted for other TUs
use, and (b) -fdeclone-ctor-dtor says "but please commonize their body
into a C4 helper" that then it follows that C4 should be emitted at the
place where C1/2 are.

If the other TU is also compiled with -fdeclone-ctor-dtor, yes.  But in
this case it isn't.

The inlining adjustment seems like the right path to me: if we can't
inline the whole constructor, inline none of it.

A pragmatic solution would then be to un-declone C4 on such targets.
Do not make the separated bodies available for inlining?

Sure, that would also work.

Jason

Reply via email to