Linker-hacking out the D runtime

Iain Buclaw via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Jan 8 14:14:36 PST 2017


On 20 December 2016 at 12:24, Mike via Digitalmars-d-announce
<digitalmars-d-announce at puremagic.com> wrote:
> On Monday, 19 December 2016 at 19:53:06 UTC, Iain Buclaw wrote:
>
>> The compiler doesn't actually generate any code that peeks inside
>> TypeInfo.  It only generates the reference to the right typeinfo to pass to
>> library runtime functions -  or on request via typeid().  It doesn't
>> actually care about the data stored inside.  And that's the angle I've taken
>> when laying out the actual data - if you provide the fields we want to
>> populate, then we'll populate them.  If you omit a few, then the compiler
>> won't bother with them.  Because at the end of the day, it's druntime
>> library that uses and makes sense of the TypeInfo data provided.  The
>> compile just says: "Well, this is as much as I'm willing to tell you about
>> the type."
>
>
> Ok, that's interesting, but what if you don't want TypeInfo at all?  Can you
> omit the TypeInfo structure entirely from object.d?  Or perhaps you still
> need to declare it in object.d, but since the compiler doesn't find any
> fields to populate, it results in an empty struct?  I'd really hate to have
> to add empty TypeInfo_XXX classes to my object.d though.
>

Yeah, there are two logical steps that need ratifying.

1) -fno-rtti should be a flag that is honoured by the compiler.
2) Runtime functions that "lower" to a C function call should not
generate RTTI if all information about the type is known at
compile-time.

There are ideas floating around to improve [2], but for the time being
however, marking all functions as @nogc catches almost all cases where
this happens.


More information about the Digitalmars-d-announce mailing list