zephyr: TF-M won't build with CONFIG_DEBUG_OPTIMIZATIONS
Describe the bug
Since commit f451201228531de98364a04130365598563a1dca (TF-M update to version 2.1.0), it’s no longer possible to build with CONFIG_DEBUG_OPTIMIZATIONS=y, at least for nRF platforms.
As a consequence, projects enabling CONFIG_DEBUG_OPTIMIZATIONS=y or CONFIG_DEBUG=y fail to build for non-secure platforms, as reported in https://github.com/zephyrproject-rtos/zephyr/issues/73708.
To Reproduce Either follow steps in https://github.com/zephyrproject-rtos/zephyr/issues/73708
or
simply try build Hello World sample with the following command:
west build -b nrf9160dk/nrf9160/ns samples/hello_world -- -DCONFIG_DEBUG_OPTIMIZATIONS=y
Expected behavior TF-M build should not break if project enabled debug optimizations.
Impact Showstopper
Logs and console output
[373/383] Linking C executable bin/tfm_s.axf
Memory region Used Size Region Size %age Used
FLASH: 194908 B 254 KB 74.94%
RAM: 50892 B 88 KB 56.48%
[379/383] Linking C executable bin/bl2.axf
FAILED: bin/bl2.axf
: && /home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -mcpu=cortex-m33+nofp -O2 -g -DNDEBUG -mcpu=cortex-m33+nofp --entry=Reset_Handler -specs=nano.specs -specs=nosys.specs -Wl,-check-sections -Wl,-fatal-warnings -Wl,--gc-sections -Wl,--no-wchar-size-warning -Wl,--print-memory-usage -Wl,-Map=/home/robert/repos/zephyrproject/zephyr/samples/hello_world/build/tfm/bin/bl2.map -mfloat-abi=soft -T /home/robert/repos/zephyrproject/zephyr/samples/hello_world/build/tfm/platform/target/nrf91/nrf_common/CMakeFiles/bl2_scatter.dir/./__/__/__/__/common/gcc/tfm_common_bl2.ld bl2/CMakeFiles/bl2.dir/src/flash_map.o bl2/CMakeFiles/bl2.dir/src/security_cnt.o bl2/CMakeFiles/bl2.dir/src/default_flash_map.o bl2/CMakeFiles/bl2.dir/src/provisioning.o bl2/CMakeFiles/bl2.dir/src/thin_psa_crypto_core.o bl2/CMakeFiles/bl2.dir/__/platform/ext/common/syscalls_stub.o bl2/CMakeFiles/bl2.dir/ext/mcuboot/bl2_main.o bl2/CMakeFiles/bl2.dir/ext/mcuboot/keys.o bl2/CMakeFiles/bl2.dir/ext/mcuboot/flash_map_extended.o bl2/CMakeFiles/bl2.dir/ext/mcuboot/flash_map_legacy.o bl2/CMakeFiles/bl2.dir/__/platform/ext/target/nordic_nrf/common/core/startup.o bl2/CMakeFiles/bl2.dir/__/platform/ext/target/nordic_nrf/common/core/startup_nrf91.o -o bin/bl2.axf bl2/ext/mcuboot/bootutil/libbootutil.a platform/libplatform_bl2.a bl2/mbedcrypto/library/libmbedcrypto.a bl2/mbedcrypto/3rdparty/p256-m/libbl2_p256m.a bl2/mbedcrypto/library/libmbedcrypto.a bl2/mbedcrypto/3rdparty/p256-m/libbl2_p256m.a bl2/mbedcrypto/3rdparty/everest/libbl2_everest.a && :
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_bl2.a(nrfx_nvmc.o): in function `nrfx_nvmc_page_erase':
/home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/drivers/src/nrfx_nvmc.c:263: undefined reference to `spm_log_msgval'
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_bl2.a(nrfx_nvmc.o): in function `nrfx_nvmc_words_write':
/home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/drivers/src/nrfx_nvmc.c:479: undefined reference to `spm_log_msgval'
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/drivers/src/nrfx_nvmc.c:480: undefined reference to `spm_log_msgval'
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: /home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/drivers/src/nrfx_nvmc.c:481: undefined reference to `spm_log_msgval'
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_bl2.a(nrfx_uarte.o): in function `nrf_gpio_pin_port_decode':
/home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_gpio.h:873: undefined reference to `spm_log_msgval'
/home/robert/zephyr-sdk/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_bl2.a(nrfx_uarte.o):/home/robert/repos/zephyrproject/modules/hal/nordic/nrfx/hal/nrf_gpio.h:882: more undefined references to `spm_log_msgval' follow
Environment (please complete the following information):
- Linux
- Toolchain: Zephyr SDK 0.16.5-1
- 0d56a3c3f4c333b08b0fecde02a9c032ee6c2d2f
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (13 by maintainers)
Commits related to this issue
- manifest: trusted-firmware-m: fix debug build Pulls in assert usage fixes. Fixes #73862. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no> — committed to tomi-font/zephyr by tomi-font 2 years ago
- manifest: trusted-firmware-m: fix debug build Pulls in assert usage fixes. Fixes #73862. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no> — committed to tiacsys/zephyr by tomi-font 2 years ago
- manifest: trusted-firmware-m: fix debug build Pulls in assert usage fixes. Fixes #73862. (cherry picked from commit 5f41ec8e39d6dbea895a1185b7a3daacf453085f) Original-Signed-off-by: Tomi Fontanill... — committed to Chenhongren/zephyr by tomi-font 2 years ago
Will be discussing this with @adeaarm, today. Will give feedback as soon as possible!