-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excessive use of BSS by certain static objects #283
Comments
you build with Arduino IDE or Arduino CLI? (not with platformio or Sloeber) |
|
Double checked and it's true indeed 🤔 The issue was once "bypassed" by moving every instance to their own file (so they become independent compilation units and the linker can strip the unused bits). diff --git a/platform.txt b/platform.txt
index 22e6cae7..05be7cb0 100644
--- a/platform.txt
+++ b/platform.txt
@@ -20,13 +20,13 @@ compiler.optimization_flags.debug=-Og
compiler.path={build.compiler_path}
compiler.c.cmd={build.crossprefix}gcc
-compiler.c.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
+compiler.c.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -flto -fuse-linker-plugin
compiler.c.elf.cmd={build.crossprefix}g++
-compiler.c.elf.flags=-Wl,--gc-sections --specs=nosys.specs {compiler.warning_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu}
+compiler.c.elf.flags=-Wl,--gc-sections --specs=nosys.specs {compiler.warning_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu} -flto
compiler.S.cmd={build.crossprefix}g++
compiler.S.flags=-c -g -x assembler-with-cpp {compiler.optimization_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections
compiler.cpp.cmd={build.crossprefix}g++
-compiler.cpp.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
+compiler.cpp.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -flto -fuse-linker-plugin
compiler.ar.cmd={build.crossprefix}ar
compiler.ar.flags=rcs
compiler.ar.extra_flags= removes the unused objects but it could have side effects. I'm checking now why the original optimization doesn't work anymore... |
Core version: 1.1.0
Variant: UNO R4 WIFI
Let's take this simple sketch and built it for UNO R4 Wi-Fi target:
These are the static objects of the sketch that consume most of RAM space:
2 of 3 UARTs are not in use by the sketch itself but they consume 1+ KByte each.
When we execute the sketch - it makes a report of free heap available:
Let's alter the sketch by adding
#include <Wire.h>
line:We can see now that 2 more (
Wire
andWire1
) objects consume 1+ Kbyte of RAM each. Both of these objects are actually not in use by the sketch.Let's execute the sketch as well:
We can see that this 'hello world' kind of sketch consumes 9 KBytes out of 32 KBytes RAM available in the Renesas RA4M1 MCU.
Let's build and execute the sketch on Arduino Zero/M0 (SAMD21) target:
There are the results when
Wire.h
is not included:And this one is taken with
Wire.h
:Summary
Both RA4M1 and SAMD21 have 32 Kbytes of RAM available.
However, the Arduino Core for Renesas MCUs consumes a lot more RAM space for unused static objects rather than Arduino Core for SAMD does.
The text was updated successfully, but these errors were encountered: