Skip to content

undefined reference to `getentropy' #895

@Dixilea

Description

@Dixilea

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 to getentropy'
/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::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 to getentropy'
/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 to getentropy'
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions