[SAoC] "Druntime for Microcontrollers" project thread

Denis Feklushkin feklushkin.denis at gmail.com
Fri Oct 2 00:30:32 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.

Use --flto=full or --flto=thin AND call linker with this option 
too.

Also do not forgot to use -Oz option with ldc2, it also reduces 
binary size.

>
>> 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.

As I said above, middle-class MCU typically have ability to 
support external memory ICs (both ROM and RAM). This memory will 
be transparently mapped into MCU address space.

For QEMU you only need to set -m option and also change linker 
script to support these amount of memory. For example, I use 
Cortex M3 "netduino2" device with script like:

[...]
MEMORY
{
  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 10M /* <----- look 
here! */
  rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
}
[...]



More information about the Digitalmars-d mailing list