Code links in debug mode but not in release

ob_seven
Posts: 12
Joined: Tue Sep 12, 2023 12:29 pm

Code links in debug mode but not in release

Postby ob_seven » Sat Feb 22, 2025 1:38 am

Hi,

I tried to search on the forum but could not find the info.
I wrote a code for the esp32d that works well in debug mode. I try to compile in release mode and I get an error message about iram overflow. I was always thinking that a code for debug was always bigger than a release one… ? There might be different flags for optimization , and I read o2 is the fastest, but maybe gives a larger code. Any hint appreciated. Thanks

ob_seven
Posts: 12
Joined: Tue Sep 12, 2023 12:29 pm

Re: Code links in debug mode but not in release

Postby ob_seven » Sat Feb 22, 2025 7:30 am

To be more precise I compile the code using vscode and pkatformio. In platformio.ini you have a flag for build_type and I either set it to debug and the code links and runs or release and then I get a linker error with iram overflow.
This seems redundant with menu config where we can also select the code optimization. I will try menu config to see whether or not I get the same result.

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Code links in debug mode but not in release

Postby MicroController » Sat Feb 22, 2025 9:47 am

.I was always thinking that a code for debug was always bigger than a release one… ?
It often is. However, there are also opposite effects. For instance, in release/performance-optimizing mode, (more) inlining of function calls takes place, which can increase the size of the calling functions.
The increased use of IRAM you observe may also indicate that some IRAM code makes calls to non-IRAM code which becomes IRAM code only through inlining.
Also, some code may conditionally put itself into IRAM for performance if optimizing for speed.

You can try to optimize for code size (-Os) instead of speed (-O2) and see if that makes a difference.

ob_seven
Posts: 12
Joined: Tue Sep 12, 2023 12:29 pm

Re: Code links in debug mode but not in release

Postby ob_seven » Sat Feb 22, 2025 10:18 am

Hi again

If I go in menuconfig, and selects the o2 directive for the compiler it does compile and link.

If I go in platformio.ini and write build_type=debug it compiles and link. If I write build_type=release it compiles but linker fails with iram overflow.

I suspect the linker script generated is different but I need to check the details. Devil is always in the details .

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot], PerplexityBot, Semrush [Bot], Sprite and 6 guests