Using latest `gcc_arm_none_eabi` - linking error 😢

Hello all!
I am trying to use the latest gcc_arm_none_eabi package in order to gain access to c++20 features for a project I’m developing on the Teensy4.1. I am specifying the updated package via the platform_packages flag in my platformio.ini file, which looks like this:

platform = teensy
platform_packages = toolchain-gccarmnoneeabi@1.100301.220327
board = teensy41
framework = arduino
upload_protocol = teensy-cli
extra_scripts = test/
build_unflags = -std=gnu++11 -std=gnu++14
build_flags = -std=c++20

This seems to be mostly working but unfortunately I then get a linker error:

/Users/aarongough/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: cannot find -larm_cortexM7lfsp_math
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy41/firmware.elf] Error 1

Does anyone have any suggestions as to what I need to do to fix this? I am running this on an intel mac, and compilation works fine if I remove the plaform_packages entry and use c++17.


In case it is needed here is the full output of pio run -v: · GitHub

This is a special lib compiled by Teensy devs and is located in their toolchain. I’m not sure that you can use another toolchain. You can try to pick that library and put it to your project and later link with build_flags = -L /path/to/arm_cortexM7lfsp_math/dir.

1 Like

Unfortunately I think I will have to leave this for the moment as I haven’t had any luck and need get back to ‘real’ work :rofl: However I will leave what I worked out so far here in the hope that it will help someone else in the future:

  1. arm_cortexM7lfsp_math is a library made by ARM with pre-built binaries provided as part of CMSIS (Cortex Microcontroller System Interface Standard).
  1. The to use these files place them in a folder like opt/lib in your project root, then add the following to Platformio.ini to link them:
; build_flags already contains `-larm_cortexM7lfsp_math` so no need to add that again
; we just need to tell the linker there is an additional directory where it can look for the library
build_flags = -Lopt/lib

The version of the compiler can then be overridden like:

platform_packages = toolchain-gccarmnoneeabi@1.100301.220327

Unfortunately this setup then results in a new error:

/Users/aarongough/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard/libstdc++.a(eh_terminate.o):(.ARM.exidx.text._ZN10__cxxabiv112__unexpectedEPFvvE+0x4): additional relocation overflows omitted from the output

From my initial research it looks like something is doing a JUMP and trying to address a location that’s too far away? Unfortunately I am really NOT an embedded dev, or even a C/C++ dev so this is now at the point where I don’t think I have a hope of fixing it lol… If anyone else has ideas I’ll be happy to try them, if not then hopefully this helps someone in the future to get c++20 working!


1 Like

Per ARM Options (Using the GNU Compiler Collection (GCC)) GCC has the option of -mlong-calls. Try adding that in the build_flags? Or try -mword-relocations?

There is also GCC 11.x available, maybe you can locally download it + add the package.json from <user>/.platformio/packages/toolchain-gccarmnoneeabi (with adapted version info) and reference it in platform_packages with `file://<path to downloaded GCC).