При сборке модулей добавляю -flto -fno-fat-lto-objects, при вызове ld ничего не добавляю, не знаю что надо, результат.
arm-none-eabi-ld: /tmp/pmc/hal/adc.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/hal/can.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/hal/hal.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/hal/pwm.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/hal/usart.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/ap.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/cml.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/lib.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/m.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/pmc.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/sh.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/task.o: plugin needed to handle lto object
arm-none-eabi-ld: /tmp/pmc/tel.o: plugin needed to handle lto object
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x2a): undefined reference to `halStart'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x2e): undefined reference to `halMain'
/tmp/pmc/hal/entry.o:(.vectors+0x8): undefined reference to `irqNMI'
/tmp/pmc/hal/entry.o:(.vectors+0xc): undefined reference to `irqHardFault'
/tmp/pmc/hal/entry.o:(.vectors+0x10): undefined reference to `irqMemoryFault'
/tmp/pmc/hal/entry.o:(.vectors+0x14): undefined reference to `irqBusFault'
/tmp/pmc/hal/entry.o:(.vectors+0x18): undefined reference to `irqUsageFault'
/tmp/pmc/hal/entry.o:(.vectors+0x2c): undefined reference to `irqSVCall'
/tmp/pmc/hal/entry.o:(.vectors+0x38): undefined reference to `irqPendSV'
/tmp/pmc/hal/entry.o:(.vectors+0x3c): undefined reference to `irqSysTick'
/tmp/pmc/hal/entry.o:(.vectors+0x78): undefined reference to `irqDMA1_Stream3'
/tmp/pmc/hal/entry.o:(.vectors+0x88): undefined reference to `irqADC'
/tmp/pmc/hal/entry.o:(.vectors+0x90): undefined reference to `irqCAN1_RX0'
/tmp/pmc/hal/entry.o:(.vectors+0x94): undefined reference to `irqCAN1_RX1'
/tmp/pmc/hal/entry.o:(.vectors+0x98): undefined reference to `irqCAN1_SCE'
/tmp/pmc/hal/entry.o:(.vectors+0xa4): undefined reference to `irqTIM1_UP_TIM10'
/tmp/pmc/hal/entry.o:(.vectors+0xdc): undefined reference to `irqUSART3'
Makefile:57: recipe for target '/tmp/pmc/pmc' failed
make: *** [/tmp/pmc/pmc] Error 1
Если вызвать gcc вместо прямого вызова ld то получаю проблемы со всяким стартовым кодом и библиотеками которые мне не нужны. Когда-то я и перешел на вызов ld чтобы не иметь этих проблем.
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans0.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans0.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans1.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans1.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans2.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans2.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans3.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans3.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans4.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans4.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans5.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans5.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans6.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans6.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans7.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans7.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans8.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans8.ltrans.o
/usr/libexec/gcc/arm-none-eabi/ld: error: /tmp/ccs6XVoG.ltrans9.ltrans.o uses VFP register arguments, /tmp/pmc/pmc.1.o does not
/usr/libexec/gcc/arm-none-eabi/ld: failed to merge target specific data of file /tmp/ccs6XVoG.ltrans9.ltrans.o
/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/lib/crt0.o: In function `_start':
/var/tmp/portage/cross-arm-none-eabi/newlib-2.4.0/work/newlib-2.4.0/newlib/libc/sys/arm/crt0.S:403: undefined reference to `main'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x34): undefined reference to `ldSdata'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x38): undefined reference to `ldEtext'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x3c): undefined reference to `ldEdata'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x40): undefined reference to `ldSbss'
/tmp/pmc/hal/entry.o: In function `__iRbssComp':
(.text+0x44): undefined reference to `ldEbss'
/tmp/pmc/hal/entry.o:(.vectors+0x0): undefined reference to `ldStack'
/tmp/ccs6XVoG.ltrans4.ltrans.o: In function `halStart':
<artificial>:(.text+0x9c0): undefined reference to `ldSvectors'
collect2: error: ld returned 1 exit status
Makefile:57: recipe for target '/tmp/pmc/pmc' failed
make: *** [/tmp/pmc/pmc] Error 1
Undefined reference это понятно, надо как-то объяснять, что функция вызывается из вне и выбрасывать ее нельзя.
В первом случае похоже никакого LTO нет, судя по времени работы ld и сообщениях о плагинах, но почему есть undefined reference? Во втором не знаю как сделать, чтобы компоновки не было, а только бы произошла оптимизация и генерация объектного кода, дальше я бы сам вызвал ld как мне надо.
Исходный Makefile.