MCUXpresso SDK for evkmimxrt1170 - default example build with LTO enabled does not compile

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpresso SDK for evkmimxrt1170 - default example build with LTO enabled does not compile

334 Views
mimlo
Contributor III

Hi,
I'm using relatively new version of MCUXpresso IDE (v11.8.1 [Build 1197] [2023-10-27]) and no matter what type of example project I import, it fails upon compilation when I turn on LTO (Link Time Optimization) - both for the compiler and linker. The result is the same, no matter what type of optimization level for LTO is chosen. it also does not matter if it's Debug or Release build.

Example used: evkmimxrt1170_shell_cm7 - however, any other example I tested leads to the same result.

The additional options I set after importing project from SDK Wizard:
mimlo_0-1708624016078.png (LTO enabled, level None, every combination of other 2 options were also tested when on/off)

mimlo_1-1708624058277.png (LTO enabled, level None)

mimlo_2-1708624248899.png (Debug level to None)

Summary from Build console:

Building target: evkmimxrt1170_shell_cm7.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -Xlinker -no-warn-rwx-segments -Xlinker -Map="evkmimxrt1170_shell_cm7.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -Xlinker --cref -flto -O0 -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -T evkmimxrt1170_shell_cm7_Release.ld -o "evkmimxrt1170_shell_cm7.axf" ./xip/evkmimxrt1170_flexspi_nor_config.o ./xip/fsl_flexspi_nor_boot.o  ./utilities/fsl_assert.o ./utilities/fsl_debug_console.o ./utilities/fsl_memcpy.o ./utilities/fsl_shell.o ./utilities/fsl_str.o  ./startup/boot_multicore_slave.o ./startup/startup_mimxrt1176_cm7.o  ./source/semihost_hardfault.o ./source/shell.o  ./drivers/fsl_anatop_ai.o ./drivers/fsl_cache.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_common_arm.o ./drivers/fsl_dcdc.o ./drivers/fsl_gpio.o ./drivers/fsl_lpuart.o ./drivers/fsl_pmu.o  ./device/system_MIMXRT1176_cm7.o  ./component/uart/fsl_adapter_lpuart.o  ./component/serial_manager/fsl_component_serial_manager.o ./component/serial_manager/fsl_component_serial_port_uart.o  ./component/lists/fsl_component_generic_list.o  ./board/board.o ./board/clock_config.o ./board/dcd.o ./board/pin_mux.o   
../device/system_MIMXRT1176_cm7.c:73:21: warning: type of 'g_pfnVectors' does not match original declaration [-Wlto-type-mismatch]
   73 |     extern uint32_t g_pfnVectors[];  // Vector table defined in startup code
      |                     ^
../startup/startup_mimxrt1176_cm7.c:552:15: note: 'g_pfnVectors' was previously declared here
  552 | void (* const g_pfnVectors[])(void) = {
      |               ^
../xip/fsl_flexspi_nor_boot.h:79:17: error: function 'ResetISR' redeclared as variable
   79 | extern uint32_t ResetISR[];
      |                 ^
../startup/startup_mimxrt1176_cm7.c:843:6: note: previously declared here
  843 | void ResetISR(void) {
      |      ^
lto1.exe: fatal error: errors during merging of translation units
compilation terminated.
lto-wrapper.exe: fatal error: arm-none-eabi-gcc returned 1 exit status
compilation terminated.
c:/nxp/mcuxpressoide_11.8.1_1197/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.8.1.202308071233/tools/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
make[1]: *** [makefile:53: evkmimxrt1170_shell_cm7.axf] Error 1
make: *** [makefile:44: all] Error 2
"make -r -j20 all" terminated with exit code 2. Build might be incomplete.

18:49:56 Build Failed. 4 errors, 1 warnings. (took 3s.583ms)


MCUXpresso IDE errors:
function 'ResetISR' redeclared as variable

mimlo_3-1708624600757.png
mimlo_8-1708624831956.png

MCUXpresso IDE warnings:

type of 'g_pfnVectors' does not match original declaration [-Wlto-type-mismatch]

mimlo_5-1708624719756.png
mimlo_6-1708624774932.png

- 'g_pfnVectors' was previously declared here

mimlo_4-1708624665369.png

mimlo_7-1708624806618.png

For me it looks like a something went wrong during demo apps preparation and nobody checked if it compiles when LTO is enabled. Maybe I'm doing something wrong, but I tried many other options, and it seems like an error in startup file and the definition of certain symbols that LTO does not accept.

I do not know what else I can do to make it compile, besides reworking startup file. However I do think that it should be handled properly on MCUXpresso SDK side.

Best regards,
Michael

0 Kudos
4 Replies

290 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @mimlo ,

Hope you are doing well!

Try configuring the IDE like this in the picture below:

Gavin_Jia_0-1709101002885.png

And this thread may help you on this topic. Hope this helps!

 

Best regards,
Gavin

0 Kudos

285 Views
mimlo
Contributor III

Hi @Gavin_Jia ,
If you read carefully my post you would notice, that there already is the screen of that exact configuration :D.
The problem is in my honest opinion, with SDK examples, as It should work by default.
Please take another look at this, and if possible, consult the issue with engineers.

Best regards,
Michael

0 Kudos

279 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @mimlo ,

I have tested on my side it is ok. It's possible that the previous configuration has an effect on subsequent configurations, and in any case, we recommend that you reimport a new project to test it.

Gavin_Jia_0-1709102039484.png

 

Gavin_Jia_1-1709102097000.png

Gavin_Jia_2-1709102140704.png

 

Best regards,
Gavin

271 Views
mimlo
Contributor III
Hi @Gavin_Jia ,
I did the following steps.
1.) Removed the shell project.
2.) Imported new one with default settings
3.) Set the MCU Linker flag as on your screen
4.) Set proper lib for build
5.) Compiled the project

It worked correctly. The possible reason behind my previous failure was this information prompt that show up when a user hovers mouse pointer over the lto linker option:

mimlo_0-1709116570032.png

It does not work only if I do exactly as the message prompt suggests me to do.
If I understand it correctly, it does not take effect if it is enabled only in there. It must be enabled on the end as well, so even though that option allows for the project to compile, it does not take any effect I'm afraid

I think it could be corrected in some of the future MCU IDE releases if someone else if able to reproduce the issue.

Thanks for your help,
Take care,
Michael

0 Kudos