Problem building libstdc++ for the avr target

Jonathan Wakely jwakely@redhat.com
Wed Dec 9 17:01:25 GMT 2020


On 09/12/20 12:49 +0000, Jonathan Wakely wrote:
>On 09/12/20 13:32 +0100, Vladimir V wrote:
>>Hello.
>>
>>While testing with the current upstream I encountered a compilation issue.
>>Although I build with "--disable-threads" flag the following error occurs:
>>
>>../../../../../libstdc++-v3/src/c++11/thread.cc:39:4: error: #error "No
>>sleep function known for this target"
>>
>>Previously the check was inside the  #ifdef _GLIBCXX_HAS_GTHREADS that
>>prevented the error from happening (in my case with gcc v10.1),
>>So I would like to ask if the thread.cc should be involved in the build if
>>the threads support is configured to be disabled?
>
>Yes, the file is always built, but which definitions it contains
>depends on what is configured for the target.
>
>The std::this_thread::sleep_for and std::this_thread::sleep_until
>functions don't actually depend on threads at all. They just sleep.
>
>But that still requires target support, just different support from
>threads.
>
>>And if it should, then can the condition be reworked to cover the described
>>case?
>
>Yes, I'll do that. Thanks for bringing it to my attention.
>
>I assume we can't use avr-libc's delay functions, because they depend
>on the CPU clock frequency, which isn't known when we compile
>libstdc++. So I'll just suppress the declarations of those functions
>and remove the #error.

The attached patch adds a new _GLIBCXX_NO_SLEEP configure macro which
should get defined for your hosted AVR build. That should mean that
std::this_thread::sleep_for is not defined, and src/c++11/thread.cc
will no longer insist on some way to sleep being supported.

I've only tested this on powerpc64le-linux, so please let me know if
it works for you.

Pushed to master.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4048 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201209/c9ffc030/attachment.bin>


More information about the Libstdc++ mailing list