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:
-
(LTO enabled, level None, every combination of other 2 options were also tested when on/off)
-
(LTO enabled, level None)
-
(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


MCUXpresso IDE warnings:
- type of 'g_pfnVectors' does not match original declaration [-Wlto-type-mismatch]


- 'g_pfnVectors' was previously declared here


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