dmd
dmd copied to clipboard
Fix Bugzilla 24599 - Wrongly elided TypeInfo emission
Reverting #14844, which caused such missing TypeInfos, and making sure the special TypeInfo members are fully analyzed and ready for codegen (otherwise hitting an assertion).
Currently just checking if it breaks CI somewhere.
Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
| Auto-close | Bugzilla | Severity | Description |
|---|---|---|---|
| ✓ | 24599 | regression | [REG2.103] Wrongly elided TypeInfo emission leading to undefined symbols at link-time |
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "stable + dmd#15868"
@kinke is there a bugzilla issue for this? Or do you have a test that I can reproduce? I'm kind of surprised that this doesn't break any code at there, since IIRC this was needed to advance work on templating the druntime hooks.
@RazvanN7: Nope sorry, no issue yet; the problem occurs in a private codebase, and unfortunately one of the largest/most complicated ones at Symmetry, so I'm not exactly looking forward to setting up an involved dustmite session. ;)
I see. I'm just wondering what's the best way to proceed here. If I merge the revert, I'm gonna have to find a different fix for Issue 23650, but without a test case I risk on breaking your code again. If I don't merge it, your code stays broken.
I'm gonna have to find a different fix for Issue 2365
I think this can only be properly fixed by re-designing the way struct TypeInfos (and the special TypeInfo member functions) are emitted in DMD, adopting the LDC way (I've changed this some years ago, no more TypeInfo issues since then AFAICT: https://github.com/ldc-developers/ldc/pull/3491). The main change there is that the struct TypeInfo emission has been moved to the codegen/glue layer - whenever the symbol is needed during codegen (so no CTFE usages, or usages in purely speculative contexts), it is emitted into the referencing object file (as a COMDAT, so that the linker folds duplicates across object files), instead of trying to decide whether to add a TypeInfoDeclaration to module members in the frontend, with brittle isSpeculativeType() (unused by LDC) logic etc.
LDC emits the special TypeInfo member functions (xopEquals, xopCmp, xtoHash) into the object file containing the struct declaration, so that those are guaranteed to be available. Only the TypeInfo_Struct symbol is lazily emitted into every referencing object file.
@RazvanN7: Okay, I finally found some time and motivation to dustmite our problem, filing an issue and updating this PR accordingly.
[just rebased onto stable to make this part of D v2.110; I was on vacation and missed the merge window]