Unverified Commit 0550fe75 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Massively reduce generated code and RAM size (#137)

Older builds included C++ locale information in RAM/flash as well as a
bunch of exception code which can't get called since they're not enabled.

Remove them by adjusting final link command and not instantiating them
in main.cpp in the first place.

Blink went from:
> Sketch uses 215604 bytes (10%) of program storage space. Maximum is 2093056 bytes.
> Global variables use 18152 bytes (6%) of dynamic memory, leaving 243992 bytes for local variables. Maximum is 262144 bytes.

To:
> Sketch uses 56112 bytes (5%) of program storage space. Maximum is 1044480 bytes.
> Global variables use 12152 bytes (4%) of dynamic memory, leaving 249992 bytes for local variables. Maximum is 262144 bytes.

For a savings of **155KB of flash** and **6KB of RAM**
parent ef602491
......@@ -104,7 +104,6 @@ extern "C" int main() {
#include <errno.h>
#include <_syslist.h>
#include <sys/times.h>
#include <bits/stdc++.h>
#undef errno
......
......@@ -106,7 +106,7 @@ recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compil
## Combine gc-sections, archives, and objects
recipe.hooks.linking.prelink.1.pattern="{runtime.tools.pqt-python3.path}/python3" "{runtime.platform.path}/tools/simplesub.py" --input "{runtime.platform.path}/lib/memmap_default.ld" --out "{build.path}/memmap_default.ld" --sub __FLASH_LENGTH__ {build.flash_length} --sub __EEPROM_START__ {build.eeprom_start} --sub __FS_START__ {build.fs_start} --sub __FS_END__ {build.fs_end}
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "{runtime.platform.path}/lib/libpico.a" -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "-Wl,--script={build.path}/memmap_default.ld" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nosys.specs -Wl,--as-needed -Wl,--start-group {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" -Wl,--whole-archive "{runtime.platform.path}/lib/libpico.a" -Wl,--no-whole-archive -lm "-I{runtime.platform.path}/pico-sdk/src/rp2040/hardware_regs/include/" "-I{runtime.platform.path}/pico-sdk/src/common/pico_binary_info/include" "{runtime.platform.path}/assembly/{build.boot2}.S" -lc -lstdc++ -Wl,--end-group
## Create output (UF2 file)
recipe.objcopy.uf2.pattern="{runtime.tools.pqt-elf2uf2.path}/elf2uf2" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.uf2"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment