This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Differentiating compiler options between ZDebug and ZRelease build configs with NCS/SES

The following questions are in regards to the instructions at nRF_Connect_SDK-modifying-a-sample-application.

In the Windows environment, I am transitioning from using nRF5_SDK_16.0.0 to using

  • nRF Connect SDK v1.3.0, with
  • SES 4.52
  • board nrf52840dk_nrf52840.

1. In the section NRF_Connect_SDK-configuring-build-types, it's not clear to me as to how to set compiler options individually per build configs ZDebug vs ZRelease.

  • For example, if we want the ZDebug build to include compiler options like "-g -O0 -DDEBUG" but the ZRelease build to instead include compiler options like "-O3 -DNDEBUG", how do we do this?

The figure in maintaining-cmakelist-txt-in-ses shows how to set compiler defines and options, but those options would apply to both ZDebug and ZRelease, as far as I can tell.

Furthermore, when I built nrf_desktop for ZDebug and then ZRelease to see what happens, I saw in the build outputs that both builds had "-O2" and "-g" compiler options.

  • There were very few differences between those two build outputs other than things like ZDebug had an include path for rtt but ZRelease did not, as you would expect when you look at the diff between the debug/release .conf files.
  • I was hoping to see at least some optimization differences, or at least a "-DDEBUG" difference, between the two build outputs to help me figure out the answer to this question.

2. In my opinion, the section selecting-a-build-type-in-ses or the previous section should indicate that the SES menus "Build/Build Configuration" and "Build/Set Active Build Configuration" are not applicable with this SDK. I originally was looking for ZDebug and ZRelease options to show up in those menus after following the instructions in the previous section.

3. In the instruction on how to set the CONF_FILE variable for the build configs (see step 2 in Creating build type files), doesn't the path "${CMAKE_CURRENT_SOURCE_DIR}" need to be in the CONF_FILE setting, as in:

if (CMAKE_BUILD_TYPE)

  set(CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/app_${CMAKE_BUILD_TYPE}.conf")

endif()

  • I found this path addition necessary. Without that path, the conf file was not found by cmake, as I learned when using assert_exists(CONF_FILE).

4. Is there something special with the names ZDebug and ZRelease vs traditional build config names Debug and Release?

  • I assume there is a link that describes these names, but I can't find one.  If you can provide a link and it's for Zephyr in general, is there any additional meaning here for nRF usage in the SDK not described in that link?

5. Is building with the command line, and perhaps just using SES for a debugger tool, the easier way to go with this SDK?

In general, I am pleased with Nordic documentation, but perhaps I am not finding the right places to look for the questions above.

  • Updated. 

    Hi Mike, 

    Sorry for the delay. I add CONFIG_SPEED_OPTIMIZATIONS=y into the porj.conf as

    ####
    CONFIG_SPEED_OPTIMIZATIONS=y
    ###
    

    And I got 176 files compiled with -O2 as 251642.log

    Is that as you expect?

    The support staff is reduced during the summer holidays, and you may experience delayed answers.

    -Amanda H.

  • Thank you for the update about delayed replies.  I understand.  And thank you very much for trying the build yourself.

    You got 176 files compiled with -O2.  That is what I expect.  I'm glad you attached a build log.  I should have, so I'm attaching mine now (my logs has 176 files compiled with -Os, of which 28 of them have a -O2 following the -Os):

    build_central_uart_zrelease_opt_for_speedYes_176_Os_28_O2.txt

    My build output is from the SES "Output" window after I use the SES menu Build / Build zephyr/zephyr.elf (after following the pre-build steps that I outlined in my previous reply, using CONFIG_SPEED_OPTIMIZATIONS=y). 

    My build output format is very different from yours.  Did you use a command line to build yours instead of using SES (which this ticket is about)?

    Your build lines begin with "cmd.exe" and "C:\gnuarmemb\bin\arm-none-eabi-gcc.exe".

    My build lines begin with "Building" and "Compiling", which I think are from SES. And my compiler commands are invoked as c:/ncs/v1.3.0/toolchain/opt/bin/arm-none-eabi-gcc, which shows that I am indeed using the NCS environment.

  • Hi Mike, 

    variant said:
    Did you use a command line to build yours instead of using SES (which this ticket is about)?

    I used west build to build the project as  

    ## before run the west build, please set the environment variable
    setx -m GNUARMEMB_TOOLCHAIN_PATH C:\ncs\v1.3.0\toolchain\opt
    echo %GNUARMEMB_TOOLCHAIN_PATH% & echo %ZEPHYR_TOOLCHAIN_VARIANT%
    set ZEPHYR_BASE=C:\ncs\v1.3.0\zephyr
    echo %ZEPHYR_BASE%
    
    v1.3.0\nrf\samples\bluetooth\central_uart>west -v build -b nrf52840dk_nrf52840

    Please try that and let me know the result.  

    -Amanda H.

  • Hi Amanda, 

    When I use west to build the project, with "CONFIG_SPEED_OPTIMIZATIONS=y" added into the proj.conf, I get the same desired result as you did:  176 files compiled with the -O2 option.

    So the question remains, what is the missing step or mistake I am making to achieve the same result using the SES "Integrated" Development Environment?  In four replies above, I tried my best to list all the steps that I performed for the SES build.

  • Hi Mike, 

    I can reproduce the issue as you. I will report to the internal. 

    Please note that we are moving into the summer vacation period here in Norway, so it might take a bit longer to get to the bottom of this than expected, as staff during the month of July will be reduced. I'm sorry about the inconvenience, but please be patient. And I'll get back to you as soon as I hear something from the devs.

    -Amanda H.

Related