[SAoC] "Druntime for Microcontrollers" project thread

IGotD- nise at nise.com
Wed Sep 30 17:36:27 UTC 2020


On Wednesday, 30 September 2020 at 16:51:46 UTC, Severin Teona 
wrote:
> On Monday, 14 September 2020 at 09:11:07 UTC, Denis Feklushkin 
> wrote:
>
>> Link Time Optimization (LTO) is available in LLVM-based ldc2 
>> and can dramatically (2-3 times!) decrease .text size.
>
> Hi again Denis. I have a quick question about this. Is there a 
> special way in which I should compile the runtime? For me 
> personally it didn't do much - from 2.8MB to 2.5MB.
>
>> QEMU have -m option to add slightly more memory into emulated 
>> Cortex M3 devices - can be useful to fit all druntime tests.
>
> Also, could you give more details about this? I have only found 
> a few Cortex-M devices that could be emulated, but none of them 
> had the resources I needed. The biggest was with 64KB of RAM 
> and 256KB of flash.
>
> Thank you!

Yes, this is a problem. For each module you import and just use 
one function in it you get a lot of extra code that you don't 
use. Usually you use --function-sections (LDC2) in order make it 
possible for the linker to remove unused functions. However this 
doesn't do much difference at all which is strange. Same flag in 
C++ does a difference indeed.

To be honest, I think that 64KB RAM, 256KB flash is betterC 
territory, unfortunately. However, regardless of that we should 
be able to clean up the binary so that no unnecessary code is 
ending up in the binary.

This is a question to the LDC maintainers, if --function-sections 
really does what it is supposed to do.



More information about the Digitalmars-d mailing list