Linker warning "_getentropy is not implemented and will always fail" #1768
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#1768
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Trying to compile my project i get the following warning after an OS upgrade that also brought in a new version of GCC:
OS: Ubuntu 24.04
GCC: arm-none-eabi-gcc (15:13.2.rel1-2) 13.2.1 20231009
SDK: v1.6.1
Can this safely be ignored for now or can i do something against this, besides downgrading the compiler?
i have not seen this; can you provide a minimal repro; is this with C++? are you calling something that might need
getentropy?I saw this when I upgraded to the latest LTS of Ubuntu. It might be something that gets noticed with a new version of GCC and/or a new version of newlib?
This at least shows that this problem isn't specific to just
pico-sdk😉Yeah, i'm sure it is a problem with
newlibhowever the reason I asked for a repro case, is that i couldn't reproduce it!! (and then work around it)Sorry, haven't gotten around to create one yet. I don't want to FOSS my project just yet as i want it in a releaseworthy state, but if you could keep it under the lid until i am prepared to release it i could send you a copy.
I am using Elmchans FatFS as a library but everything else is just the normal Pico SDK and the normal C and C++ library.
As a sidenote, everything works as expected, so for now it seems one can ignore that warning.
ok, yeah maybe just worth looking at the .DIS file and see if there are any references to entropy
CLion says "Nope"
Oh, cool, this is my whole project in assembler, thanks for showing me that! ❤️
Not sure if you still need that minimal repro case, but here's mine:
CMakeLists.txtmain.cpp:build commands:
It seems the
-DCMAKE_BUILD_TYPEis part of the trigger. If that's not present, I don't see the warningsThanks @dementedmonkey , I can confirm that I was able to reproduce this linker waning with your minimal example 👍 And I can also confirm that the warning doesn't appear if I change the
CMAKE_BUILD_TYPEtoRelease.@kilograham I used Docker to test this in different versions of Ubuntu last night, and the warning doesn't appear in Ubuntu 23.04 or Ubuntu 23.10 (which both use arm-none-eabi-gcc 12.2.1 and libnewlib-arm-none-eabi 3.3.0), but with Ubuntu 24.04 or Ubuntu 24.10 (which both use arm-none-eabi-gcc 13.2.1 and libnewlib-arm-none-eabi 4.4.0) the build-output includes this warning right at the end:
I may be able to contribute a hint here.
This code produces the warning:
This one does not:
The first version creates calls to
__cxa_guard_acquireand__cxa_guard_releasewhich seem to be intended to prevent access to not yet fully constructed static objects.My hypothesis is that they somehow depend on randomness to randomize locking attempts.
Hey, any update on that? In my case this is happening no matter which build type I'm using.
If you are only interested in getting rid of the warning without understanding/solving the cause, you can pass
-fno-threadsafe-staticsto gcc.As I wrote in my comment above, the issue is somehow related to static objects that get initialized at runtime.
Disabling the threadsafety features for them gets rid of the warning.
I currently have no idea how threadsafe statics and getentropy are related.
Maybe it's creating a random (unique) ID per thread / object, to check for collisions or something?
moving to 2.2.0 as I'm not convinced this isn't a problem with this particular GCC/newlib version - also I think the warning is harmless
I also stumbled upon this, and as I found the warnings irritating, I looked a bit further, and found Unable to link C++ application with libstdc++ when newlib is used (gcc 13 and perhaps also 12):
As a definition of a "getentropy" function, I found https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/getentropy.c.html which starts with:
OK, so that kind of looks like it could be used as "a stub function that just returns -1 and sets errno=ENOSYS"; although, my actual linker error is (text reformatted for readability):
... so it is
_getentropyI need, with underscore, not justgetentropy...Also, grepping through pico-sdk, I didn't see much of
errnobeing mentioned. So in the end, I just added this to my pico-sdkmain.cfile, right before the definition of mymain()function:... and the warning is now gone! I just hope this doesn't mess up other stuff - we'll see ...
Otherwise, I also found this suggestion in https://stackoverflow.com/questions/73742774/gcc-arm-none-eabi-11-3-is-not-implemented-and-will-always-fail :
... but it kind of looked a bit extreme (plus for me, it is libg.a triggering the warning, not libnosys.a), so I thought I'd try this only if the above stub did not work - but the stub does seem to work did, so I left it there ...
yeah, i mean we can return -1 for
_get_entropy()or indeed returns something useful frompico_rand()the returning of -1 is a good workaround if this is annoying you, but the reason I'm not committing that yet, is that it's not clear that it should be being called
I have the same error when setting
PICO_CXX_ENABLE_EXCEPTIONSto1.Edit:
CMAKE_BUILD_TYPEisReleasein my projectSo the current workaround is something like that?
fix merged into develop; i could never reproduce, so assuming it works ;-)