GCC configuration issue: nanosleep does not seems to be available
Hello everyone,
I trust you're all doing well.
I've encountered a specific error while running my code, and I'm seeking assistance to resolve it:
error: 'sleep_for' is not a member of 'std::this_thread'
51 | std::this_thread::sleep_for(std::chrono::milliseconds(500));
Based on my research, it appears that this issue is closely tied to the GCC configuration. I've referred to the following discussions on Stack Overflow for insight:
https://stackoverflow.com/questions/4438084/stdthis-threadsleep-for-and-gcc
https://stackoverflow.com/questions/12523122/what-is-glibcxx-use-nanosleep-all-about
I'm using the Yocto version Honister and the poky meta layer. I have found out that the recipe for gcc is under poky/meta/recipes-devtool/gcc. So my thinking was to create a gcc_%.bbappend file and add the following code as advised in the topics linked before:
EXTRA_OECONF_BASE:append = " --enable-libstdccxx-time "
It did not remove the error. Out of despair, I also tried to edit the gcc_11.2.0.bb file directly but it also did not fix the error. gcc version = 11.2.0
g++ version = 11.2.0
glibc version = (GNU libc) 2.34
Does anyone have an input on my problem ?
(ps: it's my first time using this resource, I hope I've posted my question in the right topic)
Quoted 25 lines · Nicolas Wirth via lists.yoctoproject.org
Hello everyone,
I trust you're all doing well.
I've encountered a specific error while running my code, and I'm seeking assistance to resolve it:
error: 'sleep_for' is not a member of 'std::this_thread' 51 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); Based on my research, it appears that this issue is closely tied to the GCC configuration. I've referred to the following discussions on Stack Overflow for insight:
https://stackoverflow.com/questions/4438084/stdthis-threadsleep-for-and-gcc
https://stackoverflow.com/questions/12523122/what-is-glibcxx-use-nanosleep-all-aboutI'm using the Yocto version Honister and the poky meta layer. I have found out that the recipe for gcc is under poky/meta/recipes- devtool/gcc. So my thinking was to create a gcc_%.bbappend file and add the following code as advised in the topics linked before:
EXTRA_OECONF_BASE:append = " --enable-libstdccxx-time"It did not remove the error. Out of despair, I also tried to edit the gcc_11.2.0.bb file directly but it also did not fix the error. gcc version = 11.2.0
g++ version = 11.2.0
glibc version = (GNU libc) 2.34
Quoted 4 lines
Does anyone have an input on my problem ?
(ps: it's my first time using this resource, I hope I've posted my question in the right topic)
libstdc++ is built as part of gcc-runtime, not the gcc recipe so I suspect that bbappend is in the wrong place.
Whilst not ideal, I'd try changing the gcc recipes in oe-core itself directly to add what you need configuration wise and see if that works. You could also look at the config.log of the gcc-runtime libstdc++ component to check the right configuration is being enabled where it needs to be.
Once you figure out what you need, we can work out how enable it from a bbappend in your layer.
Cheers,
Richard
I could see why your option wouldn't have taken affect but I have no idea if it is the right option or not.
As I said, I'd look at the config.log file for libstdc++, check the setting you want is being set.
Cheers,
Richard
On Tue, 2023-08-15 at 06:31 -0700, nicolas.wirth via lists.yoctoproject.org wrote:
Hello Richard, thanks to your help, I did the following but I still got the same error described in the previous post:
* Edit the gcc-runtime recipe under poky/meta/recipes-devtools/gcc-runtime.inc (which is inclued in gcc-runtime_11.2.bb
* Changing this line:
EXTRA_OECONF:append = " --cache-file= ${ B} /config.cache "
* to:
EXTRA_OECONF:append = " --enable-libstdccxx-time --cache-file= ${ B} /config.cache "
From to console.log under: builds/my-build/work/cortexa72-cortexa53-poky-linux/gcc-runtime/11.2.0-r0/gcc-11.2.0/build.aarch64-poky-linux.aarch64-poky-linux/aarch64-poky-linux/libstdc++-v3/config.log
configure: 81215 : WARNING : unrecognized options: --disable-dependency-tracking, --with-libtool-sysroot, --enable-languages, --enable-threads, --enable-default-pie, --without-local-prefix, --disable-install-libiberty, --disable-libssp, --enable-libitm, --enable-lto, --disable-bootstrap, --with-system-zlib, --with-linker-hash-style, --enable-linker-build-id, --with-ppl, --with-cloog, --enable-checking, --without-isl, --with-sysroot, --with-build-sysroot, --enable-standard-branch-protection, --with-glibc-version, --enable-initfini-array, --enable-__cxa_atexit, --enable-libstdccxx-time
It looks like the option I'm using is not supported. I found out why:
" *Another update:* GCC 4.9.0 is out and now defaults to automatically enabling nanosleep and sched_yield on platforms that are known to support them. There is no longer any need to use --enable-libstdcxx-time."
Which cause me troubles to understand why I still get the following error:
Quoted 15 lines
error: '
sleep_for' is not a member of'
std::this_thread'126 | std::this_thread::sleep_for(std::chrono::milliseconds(500));
My issue is now fixed, there was an include missing from my code that didn't throw an error on GCC 10.2 but did in GCC 11.2 ...
Thanks to RIchard for the help !
Quoted 3 lines · Nicolas Wirth via lists.yoctoproject.org
My issue is now fixed, there was an include missing from my code that didn't throw an error on GCC 10.2 but did in GCC 11.2 ...
it would be good to add some details to how you solved it.
Quoted 11 lines
Thanks to RIchard for the help !
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13126): https://lists.yoctoproject.org/g/poky/message/13126
Mute This Topic: https://lists.yoctoproject.org/mt/100755110/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Since the issue was with my code and not Yocto, I didn't thought it would be relevant but since I've been ask to share my solution here it is.
According to this; Porting to GCC 11 - GNU Project ( https://gcc.gnu.org/gcc-11/porting_to.html ) when using members of namespace std::this_thread, you have to include the libraire <thread>