Where is TypeInfo_Class.m_init set

Hakan Aras hakan.aras at live.at
Thu Aug 2 02:52:44 UTC 2018


On Tuesday, 31 July 2018 at 20:45:11 UTC, kinke wrote:
> Sorry, scratch that, I forgot the `extern` before the dummy 
> global. After fixing that, I didn't quickly find a solution for 
> referencing the symbol in the .data.rel.ro section (LLVM asm, 
> e.g., `void* getInit() { return __asm!(void*)("movq 
> test.C.__init, %rax", "={rax}"); }` doesn't work either).
>
> The compiler could emit the init symbol as regular global for 
> `-betterC` though.
>
> ---
>
> This issue could also be tackled in the D ctor of the 
> extern(C++) class, by injecting the blit before the actual ctor 
> body. C++ code wouldn't have to take care about that D-interop 
> incompatibility anymore (independent of -betterC).

I looked into that approach a little and it was pretty 
successful, at least for DMD:

https://run.dlang.io/is/KDHoI9

LDC complains about the type of initializer though:

onlineapp.d(22): Error: Global variable type does not match 
previous declaration with same mangled name: _D5bclib3Baz6__initZ
onlineapp.d(22):        Previous IR type: %bclib.Baz = type { [1 
x i8*]*, i32 }
onlineapp.d(22):        New IR type:      %bclib.BazInitializer = 
type { [1 x i8*]*, i32, [4 x i8] }


Any ideas on how to match the type exactly? I don't quite 
understand why there are 4 bytes at the back of BazInitializer.


More information about the Digitalmars-d-learn mailing list