Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Arduino IDE v2 - add Debug Flags, Compiler Warnings, and Compiler Optimizations

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    3

    Arduino IDE v2 - add Debug Flags, Compiler Warnings, and Compiler Optimizations

    I've seen a Teensy developer having problems with warnings stopping their compile sessions trying to move from Arduino v1.8.x to Arduino IDE v2.0.3.
    While I added in-circuit debugging to the STM32 platform for IDE v2, I started working on getting OpenOCD working with the ESP32 and added those features to the Tools menu for the espressif ESP32. It's not very difficult to add this and it improves the developer experience considerably having control of the compiler and compiler output.

    example of changes to boards.txt:

    menu.DebugLevel=Core Debug Level
    menu.Debugging=Compiler Debug Levels
    menu.opt=Optimize

    teensy40.menu.DebugLevel.none=None
    teensy40.menu.DebugLevel.none.build.code_debug=0
    teensy40.menu.DebugLevel.error=Error
    teensy40.menu.DebugLevel.error.build.code_debug=1
    teensy40.menu.DebugLevel.warn=Warn
    teensy40.menu.DebugLevel.warn.build.code_debug=2
    teensy40.menu.DebugLevel.info=Info
    teensy40.menu.DebugLevel.info.build.code_debug=3
    teensy40.menu.DebugLevel.debug=Debug
    teensy40.menu.DebugLevel.debug.build.code_debug=4
    teensy40.menu.DebugLevel.verbose=Verbose
    teensy40.menu.DebugLevel.verbose.build.code_debug= 5

    teensy40.menu.Debugging.none=None
    teensy40.menu.Debugging.enable_sym=Symbols Enabled (-g)
    teensy40.menu.Debugging.enable_sym.build.flags.deb ug=-g -DNDEBUG
    teensy40.menu.Debugging.enable_log=Core logs Enabled
    teensy40.menu.Debugging.enable_log.build.flags.deb ug=
    teensy40.menu.Debugging.enable_all=Core Logs and Symbols Enabled (-g)
    teensy40.menu.Debugging.enable_all.build.flags.deb ug=-g

    teensy40.menu.opt.osstd=Smallest (-Os default)
    teensy40.menu.opt.osltd.build.flags.optimize=-Os
    teensy40.menu.opt.oslto=Smallest (-Os) with LTO
    teensy40.menu.opt.oslto.build.flags.optimize=-Os -flto
    teensy40.menu.opt.o1std=Fast (-O1)
    teensy40.menu.opt.o1std.build.flags.optimize=-O1
    teensy40.menu.opt.o1lto=Fast (-O1) with LTO
    teensy40.menu.opt.o1lto.build.flags.optimize=-O1 -flto
    teensy40.menu.opt.o2std=Faster (-O2)
    teensy40.menu.opt.o2std.build.flags.optimize=-O2
    teensy40.menu.opt.o2lto=Faster (-O2) with LTO
    teensy40.menu.opt.o2lto.build.flags.optimize=-O2 -flto
    teensy40.menu.opt.o3std=Fastest (-O3)
    teensy40.menu.opt.o3std.build.flags.optimize=-O3
    teensy40.menu.opt.o3lto=Fastest (-O3) with LTO
    teensy40.menu.opt.o3lto.build.flags.optimize=-O3 -flto
    teensy40.menu.opt.ogstd=Debug (-Og)
    teensy40.menu.opt.ogstd.build.flags.optimize=-Og
    teensy40.menu.opt.o0std=No Optimization (-O0)
    teensy40.menu.opt.o0std.build.flags.optimize=-O0


    and example of using those flags in platform.txt( note build.lfags.optimize, build.flags.debug )
    compiler.c.flags.teensy40=-mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb {build.flags.optimize} {build.flags.debug} -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c

    # Defaults config
    build.flags.optimize=-Os
    build.flags.debug=-DNDEBUG

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,804
    Note: The IDE already has the preferences settings for warning levels.

    Click image for larger version. 

Name:	Screenshot.jpg 
Views:	38 
Size:	34.6 KB 
ID:	30238

    It is just that the Teensy install does not use them. Possible changes and the like mentioned over in the Arduino forum in the post:
    https://forum.arduino.cc/t/compiler-...ssed/1082129/8

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    Quote Originally Posted by KurtE View Post
    Note: The IDE already has the preferences settings for warning levels.

    Click image for larger version. 

Name:	Screenshot.jpg 
Views:	38 
Size:	34.6 KB 
ID:	30238

    It is just that the Teensy install does not use them. Possible changes and the like mentioned over in the Arduino forum in the post:
    https://forum.arduino.cc/t/compiler-...ssed/1082129/8
    And this is exactly the reason why I'm trying to hammer it through the Arduino devs to promote these in the Tools menu and promote board vendors implement them.
    It's really easy to do but the Arduino people need to promote it so vendors do it.

    Putting compiler switch in the IDE Pref dialog is not the way to do it since board vendors control how their products are compiled and therefore the compiler, debugger, and even the linker should be controlled in the Tools menu.

    Consistency is what makes things like this easy for everyone. $0.02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •