undefined reference to `getentropy'
When trying to build with the 32blit.toolchain, I'm getting the following linking errors:
/usr/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: warning: MyProject.elf has a LOAD segment with RWX permissions /usr/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: /home/user/dev/32blit-sdk/stdlib/pic/libstdc++_nano.a(random.o): in function
std::(anonymous namespace)::__libc_getentropy(void*)': /home/runner/work/stdlibs/stdlibs/build/gcc-12.2.0/build-pic/arm-none-eabi/libstdc++-v3/src/c++11/../../../../../libstdc++-v3/src/c++11/random.cc:179:(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0xa): undefined reference togetentropy' /usr/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: /home/user/dev/32blit-sdk/stdlib/pic/libstdc++_nano.a(random.o): in functionstd::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/runner/work/stdlibs/stdlibs/build/gcc-12.2.0/build-pic/arm-none-eabi/libstdc++-v3/src/c++11/../../../../../libstdc++-v3/src/c++11/random.cc:452:(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x56): undefined reference togetentropy' /usr/lib/gcc/arm-none-eabi/14.2.0/../../../../arm-none-eabi/bin/ld: /home/user/dev/32blit-sdk/stdlib/pic/libc_nano.a(lib_a-arc4random.o): in function_rs_stir': /home/runner/work/stdlibs/stdlibs/build/newlib-4.2.0.20211231/build-pic/arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/arc4random.c:89:(.text._rs_stir_if_needed+0x1e): undefined reference togetentropy' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/MyProject.dir/build.make:347: MyProject.elf] Error 1 make[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/MyProject.dir/all] Error 2 make: *** [Makefile:156: all] Error 2
An internet search suggests there might an issue with older versions of libstdc++ not providing a definition for getentropy(). Examination of the 32blit.toolchain suggests it's downloading some version of libstdc++, and that it's linking against that.
Could a bump in the version downloaded by the toolchain possibly remedy the situation?
I'll note that my code was originally written for a PicoSystem and works on (and builds for) that as well as Linux without issue.
This might be related to #845.
🤔 Considering that the references to getentropy are coming from the stdlibs themselves I'd guess that they're misconfigured in some way. (Though if it were there, it would probably be a stub)
Edit: okay our newlib is too old, the stub was added in https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=b9e867d088935d9f0bf312e6dbf3e4976850dfd3.