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

CPython requires stdatomic.h #118034

Closed
encukou opened this issue Apr 18, 2024 · 2 comments
Closed

CPython requires stdatomic.h #118034

encukou opened this issue Apr 18, 2024 · 2 comments
Labels
build The build process and cross-build topic-C-API

Comments

@encukou
Copy link
Member

encukou commented Apr 18, 2024

According to PEP-7:

Python 3.11 and newer versions use C11 without optional features. The public C API should be compatible with C++.

However, CPython now requires #include <stdatomic.h> (an optional C11 feature) or MSVC. (Mimalloc can use C++ atomics, C11 atomics, or MSVC atomics. And pyatomic.h requires C11 atomics, MSVC atomics, or GCC atomics. The intersection is C11 or MSVC.)

This means CPython can't compile with GCC 4.8, as C11 atomics were added in GCC 4.9. See this buildbot failure for example. Granted, GCC 4.9 is very old and we can probably drop it, but I don't know how other compilers are affected.

@erlend-aasland erlend-aasland added the build The build process and cross-build label Apr 18, 2024
@colesbury
Copy link
Contributor

colesbury commented Apr 19, 2024

You can build CPython with GCC 4.8. Mimalloc is optional in the default build and is disabled by configure if stdatomic.h is not available.

I'm not sure what went wrong with the buildbot, but something is fishy. configure thought that stdatomic.h was present and that gcc does not need any options to enable C11 features, but GCC 4.8 needs -std=gnu11 for C11 features. I wonder if the compiler used for configure and make were different.

I built main successfully with an Ubuntu 18.04 image and GCC 4.8. There is this warning after running configure, but otherwise it builds fine:

configure: Your compiler or platform does have a working C11 stdatomic.h. A future version of Python may require stdatomic.h.

@encukou
Copy link
Member Author

encukou commented Apr 22, 2024

Right. That buildbot run was misconfigured (configure had an up-to-date GCC on $PATH, but the build apparently had a decade-old one O.o)

Sorry for the noise, and thank you for the info!

@encukou encukou closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build topic-C-API
Projects
None yet
Development

No branches or pull requests

3 participants