Error "relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab'" causes on Linux ARM machines if using std::function.

asukiaaa

New member
I got the following an error at building a project on Linux ARM machine.
Bash:
/home/asuki/.platformio/packages/toolchain-gccarmnoneeabi-teensy/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v7e-m+dp/hard/libgcc.a(pr-support.o):(.ARM.exidx+0x34): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab'

The following code causes this error.
C++:
#include <Arduino.h>

using CalcInt = std::function<int(int, int)>;
int _plus(int a, int b) { return a + b; }
CalcInt plus = _plus;

void setup() { Serial.begin(9600); }

void loop() {
  Serial.println(plus(1, 2));
  delay(100);
}

However, I could build the code on Linux x86 64bit machine.

CPU typeOSMachineBuild result
ARMUbuntu22.04 64bitNvidia Jetson AGX OrinFailed
ARMRaspberry Pi OS 64bitRaspberry Pi 3BFailed
ARMRaspberry Pi OS 32bitRaspberry Pi 3BFailed
x86Ubuntu22.04 64bitLenovo ThinkPad S1 Yoga (Intel)Succeeded

Version of tools.
PlatformIO: 6.1.16
platformio-teensy: 5.0.0 (It uses Teensyduino v1.59)

I tried to build with using Arduino IDE but IDE2 does not support ARM and IDE1.8.19 cannot failed loading board setting of teensy so I gave up trying Arduino IDE.

I read the following threads but I cannot find any way to resolve the error.

I could avoid the error if I stop using std::function like this but I want to use std::function.
C++:
// using CalcInt = std::function<int(int, int)>;
typedef int(*CalcInt)(int, int);

Is there any way to avoid the error on ARM machines?
 
Last edited:
Arduino IDE 1.8.19 does work on ARM-based Linux. But you must run the dedicated installed, because Boards Manager in those old IDE versions is not enough for Teensy.

Thank you for the information.
I miss understood the way to install teensy info to Arduino IDE.
I could install board info of teensy with using the installer.

However, same error occurs even on Arduino IDE on Jetson AGX Orin (arm64bit).
Screenshot from 2024-12-12 10-19-49.png
 
Back
Top