Skip to content
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

Optimize for Debugging compiles with -0s #230

Closed
3 tasks done
zfields opened this issue Jan 5, 2024 · 6 comments · Fixed by #238
Closed
3 tasks done

Optimize for Debugging compiles with -0s #230

zfields opened this issue Jan 5, 2024 · 6 comments · Fixed by #238
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@zfields
Copy link

zfields commented Jan 5, 2024

Describe the problem

When I select "Optimize for Debugging" in the "Sketch" menu, it introduces the -g3 flag, which is great, but it also leaves -Os (optimize for size).

image

Normally debug binaries are compiled with -O0 or -Og, to prevent variables or instructions from being optimized away. This allows the executed instructions to resemble the code as much as possible and facilitates debugging.

FQBN: arduino:renesas_portenta:portenta_c33
Using board 'portenta_c33' from platform in folder: /home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5
Using core 'arduino' from platform in folder: /home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5

Detecting libraries used...
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=200000000 -std=gnu++17 -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 -DPROJECT_NAME="/tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino" -DARDUINO_PORTENTA_C33 -DARDUINO_ARCH_RENESAS_PORTENTA -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/defines.txt -DLWIP_DNS=1 -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/tinyusb -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated-avr-comp -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33 -iprefix/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5 @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/includes.txt /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/sketch/BlinkDebug.ino.cpp -o /dev/null
Generating function prototypes...
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=200000000 -std=gnu++17 -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 -DPROJECT_NAME="/tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino" -DARDUINO_PORTENTA_C33 -DARDUINO_ARCH_RENESAS_PORTENTA -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/defines.txt -DLWIP_DNS=1 -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/tinyusb -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated-avr-comp -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33 -iprefix/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5 @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/includes.txt /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/sketch/BlinkDebug.ino.cpp -o /tmp/3961272034/sketch_merged.cpp
/home/zak/.arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/3961272034/sketch_merged.cpp
Compiling sketch...
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -Wall -Wextra -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib -DF_CPU=200000000 -MMD -std=gnu++17 -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -DARDUINO=10607 "-DPROJECT_NAME=\"/tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino\"" -DARDUINO_PORTENTA_C33 -DARDUINO_ARCH_RENESAS_PORTENTA -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/defines.txt -DLWIP_DNS=1 -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/tinyusb -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino/api/deprecated-avr-comp -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/cores/arduino -I/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33 -iprefix/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5 @/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/includes.txt /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/sketch/BlinkDebug.ino.cpp -o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/sketch/BlinkDebug.ino.cpp.o
Compiling libraries...
Compiling core...
Using previously compiled file: /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/common_data.c.o
Using previously compiled file: /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/pin_data.c.o
Using previously compiled file: /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/main.c.o
Using previously compiled file: /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/variant.cpp.o
Using precompiled core: /tmp/arduino/cores/arduino_renesas_portenta_portenta_c33_6f630dca8d5eb29b7ef91b56c46bda6c/core.a
Linking everything together...
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -Wl,--gc-sections --specs=nosys.specs -Wall -Wextra -mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.elf -L/tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA -L/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33 -T/home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/fsp.ld /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/sketch/BlinkDebug.ino.cpp.o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/common_data.c.o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/main.c.o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/tmp_gen_c_files/pin_data.c.o /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/core/variant.cpp.o -Wl,--whole-archive -Wl,--start-group /home/zak/.arduino15/packages/arduino/hardware/renesas_portenta/1.0.5/variants/PORTENTA_C33/libs/libfsp.a /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/../../cores/arduino_renesas_portenta_portenta_c33_6f630dca8d5eb29b7ef91b56c46bda6c/core.a -Wl,--no-whole-archive -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -Wl,--end-group -Wl,-Map,/tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.map
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-objcopy -O binary -j .text -j .data /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.elf /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.bin
/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-objcopy -O ihex -j .text -j .data /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.elf /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.hex

/home/zak/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-size -A /tmp/arduino/sketches/6E18701710D06A6EAAFD2F664971D8EA/BlinkDebug.ino.elf
Sketch uses 94332 bytes (4%) of program storage space. Maximum is 2097152 bytes.
Global variables use 20720 bytes (3%) of dynamic memory, leaving 502904 bytes for local variables. Maximum is 523624 bytes.

To reproduce

Compile the Blink sketch with "Optimize for Debug" selected.

Expected behavior

I would expect to see -O0 or -Og used to compile the program.

Arduino IDE version

Version: 2.2.1 Date: 2023-08-31T14:16:33.536Z CLI Version: 0.34.0 Copyright © 2024 Arduino SA

Operating system

Linux

Operating system version

Ubuntu

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@zfields zfields added the type: imperfection Perceived defect in any part of project label Jan 5, 2024
@per1234 per1234 transferred this issue from arduino/arduino-ide Jan 5, 2024
@per1234 per1234 added the topic: code Related to content of the project itself label Jan 5, 2024
@per1234 per1234 self-assigned this Jan 5, 2024
@per1234
Copy link
Collaborator

per1234 commented Jan 5, 2024

Hi @zfields. The compiler.optimization_flags.debug property has not been configured in the "Arduino Renesas Portenta Boards". This means the Sketch > Optimize for Debugging option in Arduino IDE has no effect. The compilation will proceed as appropriate for production application regardless of the setting of that menu option.

A compiler.optimization_flags.debug property in this platform would not be directly useful to Arduino IDE users because the platform has not been configured for use with the Arduino IDE 2.x integrated sketch debugger. I suppose it might be useful for those who are using an external debugger though.

@per1234 per1234 added type: enhancement Proposed improvement and removed type: imperfection Perceived defect in any part of project labels Jan 5, 2024
@per1234 per1234 removed their assignment Jan 5, 2024
@zfields
Copy link
Author

zfields commented Jan 5, 2024

Yes, I do have an external debugger, and a semi-urgent need to debug.

As a workaround, is there a way I can manually update the settings file, so that I can enable debugging and move forward?

@zfields
Copy link
Author

zfields commented Jan 25, 2024

Thanks for getting this fix in!

How do I get access to the fix?

Is there a new version of the Renesas core I need to download, or do I need to pull the nightly build of the IDE v2.0 to get this update?

@zfields
Copy link
Author

zfields commented Jan 25, 2024

I've updated my file locally, so there is no urgency, but I'd love a more formal solution.

@aentinger
Copy link
Contributor

You'll get a new version for downloading and installing both via IDE and arduino-cli once a new version of this core is released. For reference take a look at arduino-cli core update-index and arduino-cli core upgrade, i.e.

arduino-cli core update-index
arduino-cli core upgrade arduino:renesas_uno

If/when a new core is going to be published is a question I can not answer as its subject to many internal considerations and dependencies - sorry.

@zfields
Copy link
Author

zfields commented Jan 26, 2024

Thank you for providing those resources and your candor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
3 participants