LPC845 & mcuxpressoide_11.2.0 : lto-wrapper failed

Showing results for 
Search instead for 
Did you mean: 

LPC845 & mcuxpressoide_11.2.0 : lto-wrapper failed

Contributor III


I need to enable the -flto option for my project using an LPC845.

If I turn on -flto for the C compiler, the C++ compiler and the linker in mcu settings, I get the following error:

Building target: LPC845_Project.axf
Invoking: MCU C++ Linker
arm-none-eabi-c++ -nostdlib -L"C:\Users\Victor\Documents\GitHub\IKM-RL800-01U-mcu\source\driver-S2LP\Sigfox_Libs\bin" -Xlinker -Map="LPC845_Project.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -Xlinker --sort-section=alignment -Xlinker --cref -flto -Os -mcpu=cortex-m0plus -mthumb -T LPC845_Project_Release.ld -o "LPC845_Project.axf" ./utilities/fsl_debug_console.o ./startup/startup_lpc845.o ./source/tasks/task_S2LP.o ./source/tasks/task_at.o ./source/ika_cpp/utils/eng_not/engineeringnotation.o ./source/ika_cpp/utils/aes/AES.o ./source/ika_cpp/ika_log_formatter/ika_log_formatter.o ./source/ika_cpp/freertos_addons/cpp_config.o ./source/ika_cpp/freertos_addons/thread.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Commands.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Csma.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Fifo.o ./source/driver-S2LP/S2LP_Library/src/S2LP_General.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Gpio.o ./source/driver-S2LP/S2LP_Library/src/S2LP_PacketHandler.o ./source/driver-S2LP/S2LP_Library/src/S2LP_PktBasic.o ./source/driver-S2LP/S2LP_Library/src/S2LP_PktStack.o ./source/driver-S2LP/S2LP_Library/src/S2LP_PktWMbus.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Qi.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Radio.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Timer.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Timer_ex.o ./source/driver-S2LP/S2LP_Library/src/S2LP_Types.o ./source/driver-S2LP/driver_s2lp.o ./source/driver-S2LP/sigfox.o ./source/driver-LPC84X/ika_gpio.o ./source/LPC845_Project.o ./source/mtb.o ./source/s2lp_custom_ikm.o ./source/semihost_hardfault.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_gpio.o ./drivers/fsl_iap.o ./drivers/fsl_pint.o ./drivers/fsl_power.o ./drivers/fsl_reset.o ./drivers/fsl_spi.o ./drivers/fsl_swm.o ./drivers/fsl_syscon.o ./drivers/fsl_usart.o ./device/system_LPC845.o ./component/uart/miniusart_adapter.o ./board/board.o ./board/clock_config.o ./board/peripherals.o ./board/pin_mux.o ./amazon-freertos/freertos_kernel/portable/MemMang/heap_4.o ./amazon-freertos/freertos_kernel/portable/GCC/ARM_CM0/port.o ./amazon-freertos/freertos_kernel/croutine.o ./amazon-freertos/freertos_kernel/event_groups.o ./amazon-freertos/freertos_kernel/list.o ./amazon-freertos/freertos_kernel/queue.o ./amazon-freertos/freertos_kernel/stream_buffer.o ./amazon-freertos/freertos_kernel/tasks.o ./amazon-freertos/freertos_kernel/timers.o -lSFX_LIB_MON_CortexM0+ -lADDON_RF_PROTOCOL_MON_CortexM0+
C:\Users\Victor\AppData\Local\Temp\ccEbURjM.s: Assembler messages:
C:\Users\Victor\AppData\Local\Temp\ccEbURjM.s:941: Error: invalid offset, value too big (0x00002C90)
lto-wrapper.exe: fatal error: arm-none-eabi-c++ returned 1 exit status
compilation terminated.
c:/nxp/mcuxpressoide_11.2.0_4120/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.2.0.202001021529/tools/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: error: lto-wrapper failed


What could cause this issue, and how to correct it ?



Labels (1)
Tags (2)
3 Replies

Senior Contributor II

Hi Victor,

the reason is that the offset/value for an immediate constant in the assembly code is too big.

I had fixed such things in the FreeRTOS port I'm using (see Tutorial: Adding FreeRTOS to where there is no FreeRTOS | MCU on Eclipse ): this port works even with highest optimization levels and with -flto.

Search for example for '-flto' in McuOnEclipseLibrary/port.c at master · ErichStyger/McuOnEclipseLibrary · GitHub  which has two locations dealing with that optimization level.

You could use/integrate that port (see above article how you can do this even for an SDK which does not have FreeRTOS): otherwise that FreeRTOS port can easily replace your existing one.

I hope this helps,


Contributor III

Hello Erich,

Thanks for your answer. Actually I've read this post long time ago and find it very useful (BTW, very nice blog, it helped us a lot of times!)

However I'm working with the latest version of the FreeRTOS kernel, I would rather like not to change it at this stage of the development (aka very close to the end, missing a few kB of flash to finish it).

  1. I don't know how to obtain more debug information from the linker. Is it possible?
  2. I'm using this port: FreeRTOS-Kernel/portable/GCC/ARM_CM0 at master · FreeRTOS/FreeRTOS-Kernel · GitHub. Could you please pin-point the location of the problem for this official port? Unfortunately I don't know assembly language...and I can't see any constant matching the offset reported in the linker message.
  3. I've opened an issue in the FreeRTOS kernel Github repo: [BUG] -flto optimization fails with ARM_CM0 port (invalid offset, value too big) · Issue #105 · Free.... Feel free to contribute if you have the answer :smileyhappy:

Thanks again,


0 Kudos

Contributor III

After new tests, the issue is not related to FreeRTOS at all. It is due to an external static library. I wonder if I can disable -flto only for this library...
I've created a new post for this specific question: https://community.nxp.com/message/1346603 

0 Kudos