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

configs: enable libstdcxx-threads and libstdcxx-time via posix #722

Closed
wants to merge 1 commit into from

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Dec 1, 2023

Enable standard C++ threads and time functionality via Zephyr's POSIX API.


@cfriedt
Copy link
Member Author

cfriedt commented Dec 1, 2023

The added ./configure options might kick off some autotools tests (GLIBCXX_CHECK_GTHREADS, GLIBCXX_ENABLE_LIBSTDCXX_TIME, ..) which I am skeptical about. Those, in turn, run some other autoconf build-time tests.

Until we have a stable interface based on *zephyr*, and if this change does not work as-is, it might be necessary to hard-code the following in gcc/libstdc++-v3/acinclude.m4.

  ac_has_clock_monotonic=yes
  ac_has_clock_realtime=yes
  ac_has_nanosleep=yes
  ac_has_sched_yield=yes

Even hard-coding the above values might not work, in which case we will likely need to provide some modified means of configuration - e.g. manually using AC_DEFINE() and AC_SUBST() macros to enable the needed options.

Eventually, we definitely do want to support target-based feature selection, such that we can set sane defaults via target *zephyr* and not run any build-time tests.

@stephanosio stephanosio self-requested a review December 1, 2023 23:56
@stephanosio stephanosio added area: GCC Issues related to GCC (GNU Compiler Collection) area: libstdc++ Issues related to libstdc++ (GNU C++ Library) labels Dec 1, 2023
@cfriedt cfriedt marked this pull request as draft December 3, 2023 23:03
@cfriedt cfriedt force-pushed the enable-std-thread branch 22 times, most recently from 34172b0 to c72bf40 Compare December 5, 2023 20:36
@cfriedt cfriedt force-pushed the enable-std-thread branch 2 times, most recently from 2b8f85b to 65afb8b Compare December 5, 2023 20:58
Enable standard C++ threads and time functionality via Zephyr's
POSIX API.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt
Copy link
Member Author

cfriedt commented Dec 6, 2023

@stephanosio, @keith-packard -

The changes here should be just about sufficient to enable std::thread and friends. Cannot rely on compile or link tests here obviously (unless there was some kind of fake set up for Zephyr x-toolchain builds, which might be an option).

I dropped a previous commit (see paste below) that polluted gthr-posix.h with a bunch of declarations.

https://pastebin.com/Sb1XUQ9H

Those declarations should be in <pthread.h> or <time.h> with just one or two feature test macros but none of them show up in CI for some reason.

Any suggestions?

https://github.com/zephyrproject-rtos/picolibc/blob/main/newlib/libc/machine/cris/include/pthread.h
https://github.com/zephyrproject-rtos/picolibc/blob/main/newlib/libc/include/time.h

https://github.com/zephyrproject-rtos/newlib-cygwin/blob/zephyr-newlib-3.3.0/newlib/libc/include/pthread.h
https://github.com/zephyrproject-rtos/newlib-cygwin/blob/zephyr-newlib-3.3.0/newlib/libc/include/time.h

Note: These feature test macros should only be defined for the build. We cannot hard code them into an installed header, since Zephyr apps might disable POSIX support.

@cfriedt
Copy link
Member Author

cfriedt commented Dec 6, 2023

It's too bad there are no actual instructions for building the SDK. E.g. the last time I had to change something in the SDK or otherwise build it from scratch, I needed to make a bash script for doing so.

I'm able to build the SDK manually without issue using unmodified changes in this PR and in zephyrproject-rtos/gcc#25 .

build.log.xz.txt (xz -d < build.log.xz.txt > build.log.txt)

Not 100% sure how to fix CI here, but it does not seem to be working.

@cfriedt
Copy link
Member Author

cfriedt commented Feb 12, 2024

Closing this in favour of using the ISO C11 threads API, as there are fewer moving parts and Zephyr does not yet have a "kernel headers" package to use in constructing the toolchain (or a numeric syscall system / ABI).

@cfriedt cfriedt closed this Feb 12, 2024
@stephanosio stephanosio deleted the enable-std-thread branch September 26, 2024 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: GCC Issues related to GCC (GNU Compiler Collection) area: libstdc++ Issues related to libstdc++ (GNU C++ Library)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants