Teensy 4.0 linker issues with STL libraries

Status
Not open for further replies.
@Paul: in case you still read this thread: Would you accept a pull request to add weak definitions of the __throw_bad_XXX functions in the core?
 
Yes when i made the function in previous libraries in past i made them weak, in case some other user code or library implemented their own.
 
I ran into the same problem. I got the errors
Code:
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7e-m/fpu/fpv5-d16\libgcc.a(unwind-arm.o): In function `get_eit_entry':
unwind-arm.c:(.text+0x134): undefined reference to `__exidx_end'
unwind-arm.c:(.text+0x138): undefined reference to `__exidx_start'
collect2.exe: error: ld returned 1 exit status
Error compiling for board Teensy 4.0.

However, the code was compiling just fine for the Teensy 3.2, 3.5 and 3.6. But when I switched to the Teensy 4.x these error messages started to appear.
I was able to track down the problem and it seemed to occur when the vector.assign() function was being used multiple times with initializer lists.

The following code reproduces the errors if compiled for teensy 4.x. Comment out any one of the two assign() lines, and it compiles just fine.
Code:
#include <initializer_list>
#include <vector>

class MyClass{
  public:
    void myFunc();
    std::vector<int> my_vector;
};

void MyClass::myFunc()
{
  my_vector.assign(std::initializer_list<int>{3,5});
  my_vector.assign(std::initializer_list<int>{6,2});
}

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

I was able to solve it by using the solution mentioned previously in this thread, in the beginning of the code.
Code:
extern "C"{
  __attribute__((weak)) int __exidx_start(){ return -1;}
  __attribute__((weak)) int __exidx_end(){ return -1; }
}
— but I'm still curious why the code breaks only for the teensy 4s and not previous teensies.
 
Status
Not open for further replies.
Back
Top