Setting default_library to 'small' in mbed_app.json

I can create a custom target and change the library setting to ‘small’ to use newlib nano. I know it is only safe when the RTOS is not used, but this already possible with the bare-metal option. In this case, the newlib nano will also save about 30 kB of flash size.
I think it makes more sense to set this option per app in mbed_app.json, but with the existing options it did not work. Is there a way to change this setting in mbed_app.json?

Hi Johannes,

I use below configuration in mbed_app.json

{
    "requires": ["bare-metal"],
    "target_overrides": {
        "*": {
            "target.default_lib": "small"
        }
    }
}

And build mbed-os-example-blinky-baremetal on K64F, it saves about 24KBs, could you elaborate what doesn’t work in your environment?

Regards,
Desmond

Thanks Desmond,
your solution is working. I had tried “default_lib”: “small”, that was not accepted. But with target.default_lib it does.

Is this similar to my question here?

https://forums.mbed.com/t/re-how-to-change-compiler-from-arm-std-to-arm-micro-toolchains/6344

I tried the “target.default_lib”: “small” on a couple of targets but did not see any size change on the Flash output file?
Also would this work when using the online compiler?

I’m not sure if this setting should work with Keil, it looks like the settings are different for the toolchains. For gcc-arm, it works and with ‘small’ the newlib nano is used. For the ARM compiler, the uARM toolchain is selected and also using the leaner library.
There is a Youtube video with some interesting information:


As far as I understand, this setting will be refurbished und unified.

see also: