Skip to content

undefined reference to getentropy in libstdc++ #519

Closed
@stephanosio

Description

@stephanosio

(Reported in https://discord.com/channels/720317445772017664/883404732423606303/995909013394960425)

/path/to/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /path/to/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libstdc++_nano.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
random.cc:(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/path/to/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /path/to/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/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&)':
random.cc:(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3c): undefined reference to `getentropy'
/path/to/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /path/to/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/lib/thumb/v7e-m/nofp/libc_nano.a(lib_a-arc4random.o): in function `_rs_stir_if_needed':
arc4random.c:(.text._rs_stir_if_needed+0x16): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Likely related upstream GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103166

Note that the "fix" for the above bug has been merged and is already part of the GCC 12.1 release, yet we still see this issue. There likely exists another underlying problem requiring further investigation.

Metadata

Metadata

Assignees

Labels

area: GCCIssues related to GCC (GNU Compiler Collection)area: libstdc++Issues related to libstdc++ (GNU C++ Library)

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions