[PATCH v2] m68k: Add LTO support

Daniel Palmer daniel at thingy.jp
Tue Mar 31 10:49:51 CEST 2026


Hi Angelo,

On Tue, 31 Mar 2026 at 16:37, Angelo Dureghello <angelo at kernel-space.org> wrote:
> > -DItype __ashldi3 (DItype u, word_type b)
> > +__used DItype __ashldi3 (DItype u, word_type b)
>
> Why the above __used is needed ? This impacts all the coldfire builds.
>

At least for normal m68k the final link will fail because GCC has
output references to the libgcc functions but LTO didn't think they
were needed and discarded them already (example below). So this
attribute is to tell GCC to keep them so the link completes. On
coldfire is this giving you code you didn't have before? I guess that
could be the case if coldfire doesn't need to emulate some things with
libgcc.

Cheers,

Daniel


Build with the "+__used DItype __ashldi3 (DItype u, word_type b)" hunk reverted:

daniel at kinako:~/coding/cleantrees/u-boot$ make
CROSS_COMPILE=m68k-linux-gnu- -j16
 UPD     include/generated/timestamp_autogenerated.h
 UPD     include/config/uboot.release
 UPD     include/generated/version_autogenerated.h
 LDS     u-boot.lds
 CC      arch/m68k/lib/ashldi3.o
 AR      arch/m68k/lib/lib.a
 CC      cmd/version.o
 CC      common/init/board_init.o
 CC      common/version.o
 AR      cmd/built-in.a
 AR      common/init/built-in.a
 AR      common/built-in.a
 KSL     keep-syms-lto.c
 KSLCC   keep-syms-lto.o
 LTO     u-boot
/usr/bin/m68k-linux-gnu-ld.bfd: /tmp/cciN6Tis.ltrans0.ltrans.o: in
function `board_init_f':
/home/daniel/coding/cleantrees/u-boot/common/board_f.c:213:(.text.board_init_f+0x3fc):
undefined reference to `__ashldi3'
/usr/bin/m68k-linux-gnu-ld.bfd:
/tmp/cciN6Tis.ltrans0.ltrans.o:/home/daniel/coding/cleantrees/u-boot/common/board_f.c:213:(.text.board_init_f+0x404):
undefined reference to `__ashldi3'
/usr/bin/m68k-linux-gnu-ld.bfd: /tmp/cciN6Tis.ltrans1.ltrans.o: in
function `virtio_uclass_child_pre_probe':
/home/daniel/coding/cleantrees/u-boot/include/virtio.h:463:(.text.virtio_uclass_child_pre_probe+0x114):
undefined reference to `__ashldi3'
/usr/bin/m68k-linux-gnu-ld.bfd: /tmp/cciN6Tis.ltrans1.ltrans.o: in
function `virtio_uclass_child_pre_probe':
/home/daniel/coding/cleantrees/u-boot/drivers/virtio/virtio-uclass.c:311:(.text.virtio_uclass_child_pre_probe+0x160):
undefined reference to `__ashldi3'
/usr/bin/m68k-linux-gnu-ld.bfd:
/home/daniel/coding/cleantrees/u-boot/drivers/virtio/virtio-uclass.c:321:(.text.virtio_uclass_child_pre_probe+0x1aa):
undefined reference to `__ashldi3'
/usr/bin/m68k-linux-gnu-ld.bfd:
/tmp/cciN6Tis.ltrans1.ltrans.o:/home/daniel/coding/cleantrees/u-boot/drivers/virtio/virtio_blk.c:82:
more undefined references to `__ashldi3' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:2096: u-boot] Error 1


More information about the U-Boot mailing list