Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error: random.cc:452: undefined reference to `getentropy' (IDFGH-10746) #11963

Closed
3 tasks done
franz-ms-muc opened this issue Jul 27, 2023 · 10 comments
Closed
3 tasks done
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally

Comments

@franz-ms-muc
Copy link
Contributor

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

using ESP-IDF 5.1 i get the Following Error at a Build in Windows,
however same Project build fine in Ubuntu:

FAILED: Application.elf 
cmd.exe /C "cd . && C:\Espressif\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address -Wl,--cref -Wl,--defsym=IDF_TARGET_ESP32=0 -Wl,--Map=C:/git/hr/LOGIBUS_integration_Hutschienenmoped/Application/build/Application.map -Wl,--no-warn-rwx-segments -fno-rtti -fno-lto -Wl,--gc-sections -Wl,--warn-common -T esp32.peripherals.ld -T esp32.rom.ld -T esp32.rom.api.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32.rom.newlib-funcs.ld -T esp32.rom.eco3.ld -T memory.ld -T sections.ld @CMakeFiles\Application.elf.rsp -o Application.elf  && cd ."
c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/lib/no-rtti\libstdc++.a(random.o):(.literal._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x4): undefined reference to `getentropy'
c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/lib/no-rtti\libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/src/c++11/random.cc:179: undefined reference to `getentropy'
c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/lib/no-rtti\libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/src/c++11/random.cc:452: undefined reference to `getentropy'
c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/lib/no-rtti\libc.a(lib_a-arc4random.o):(.literal+0x28): undefined reference to `getentropy'
c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: c:/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/lib/no-rtti\libc.a(lib_a-arc4random.o): in function `_rs_stir':
/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/arc4random.c:89: undefined reference to `getentropy'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 27, 2023
@github-actions github-actions bot changed the title Build Error: random.cc:452: undefined reference to `getentropy' Build Error: random.cc:452: undefined reference to `getentropy' (IDFGH-10746) Jul 27, 2023
@0xjakob
Copy link
Contributor

0xjakob commented Jul 28, 2023

@franz-ms-muc Do you have any reproducing example for this? It seems that the libstdc++ is somehow configured to use get_entropy() in your case. But currently in IDF, get_entropy() is not used when libstdc++ queries random numbers. See also #11398.

@franz-ms-muc
Copy link
Contributor Author

i will make one.
(i have a Open-Source Version of my Project, so it is easy to do so)

it could come from the 4diac Lib i link to the Project.
why this not fails in Linux ?

https://gitlab.com/meisterschulen-am-ostbahnhof-munchen/org.eclipse.4diac.forte/-/blob/develop_me3/src/modules/utils/FB_RANDOM.cpp?ref_type=heads

https://gitlab.com/meisterschulen-am-ostbahnhof-munchen/org.eclipse.4diac.forte/-/blob/develop_me3/src/modules/utils/FB_RANDOM.h?ref_type=heads

this is in fact a Random Number Generator, which is incuded there.

see this Lines:

  std::random_device mRandomDevice;  // Will be used to obtain a seed for the random number engine
  std::mt19937 mRandomGenerator; // Standard mersenne_twister_engine 

@0xjakob
Copy link
Contributor

0xjakob commented Jul 31, 2023

why this not fails in Linux ?

Yes, this is strange. I looked at the code of random.cc. getentropy() shouldn't be used if _GLIBCXX_HAVE_GETENTROPY is not defined. I'll ask around if someone knows more about this...

@0xjakob 0xjakob self-assigned this Jul 31, 2023
@0xjakob
Copy link
Contributor

0xjakob commented Jul 31, 2023

@franz-ms-muc _GLIBCXX_HAVE_GETENTROPY is indeed enabled in our toolchain for Windows. But we'll probably leave it as it is and rather implement getentropy(). This will be faster than waiting for a new toolchain release. See also #11398.

@franz-ms-muc
Copy link
Contributor Author

@franz-ms-muc _GLIBCXX_HAVE_GETENTROPY is indeed enabled in our toolchain for Windows. But we'll probably leave it as it is and rather implement getentropy(). This will be faster than waiting for a new toolchain release. See also #11398.

so you mean:

the Toolchain is configured different in Windows and in Linux ?

@0xjakob
Copy link
Contributor

0xjakob commented Aug 1, 2023

the Toolchain is configured different in Windows and in Linux ?

It pretty much seems so, yes.

@espressif-bot espressif-bot assigned gerekon and unassigned 0xjakob Aug 3, 2023
@espressif-bot espressif-bot added Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new Status: In Progress Work is in progress labels Aug 3, 2023
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels Aug 18, 2023
@0xjakob
Copy link
Contributor

0xjakob commented Aug 21, 2023

@franz-ms-muc We merged a fix. If you can, please try to build again with the latest master version.

dbahrdt pushed a commit to Eltako/esp-idf that referenced this issue Sep 14, 2023
@andychess
Copy link

I'm also getting this error using a Mac and ESP32-C6.
grafik

@andychess
Copy link

Here is the relevant code:
grafik

@Lapshin
Copy link
Collaborator

Lapshin commented Feb 21, 2024

I'm also getting this error using a Mac and ESP32-C6.

@andychess , sorry for the late response. Please try the latest toolchain version https://github.com/espressif/crosstool-NG/releases/tag/esp-13.2.0_20230928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants