configs: common: enable c++11 thread support via c11 threads #774
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Notes for Revision 2
Note
This is the second revision of this change, the first being in #735.
This revision adds a weak default implementations of C11
<threads.h>
API functions, so that Zephyr applications can continue to build and link with default settings (i.e. without enabling the options below):Overview
This change allows Zephyr developers to use most or all of the C++ facilities in gcc that depend on gthread support.
Those facilities include (but are likely not limited to)
std::thread
std::this_thread
std::mutex
std::recursive_mutex
std::shared_mutex
std::condition_variable
std::binary_semaphore
std::counting_semaphore
std::lock_guard
std::unique_lock
std::scoped_lock
std::shared_lock
std::syncstream
std::future
std::async
Associated Zephyr SDK PRs
Associated Zephyr PRs
Zephyr SDK Toolchain Snapshots
Testing branch
Test are in review at zephyrproject-rtos/zephyr#43729 .
The test suites can be run with e.g.
They should run via picolibc eventually as well, but IIRC, there is an error about a missing
.spec
file. The workaround is to copy the spec file from a separate Zephyr SDK installation.Help Wanted
Updating Picolibc
The few changes required to newlib might also need to be applied to picolibc in order to expose similar functionality.
Additional Testsuites
It would be helpful to add test suites for the following
std::semaphore
std::future
std::coroutine
Additional testsuites can be added in parallel. They should not be considered blockers by any means, since they do not depend on anything specific to Zephyr.
Technically, not dependent on threading, coroutine support in Zephyr might Just Work (TM). However, coroutines have the potential to be extremely impactful in Zephyr as they are far more memory efficient than threads (important for resource-constrained devices).
Building, Testing, and Uploading Additional SDK Toolchains
"Zephyr SDK Toolchain Snapshots" lists a number of unchecked boxes and unlinked toolchains without links. To check the box and populate the link, the following steps should be taken:
sh ./sdk-ng/contrib/linux_build_toolchain.sh -o /tmp/sdk-build -c $ARCH-zephyr-elf
rsync -avr /opt/zephyr/zephyr-sdk-0.16.8/$ARCH-zephyr-elf{,_orig}/
LLVM Toolchain Integration
Currently, all of this work is being done against Zephyr's GCC-based SDK toolchains. It's possible that LLVM toolchain integration will be much easier.
Our testsuites should run successfully with both GCC-based toolchains as well as with LLVM.