Ошибки связи при использовании -flto и -g3 (arm-none-eabi) - PullRequest
0 голосов
/ 01 мая 2020

Я пытаюсь скомпилировать некоторый код для Cortex M4, используя LTO и -g3

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
MCU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
CFLAGS = $(MCU) -Os -g3 -flto -fdata-sections -ffunction-sections
LDFLAGS = $(MCU) -flto -specs=nano.specs -Wl,--gc-sections

Это выдает:

...
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4._types.h.125.5cf8a495f1f7ef36777ad868a1e32068]' of /tmp/ccsUuxWo.debug.temp.o
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4.stddef.h.155.3588ebfdd1e8c7ede80509bb9c3b8009]' of /tmp/ccsUuxWo.debug.temp.o
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4._types.h.184.03611d4f6b5bec9997bcf4279eceba07]' of /tmp/ccsUuxWo.debug.temp.o
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4.reent.h.17.90c2574d4acdcfce933db5cb09ff35fe]' of /tmp/ccsUuxWo.debug.temp.o
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4.cdefs.h.49.6260d97adb8d27534cbdc0f868b8ea87]' of /tmp/ccsUuxWo.debug.temp.o
`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/ccsUuxWo.debug.temp.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4.math.h.13.cc998d7e0eff0587fd028fd98ed8bf4e]' of /tmp/ccsUuxWo.debug.temp.o
collect2: error: ld returned 1 exit status

Если я компилирую с -flto и -g (НЕ -g3) работает нормально. Если я скомпилирую без -flto и с -g3, он будет работать нормально.

Ошибки приводят меня к мысли, что мне нужно сохранить раздел в скрипте компоновщика, поэтому я попробовал оба: KEEP(*(.gnu.debuglto*)) *(.gnu.debuglto_.debug_macro*) безуспешно

...