I have an application that works fine in "Debug" configuration, however when I change the configuration to "Release" the program behaves differently, what could be going on?
The following table lists the default project property differences between "Debug" and "Release" configurations:
| Debug Configuration |
Release Configuration |
|
| Build > Include Debug Information |
Yes | No |
| Compiler > Optimisation Level |
None | Level 1 |
| Preprocessor > Preprocessor Definitions |
DEBUG | NDEBUG |
The most common cause of this problem we come across is where users modify a project property during development and they make the change in "Debug" configuration only rather than the "Common" configuration so that the change only applies to the "Debug" configuration and is therefore not picked up in the "Release" configuration.
The Build > Include Debug Information project property is unlikely to make any difference - it just specifies whether or not debug information is included in the .elf file, it should not make any difference to the program that is downloaded.
The change in optimisation level can cause a program to behave differently. See Changing optimisation levels causes different application behaviour for a description of why changing the optimisation level may alter the way an application behaves.
Comments
3 comments
I am having the same problem. Even when I make the Debug and Release configurations the same, the Release behaves differently and not good. I suspect it is a problem with the keyword volatile or static. How do I observe the variables during Release? How do I debug the Release? What settings can I change to identify the problem in Release? How do I look at the output code?
I am having the same problem. Is there a way to change the optimisation options so that both debug and release can be the same. My code fails in release and when stepping through the assembly code it does not perform a function as intended. For instance I have a routine that calls a simple loop delay function. The call to this function is optimised out in the release code!
Do we have to release code as debug to remove optimisation? or is there another way?
Ok, I appear to have answered my own question. There is a 'project option' in 'Private Configuration'->Release to set the levels to
None
Debug
Level 1
Level 2
Level 3
Optimize for size
I found these by using the Project Options search facility :)
Can I assume these follow the GCC command line options (in my case for NXP LCP1768) ?
Please sign in to leave a comment.