Skip to content

Fix #23731 - undefined __xopEquals/__xtoHash for instantiated struct - #23732

Draft
dkorpel wants to merge 1 commit into
dlang:masterfrom
dkorpel:fix-23731
Draft

Fix #23731 - undefined __xopEquals/__xtoHash for instantiated struct#23732
dkorpel wants to merge 1 commit into
dlang:masterfrom
dkorpel:fix-23731

Conversation

@dkorpel

@dkorpel dkorpel commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #23731

Claude's description:

Bisected to 786dc71 ("Emit special __xopEquals/__xopCmp/__xtoHash members once"), which removed the emission of those members from TypeInfoStructDeclaration codegen on the assumption that they are always emitted along with the StructDeclaration in some other object file.

That assumption breaks for a struct template instance whose needsCodegen() is false but whose TypeInfo is still emitted here (isSpeculativeType returns false when ti.minst is set or sd.requestTypeInfo is true):

  • ti.minst is null — a speculative instance whose TypeInfo was requested anyway (e.g. by the inliner, which sets requestTypeInfo with a null scope). No module ever runs TemplateInstance.toObjFile() for it.
  • ti.minst is a non-root module that is not part of the compilation — as in the reported case, where the instance is created while CTFE-evaluating a manifest constant in an imported module that is never itself compiled.

In both cases the emitted TypeInfo_Struct ends up referencing __xopEquals/__xtoHash symbols that no object file defines, giving the reported link errors. This restores the pre-2.113 emission next to the TypeInfo; the functions are COMDATs, so a duplicate copy in the module that does emit the instance is harmless.

Note the reduced case in the issue also fails to link with 2.112 and 2.110 on the separate ModuleInfo for config error, which is the long-standing "all imported modules that need a ModuleInfo must be compiled and linked" requirement and is unrelated to this regression.

@dkorpel
dkorpel marked this pull request as draft August 28, 2026 11:31
@dkorpel
dkorpel changed the base branch from stable to master August 28, 2026 11:34
@dkorpel dkorpel added the Backport:v2.114 Cherry-pick this PR onto the v2.114 release branch label Aug 28, 2026
@dkorpel dkorpel closed this Aug 28, 2026
@dkorpel dkorpel reopened this Aug 28, 2026
…ruct

786dc71 stopped emitting the special TypeInfo members alongside the
TypeInfo of a template-instantiated struct whose own codegen was elided,
assuming they are always emitted with the StructDeclaration elsewhere.

That does not hold when `ti.minst` is null (a speculative instance whose
TypeInfo was requested anyway) or a non-root module that is not part of
the compilation: nothing emits `TemplateInstance.toObjFile()`, so the
TypeInfo emitted here is left referencing symbols no object file defines.

Restore emitting them next to the TypeInfo, as before 2.113.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@thewilsonator

Copy link
Copy Markdown
Contributor

Is this good to go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport:v2.114 Cherry-pick this PR onto the v2.114 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linker error in program that used to work when using 2.113-rc0

2 participants