-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Issue 12146 - Linker error with __xopCmp, __xopEq, TypeInfo #3255
Conversation
|
@9rnsr can you have a look at this? |
|
No, the root cause is that semantic3 is not run for On the other hand, |
- The root cause for this bug was, that the TypeInfo for structs can only be generated after semantic3 for that struct was run. This is not possible if the TypeInfo is needed during the obj generation pass, e.g. because it is referenced by an array TypeInfo. - Fixed by eagerly emitting TypeInfo for structs, this is similar to TypeInfos for classes.
I could not use deferred semantic3, because the TypeInfo for the struct was only needed during obj file generation. |
|
If the type info is only generated with the struct declaration, you will have to compile deimos modules to a library and not be able to use them as "header" files only. |
|
I think you're right, but we should think about it thoroughly. |
|
IMO we should only weakly link against TypeInfo. Then if it isn't defined as in the Deimos case you'll get a null reference. I really don't see why we would generate RTTI for imported types. |
|
I'm not sure what this is showing? That the error message for typeid of an undefined struct is misleading? |
That won't work. You need it for example if you create an dynamic array of a struct type declared in deimos. It should be fine if the struct definition outputs another COMDAT if the containing module is compiled. We just have to guarantee that only one instance is generated in into the object file. Optlink accepts that, but the MS linker does not. |
|
I think we can solve this, when a struct doesn't require linkage, we already know it's TypeInfo (no eq, cmp, hash, whatsoever), no init {all zero), no rtInfo, just it's size and maybe the name. |
|
You must not generate a "false" type info, because if a different module requires and generates the full type info, the linker will pick any of the generated COMDATs, and it could be the "false" version. With the precise GC, any TypeInfo needs RTInfo, so the minimal TypeInfo will never be good enough. |
|
Full TypeInfo would not be a COMDAT but global.
One could regress to conservative scanning though, but that's not optimal of course. |
I suspect that some linker will complain if both exist for the same symbol.
That's a bug, not a feature.
That's actually done in the precise GC with the current fallback in the compiler to generate 0/1 instead of proper RTInfo. But that doesn't help if you want other stuff in RTInfo aswell.
Calling runtime function, e.g. for array appending and comparing, also needs type info, and just the size isn't always enough. |
They are zero initialized and don't implement any x... function, so everything required is already known. |
Why and which linker? It's very common to define weak fallbacks that are optionally replaced with a strong symbol. |
The MS linker for example: |
The
That not a COMDAT, right? How about this instead? pragma(mangle, "fun") void fun(T)() {}
alias funi = fun!int; |
I checked with dumpbin, it is a COMDAT. |
|
Weird that it's a COMDAT. |
|
@MartinNowak optlink has problems with weak definitions, I'd rather avoid them at the moment. |
for structs can only be generated after semantic3 for
that struct was run. This is not possible if the TypeInfo
is needed during the obj generation pass, e.g. because
it is referenced by an array TypeInfo.
this is similar to TypeInfos for classes.