RFC: Pay-as-you-go, Portable D Runtime for Microcontrollers (and maybe more)

Adrian Matoga via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 14 12:44:47 PDT 2015


On Thursday, 11 June 2015 at 00:26:39 UTC, Mike wrote:
> On Wednesday, 10 June 2015 at 10:06:19 UTC, Adrian Matoga wrote:
>
>> Generally, if we stick to the pay-as-you-go approach most
>> features of D runtime (even exceptions and RTTI) can be ported.
>> They will not imply any costs when not used, but will be ready 
>> to
>> use out-of-the-box when they're needed.
>
> I haven't had a pay-as-you-go experience with RTTI.  In fact 
> TypeInfo has become my mortal enemy [1].  I submitted a bug 
> report for now [2].
>
> [1] TypeInfo not garbage collected (discussion) - 
> http://forum.dlang.org/post/quemhwpgijwmqtpxukiv@forum.dlang.org
> [2] TypeInfo not garbage collected (bug report) - 
> http://bugzilla.gdcproject.org/show_bug.cgi?id=184
>
> There is an implementation of an -fno-rtti switch [3], but 
> unfortunately, I have found it compromises on a few things 
> (slicing, postblit, and maybe others).  I think
> the best way forward is to move TypeInfo to the runtime as 
> described in [4].  I'm currently working on an initial pull 
> request for it, but I have to admit that I don't know much 
> about what I'm doing in the compiler and am struggling with it.
>  But I'm afraid if I don't do it, it won't happen.  I can't 
> even continue with my work without it.
>
> [3] -fno-rtti implementation - 
> https://github.com/D-Programming-GDC/GDC/pull/100
> [4] Move TypeInfo to the D Runtime - 
> https://issues.dlang.org/show_bug.cgi?id=12270

If there's anything I can help with, let me know. My experience 
with GDC is close to non-existent (I managed to make some 
one-line hacks to make it compile for AVR or to show the sizes of 
TypeInfos, but that was pretty easy), and I didn't even bother to 
build LDC, but I want to write stuff for STMs in D so I'm 
motivated to learn by doing.

>> I'll try to push this work on github later this week.
>
> I look forward to seeing it.  It's encouraging to see more 
> interest in using D for this Domain.

Here it is: https://github.com/epi/dirt
It's just a playground where I try adding different features by 
trial and error, so it's very far from being as clean and 
organized as your projects.
I wouldn't even start without your and Adam Ruppe's work, so 
thank you for that.

Apart from first steps towards formatted print and exception 
support I mentioned earlier, there's a try on running static 
constructors (which is most likely broken anyway) in the correct 
order. The machinery used to make it work wastes some text and 
data memory to do it in run time, but since we're linking 
everything statically in the end, I wonder if the linker could be 
forced to put it all together instead.


More information about the Digitalmars-d mailing list