Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.32k stars 5.28k forks source link

Fix build on recent arm gcc/newlibc versions #6615

Closed KevinOConnor closed 3 months ago

KevinOConnor commented 3 months ago

It seems recent arm gcc versions no longer build correctly using the --specs=nano.specs --specs=nosys.specs linker flags. Replace those linker flags with -nostdlib -lgcc -lc_nano.

This seems to fix the build on recent gcc versions, it eliminates some build time warnings, and does not increase the size of the resulting binary.

-Kevin

radekdoulik commented 3 months ago

It doesn't completely solve it on ubuntu 24.04. With changes from this PR, I am getting this linker error

  Linking out/klipper.elf
/usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libc_nano.a(libc_a-setjmp.o):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
collect2: error: ld returned 1 exit status
make: *** [Makefile:73: out/klipper.elf] Error 1
KevinOConnor commented 3 months ago

Thanks. Can you pull this branch again and retry?

-Kevin

ifreislich commented 3 months ago

That works compiling for RP2040 on my ubuntu 24.04 system and fixes compiling STM32 arm cores >= 1.

radekdoulik commented 3 months ago

Thanks. Can you pull this branch again and retry?

-Kevin

It links fine now, thanks!

fredericmorin commented 3 months ago

Git checkout'd this branch (work-armlink-20240611 commit 1e63e183) and got the linker command to complete successfully.

Config details: RPi5b on Armbian


Linux voron24r2 6.6.33-current-bcm2712 #1 SMP PREEMPT Wed Jun 12 16:29:38 UTC 2024 aarch64 GNU/Linux
fred@voron24r2:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Armbian 24.8.0-trunk.42 trixie
Release:    n/a
Codename:   trixie```
KevinOConnor commented 3 months ago

Thanks for testing. I committed this PR to the main branch.

-Kevin