# Changing Compiler Optimizations Had No Affect

**URL:** <https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181>\
**Category:** UNO R4 WiFi\
**Created:** [July 20, 2023, 10:33pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181 "2023-07-20T22:33:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Merlin513](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Merlin513](https://forum.arduino.cc/u/Merlin513)\
**Post date:** [July 20, 2023, 10:33pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/1 "2023-07-20T22:33:07Z")

</div>

While doing coremark comparisons (which I reported in post [Coremark Comparision - UNO R4 / UNO R4 WiFi - Arduino Forum](https://forum.arduino.cc/t/coremark-comparision/1150010/3) I tried to run the coremark with the default -Os and -O2 by changing -Os in platforms.txt to -O2 but it appears it has no affect on performance as with other boards I tested:

```arduino
Uno R4 WiFi (48Mhz, -0s) - 81.81
Uno R4 WiFi (48Mhz, -02) - 81.81
UnoR4 Minima (-02) - 106.75
UnoR4 Minima (-0s) - 106.75

```

No change. Yes I verifed that it actually changed by looking at verbose compilation and I also restarted the IDE between changes.

Changing from -Os to -O2 with other boards show a big difference:

```arduino
Teensy 3.2 (48Mhz -0s) - 86.23
Teensy 3.2 (48Mhz -02) - 116.07
Feather M0 (48Mhz -0s) - 48.61
Feather M0 (48Mhz -02) - 83.85
CH32V307 Eval(48Mhz -0s) - 91.80
CH32V307 Eval(48Mhz -02) - 116.52

```

What am I missing or is it not possible to change optimization level?

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 20, 2023, 10:39pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/2 "2023-07-20T22:39:50Z")

</div>

Why did you create a new topic regarding the almost same subject? It is a violation of the forum rules.

---

<div class="post-metadata">

**Author:** ![Merlin513](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Merlin513](https://forum.arduino.cc/u/Merlin513)\
**Post date:** [July 20, 2023, 10:42pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/3 "2023-07-20T22:42:08Z")

</div>

> [@b707](#):
>
> y did you create a new topic regarding the almost same subject? It is a violation of the forum

The other thread was regarding Coremark comparisons. This is specific to the issue regarding changing Compiler Optimizations. If I were to create an issue it would be for this not for Coremark Comparisons. I don't believe its incorrect to zero in on the actual issue.

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 20, 2023, 11:56am UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/4 "2023-07-20T11:56:58Z")

</div>

> [@Coremark Comparision](https://forum.arduino.cc/t/coremark-comparision/1150010/1):
>
> maybe NOT - changed the build flag manually and got exactly the same performance???

It is a very strange result.  
Are you sure the option really changed? Check in the output of the arduino IDE - the compilation line with all the options is visible there

---

<div class="post-metadata">

**Author:** ![Merlin513](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Merlin513](https://forum.arduino.cc/u/Merlin513)\
**Post date:** [July 20, 2023, 12:15pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/5 "2023-07-20T12:15:17Z")

</div>

> [@b707](#):
>
> It is a very strange result.  
> Are you sure the option really changed? Check in the output of the arduino IDE - the compilation line with all the options is visible there

Just checked and looks like it changed:

```arduino
"C:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/ **arm-none-eabi-g++" -c -w -O2** -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=48000000 -DNO_USB -DBACKTRACE_SUPPORT -DARDUINO_UNOR4_WIFI -std=gnu++17 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 "-DPROJECT_NAME=\"C:\\Users\\Merli\\AppData\\Local\\Temp\\arduino\\sketches\\B2F7226DA9EDA29A3DA9FBF498BD045B/CoreMark.ino\"" -DARDUINO_UNOWIFIR4 -DARDUINO_ARCH_RENESAS_UNO -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE -mthumb "@C:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4/defines.txt" -DCFG_TUSB_MCU=OPT_MCU_RAXXX "-IC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2/cores/arduino/tinyusb" "-IC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino/api/deprecated" "-IC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino/api/deprecated-avr-comp" "-IC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino" "-IC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4" "-iprefixC:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2" "@C:\\Users\\Merli\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4/includes.txt" "C:\\Users\\Merli\\AppData\\Local\\Temp\\arduino\\sketches\\B2F7226DA9EDA29A3DA9FBF498BD045B\\sketch\\CoreMark.ino.cpp" -o nul

```

Checked the other lines as well but didn't want to clutter the message. There are a bunch of other lines that show 0s has be changed to O2

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [July 20, 2023, 11:24pm UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/6 "2023-07-20T23:24:40Z")

</div>

> [@Merlin513](#):
>
> The other thread was regarding Coremark comparisons. This is specific to the issue regarding changing Compiler Optimizations.

Except that you made the other thread about compiler optimizations as well.

It is OK to make separate forum topics for discrete aspects of general subject. However, you must keep the two topics discrete, which you failed to do from the start.

Even when the topics start out on discrete subjects, they have a tendency to converge to parallel discussion over time. Parallel discussions are harmful because they waste the time of the helpers who unknowingly duplicate the previous efforts from the other topic. For this reason, you must manage the scope of the discussion to prevent this from happening. If discussion starts to stray into the territory of the other topic, then redirect the participants over to the other to continue that discussion.

I moved all the discussion about the effect of changing compiler optimization flags to this topic. From here on, the other topic will be used exclusively for discussing the CoreMark results with the stock compilation patterns and this topic used exclusively for discussing the apparent lack of effect from changing compiler optimization flags.

If I see more convergence then I'll have to merge the two topics.

---

<div class="post-metadata">

**Author:** ![Merlin513](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Merlin513](https://forum.arduino.cc/u/Merlin513)\
**Post date:** [July 21, 2023, 7:15am UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/7 "2023-07-21T07:15:03Z")

</div>

Yes Principal. **Please close this topic.** Probably should have been a Github issue anyway. If I get inspired to do anything more with these boards I will report any issues via Github right now lost interest in these boards.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [July 21, 2023, 7:15am UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/8 "2023-07-21T07:15:59Z")

</div>

Closed on July 21, 2023, 7:15am UTC



---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [July 23, 2023, 12:08am UTC](https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/9 "2023-07-23T00:08:57Z")

</div>

In order to make all relevant information available to any who are interested in this subject, I'll share a link to the GitHub issue here:

> <https://github.com/arduino/ArduinoCore-renesas/issues/63>
>
> In platforms.txt I changed the optimization level from -Os to -O2 and appears to… have no affect performance. Using a coremark sketch that I used before the issue becomes apparent. See this post: https://forum.arduino.cc/t/changing-compiler-optimizations-had-no-affect/1150181/4. In summary:
> 
> \`\`\`
> Uno R4 WiFi (48Mhz, -0s) - 81.81
> Uno R4 WiFi (48Mhz, -02) - 81.81
> UnoR4 Minima (-02) - 106.75
> UnoR4 Minima (-0s) - 106.75
> \`\`\`
> but when I change it for other boards:
> \`\`\`
> Teensy 3.2 (48Mhz -0s) - 86.23
> Teensy 3.2 (48Mhz -02) - 116.07
> Feather M0 (48Mhz -0s) - 48.61
> Feather M0 (48Mhz -02) - 83.85
> CH32V307 Eval(48Mhz -0s) - 91.80
> CH32V307 Eval(48Mhz -02) - 116.52
> \`\`\`
> it appears to make a difference. Is there something I am missing or can this be related to the micros issue. From what I saw the time is calculated from using millis()
> 
> REF: https://github.com/PaulStoffregen/CoreMark
