Open
Description
When building an executable with PICO_NO_FLASH
while using a static std::vector
the build fails with a linker error:
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(eh_globals.o): in function `_GLOBAL__sub_I___cxa_get_globals_fast':
/build/arm-none-eabi-gcc/src/gcc-12.2.0/libstdc++-v3/libsupc++/eh_globals.cc:178: undefined reference to `__dso_handle'
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-fini.o): in function `__libc_fini_array':
/build/arm-none-eabi-newlib/src/build-newlib/arm-none-eabi/thumb/v6-m/nofp/newlib/../../../../../../newlib-4.3.0.20230120/newlib/libc/misc/fini.c:36: undefined reference to `_fini'
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: picopp_include_all.elf: hidden symbol `__dso_handle' isn't defined
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
I am using gcc 12.2.0.
This does not happen when building the same application without PICO_NO_FLASH
.
This is because inside $PICO_SDK_PATH/src/rp2_common/pico_standard_link/CMakeLists.txt:79
the compile option -nostartfiles
is set iff PICO_NO_FLASH
is set to 1.
At the same time manually defining the missing symbols works as well.
void* __dso_handle = 0;
void* _fini = 0;
I am not sure what exactly these symbols do or whether they are actually needed so any help is appreciated.
Is this a bug in the pico-sdk
or do I have any mistakes on my side.
To reproduce, a basic example where this error occurs is:
#include <vector>
void
test()
{
static std::vector<int> vec;
vec.push_back(0);
}
int
main()
{
return 0;
}