<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: GCC Optimization Level broken by core_cm7.h in SDK 2.10 in i.MX RT Crossover MCUs</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354441#M16683</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 21:15:05 GMT</pubDate>
    <dc:creator>steve_n</dc:creator>
    <dc:date>2021-10-12T21:15:05Z</dc:date>
    <item>
      <title>GCC Optimization Level broken by core_cm7.h in SDK 2.10</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1352706#M16625</link>
      <description>&lt;P&gt;In mcuXpresso SDK 2.10 for the i.MX-RT 1064, the CMSIS file core_cm7.h, causes an issue with optimization level. This is testable in mcuXpresso IDE 11.4.&lt;/P&gt;&lt;P&gt;To test, simply create a hello_world project with SDK 2.10 in IDE 11.4. Set the project optimization level to "&lt;FONT face="courier new,courier"&gt;O0&lt;/FONT&gt;".&lt;/P&gt;&lt;P&gt;In &lt;FONT face="courier new,courier"&gt;main()&lt;/FONT&gt;, define a local variable but do not reference it anywhere (i.e.&lt;FONT face="courier new,courier"&gt; int test_o_level = 1;&lt;/FONT&gt;) In &lt;FONT face="courier new,courier"&gt;Og&lt;/FONT&gt; this variable will be optimized out, in &lt;FONT face="courier new,courier"&gt;O0&lt;/FONT&gt; it will not be. The variable is always optimized out even when the project setting is at &lt;FONT face="courier new,courier"&gt;O0&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;This because of an issue core_cm7.h. Around line 2320, the &lt;FONT face="courier new,courier"&gt;SCB_&lt;/FONT&gt; cache functions are defined, which are surrounded by &lt;FONT face="courier new,courier"&gt;GCC pragmas&lt;/FONT&gt; to temporarily change the optimization level to "&lt;FONT face="courier new,courier"&gt;Og&lt;/FONT&gt;".&lt;/P&gt;&lt;PRE&gt;/*&lt;BR /&gt;* Optimize the Data Cache functions, for the endless loop issue.&lt;BR /&gt;* More details, see https://github.com/ARM-software/CMSIS_5/issues/620&lt;BR /&gt;*/&lt;BR /&gt;#if (defined(__GNUC__) &amp;amp;&amp;amp; !defined(__OPTIMIZE__))&lt;BR /&gt;#pragma GCC push_options&lt;BR /&gt;#pragma GCC optimize ("Og")&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;... CACHE FUNCTIONS HERE ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#if (defined(__GNUC__) &amp;amp;&amp;amp; !defined(__OPTIMIZE__))&lt;BR /&gt;#pragma GCC pop_options&lt;BR /&gt;#endif&lt;/PRE&gt;&lt;P&gt;This &lt;EM&gt;looks&lt;/EM&gt; like 100% valid GCC pragmas to set and then restore the optimization level to me. Except, it doesn't actually work. (FYI - that github link relates to an issue that required the Og level in the first place - but that is ostensibly a different bug.)&lt;/P&gt;&lt;P&gt;I prefer to debug with "&lt;FONT face="courier new,courier"&gt;O0&lt;/FONT&gt;" level. For some reason, the "&lt;FONT face="courier new,courier"&gt;Og&lt;/FONT&gt;" level set by core_cm7.h is not properly popped, and the "&lt;FONT face="courier new,courier"&gt;O0&lt;/FONT&gt;" level set via the command line is not restored. This effectively forces "&lt;FONT face="courier new,courier"&gt;Og&lt;/FONT&gt;" on my whole project.&lt;/P&gt;&lt;P&gt;Adding this to core_cm7.h (after &lt;FONT face="courier new,courier"&gt;#pragma GCC pop_options&lt;/FONT&gt;) works to properly restore the level:&lt;/P&gt;&lt;PRE&gt;#pragma GCC reset_options&lt;/PRE&gt;&lt;P&gt;I found no other way to fix it. This looks like a GCC bug. However, since this impacts the SDK I think you should provide a workaround in the SDK includes.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 13:23:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1352706#M16625</guid>
      <dc:creator>steve_n</dc:creator>
      <dc:date>2021-10-08T13:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: GCC Optimization Level broken by core_cm7.h in SDK 2.10</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1352761#M16629</link>
      <description>&lt;P&gt;Of course I figure this out right after my initial post...&lt;/P&gt;&lt;P&gt;The issue is the !defined(__OPTIMIZE__) qualifier of the #if.&lt;/P&gt;&lt;P&gt;The first set of pragmas that pushes on a new set of optimization options works. In doing so, it defines __OPTIMIZE__ as part of the process!&lt;/P&gt;&lt;P&gt;Therefore, the second half never gets run, to pop off the "Og" option.&lt;/P&gt;&lt;PRE&gt;#if (defined(__GNUC__) &amp;amp;&amp;amp; !defined(__OPTIMIZE__))&lt;BR /&gt;#pragma GCC pop_options&lt;BR /&gt;#endi&lt;/PRE&gt;&lt;P&gt;Once "Og" is set, __OPTIMIZE__ is defined.&lt;/P&gt;&lt;P&gt;So, this is not a GCC bug, it is a CMSIS issue.&lt;/P&gt;&lt;P&gt;EDIT: From what I can tell, the extra pragmas were added by NXP and they are not a part of the native CMSIS.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 14:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1352761#M16629</guid>
      <dc:creator>steve_n</dc:creator>
      <dc:date>2021-10-08T14:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: GCC Optimization Level broken by core_cm7.h in SDK 2.10</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354270#M16677</link>
      <description>&lt;P&gt;Would someone from NXP care to comment on this?&lt;/P&gt;&lt;P&gt;The file core_cm7.h breaks the optimization level setting - will this be addressed in future releases?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 13:22:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354270#M16677</guid>
      <dc:creator>steve_n</dc:creator>
      <dc:date>2021-10-12T13:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: GCC Optimization Level broken by core_cm7.h in SDK 2.10</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354399#M16682</link>
      <description>&lt;P&gt;Hello steve_n,&lt;/P&gt;
&lt;P&gt;I will escalate this to the SDK team, thank you for pointing out this issue!&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Gustavo&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 18:58:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354399#M16682</guid>
      <dc:creator>gusarambula</dc:creator>
      <dc:date>2021-10-12T18:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: GCC Optimization Level broken by core_cm7.h in SDK 2.10</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354441#M16683</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 21:15:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/GCC-Optimization-Level-broken-by-core-cm7-h-in-SDK-2-10/m-p/1354441#M16683</guid>
      <dc:creator>steve_n</dc:creator>
      <dc:date>2021-10-12T21:15:05Z</dc:date>
    </item>
  </channel>
</rss>

