-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
cpp: thread: support for std::thread, std::mutex, std::condition_variable, etc #43729
base: main
Are you sure you want to change the base?
cpp: thread: support for std::thread, std::mutex, std::condition_variable, etc #43729
Conversation
7e0911f
to
597f1c9
Compare
The toolchain header
The file
|
48ebd02
to
9b19892
Compare
c7f071a
to
b5f0b91
Compare
@cfriedt is there any reason why this pull-req is not progressing forward? I'm also very interested in getting better C++ support into Zephyr and would like to help out. Is there any specific I can help out with here? I've tested this PR with the SDK changes mentioned above and my 5-min test says it works fine. |
@ortogonal
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
e1486d4
to
914ad2a
Compare
914ad2a
to
d97b95b
Compare
Currently, eval SDK Toolchain components are ready to download for evaluation purposes
The x86_64 and riscv64 toolchain components also support the 32-bit variants for those ISAs |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This is just waiting on a candidate toolchain or CI image to become available. v0.16.6 does have the necessary toolchain changes (aside from having to enable c11 threads) so as long as we can point Zephyr CI at a different image with that toolchain it can run through automated testing. @stephanosio - is there a way that this can be pulled into the CI run you had going |
Hi @cfriedt - I patched the 16.6 build to give the threading support a try. I was able to build/link my firmware successfully with the patch, thanks to your work! I noticed that whenever __cxxabiv1::__cxa_guard_acquire() is invoked, it would throw exception though. I'm building against QEMU MPS3_AN547 target (cortex M55). When running LLDB against the elf I saw following callstack: (lldb) bt
* thread #1, stop reason = breakpoint 1.1
* frame #0: 0x10008160 zephyr.elf`__cxa_throw
frame #1: 0x1000446c zephyr.elf`(anonymous namespace)::mutex_wrapper::mutex_wrapper() (.isra.0) + 44
frame #2: 0x100044a0 zephyr.elf`__cxa_guard_acquire + 24
frame #3: 0x100015ce zephyr.elf`main at main.cpp:27:33
frame #4: 0x100031f0 zephyr.elf`bg_thread_main(unused1=0x00000000, unused2=0x00000000, unused3=0x00000000) at init.c:459:8
frame #5: 0x10001672 zephyr.elf`z_thread_entry(entry=(zephyr.elf`bg_thread_main + 1 at init.c:424:20), p1=0x00000000, p2=0x00000000, p3=0x00000000) at thread_entry.c:48:2
frame #6: 0x10002612 zephyr.elf`arch_switch_to_main_thread(main_thread=<unavailable>, stack_ptr=0x00000000, _main=<unavailable>) at thread.c:575:2 my #include <stdio.h>
#include <cxxabi.h>
int main(void)
{
printf("%s\n", "started");
__cxxabiv1::__cxa_guard_acquire(NULL);
printf("%s\n", "ended");
} I want to debug this further, but as you can see the symbols for anything in stdlibc++ is missing. Two questions for you:
Again, thanks for the great work here! |
Hi @AfflatusX - There is a known issue and fix, documented here zephyrproject-rtos/sdk-ng#751 I'm not sure what release this will be integrated into in the Zephyr SDK. @stephanosio is the C++ maintainer and SDK maintainer, and might have a better idea. |
@cfriedt - Thanks for the quick reply! I can fork/patch your PR in the meantime. However, when I pull the v0.16.6 branch and try to build the toolchain using
I tried to search for the message |
I would guess that some changes were reverted in |
my bad, forgot gcc is a sub module, need to update separately. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This commit adds support for std::thread and std::this_thread when the configured C++ standard is >= C++11. The implementation uses POSIX threads under the hood. Signed-off-by: Christopher Friedt <[email protected]>
This commit adds tests for std::thread and std::this_thread. Signed-off-by: Christopher Friedt <[email protected]>
Add tests for the ISO C++11 std::condition_variable. Signed-off-by: Christopher Friedt <[email protected]>
Add tests for ISO C++ std::mutex. Signed-off-by: Christopher Friedt <[email protected]>
d97b95b
to
984a65b
Compare
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This commit adds support for
std::thread
andstd::this_thread
when the configured C++ standard is >= C++11.Fixes #25569
Accompanying
sdk-ng
PR: zephyrproject-rtos/sdk-ng#735Notes:
CONFIG_ARCH_POSIX=y
andCONFIG_ARCH_POSIX=n
CONFIG_ARCH_POSIX=n
as we cannot yet auto-allocate thread stacks