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

Thread: Hi all and question.

  1. #1

    Hi all and question.

    Hi forum, im a new so i want to say hello.

    And second does anyone have a description and suggested usage for the optimize options, such as:

    Fast, Faster, Fastest
    LTO
    Pure Code
    Debug
    Smallest code

    etc.

    I tend to use FASTEST + pure code and LTO option as my code runs the fastest with these options, but don't like blind decisions.

    Thanks in advance!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,077
    Use File > Preferences to turn on verbose info while compiling.

    Then Arduino will show you the exact gcc commands it is using to compile your program. Most of these just change the -O optimization level. Some also add C library specs, for the reduced size printf. Arduino's console panel supports copy to clipboard, so you can copy compiler commands from different tests into a text editor to more easily see what each option changed.

    If you *really* want to dig into the details, you'll probably need to read the gcc documentation which can be found online. It's a deep rabbit hold of compiler optimization details.

  3. #3
    Senior Member
    Join Date
    Oct 2015
    Location
    Roma (IT, EU)
    Posts
    336
    Hello and welcome!

    Absolutely what Paul said, of course.

    Just a quick glimpse:

    Quote Originally Posted by congchualon View Post
    Fast, Faster, Fastest
    Different GCC optimizations levels (think -O1, -O2, -O3)

    LTO
    Turns on Link-time Optimizations.
    GCC produces additional informations to optimize stuff across the various modules which compose the final executable.
    Beware: LTO sometimes BREAKS the resulting executable, which may run oddlly or not at all.
    For example, I got issues with a few OLED libraries.

    Pure Code
    This is is not available on Teensy LC (can't remember about T4.x, can't check at the moment).
    It forces the compiler not to store read-only data in the "code" section (so it will put it in the "data" section instead).
    It should strengthen security; not sure if it helps performances too.

    Debug
    For Teensy+Arduino environment, I don't think it's useful. We don't have an integrated step debugger (unfortunately).

    Smallest code
    The compiler strives to produce the smallest possible code, even at the cost of reducing speed optimizations (i.e. loops unrolling).
    It helps when you have a Teensy model with smaller program memory (for example the LC) and/or a large program.

Posting Permissions

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