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

Build failure due to missing _Py_SINGLETON in static-extension-modules build (3.13 only) #119661

Closed
kpfleming opened this issue May 28, 2024 · 8 comments
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@kpfleming
Copy link

kpfleming commented May 28, 2024

Bug report

Bug description:

While attempting to upgrade python-build-standalone to support Python 3.13 beta releases, we've run into a build failure which may be caused by Argument Clinic failing to ensure that all necessary #include directives are emitted into the source files it generates.

The failure can be seen here. Granted this is a very unusual way to build CPython, but given some of the discussions at the recent Packaging Summit it may become more valuable soon :-)

It was suggested that @vstinner might have the knowledge needed to understand what is happening here, so apologies in advance for the direct ping :-)

I'm happy to include patches into that build tree to see if we can overcome the problem before the next beta release, and I'm also happy to make that branch writable by others who want to try to help troubleshoot.

CPython versions tested on:

3.13

Operating systems tested on:

Linux, macOS, Windows

Linked PRs

@vstinner
Copy link
Member

The failure can be seen here.

cpython-3.13> ./Modules/clinic/_curses_panel.c.h: In function '_curses_panel_panel_move':
cpython-3.13> ./Modules/clinic/_curses_panel.c.h:169:36: error: implicit declaration of function '_Py_SINGLETON' [-Werror=implicit-function-declaration]
cpython-3.13>      #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
cpython-3.13>                                     ^
cpython-3.13> ./Modules/clinic/_curses_panel.c.h:178:20: note: in expansion of macro 'KWTUPLE'
cpython-3.13>          .kwtuple = KWTUPLE,
cpython-3.13>                     ^~~~~~~

_Py_SINGLETON() cannot and must not be used outside CPython internals.

If you use Argument Clinic, you can try to generate code using the limited C API instead.

@vstinner
Copy link
Member

@kpfleming
Copy link
Author

We are building CPython 3.13.0b1, the failure happens in the curses_panel module which is part of the standard extensions. It appears that somehow this code in the tree isn't aware that it is being built as 'internals', so we may be missing some sort of macro definition. This is no doubt an artifact of the somewhat ugly build system used in the python-build-standalone project.

@vstinner
Copy link
Member

Can you attach generated Modules/clinic/_curses_panel.c.h file?

@vstinner
Copy link
Member

vstinner commented May 28, 2024

Build command: cpython-3.13> /usr/bin/aarch64-linux-gnu-gcc -I/tools/deps/include/ncursesw -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -DHAVE_NCURSESW=1 -DPy_BUILD_CORE_BUILTIN -c ./Modules/_curses_panel.c -o Modules/_curses_panel.o

@kpfleming
Copy link
Author

We're building from the 3.13.0b1 tarball downloaded from python.org, which has that file (and presumably all of the other 'clinic' files) already generated and present in Modules/clinic.

vstinner added a commit to vstinner/cpython that referenced this issue May 29, 2024
When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
@vstinner
Copy link
Member

I wrote PR gh-119712 to add an explicit include to get the _Py_SINGLETON() macro. You can see that the PR changes Modules/clinic/_curses_panel.c.h to add:

#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#  include "pycore_runtime.h"     // _Py_SINGLETON()
#endif

vstinner added a commit that referenced this issue May 29, 2024
When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
vstinner added a commit to vstinner/cpython that referenced this issue May 29, 2024
…hon#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.

(cherry picked from commit 7ca74a7)
@kpfleming
Copy link
Author

kpfleming commented May 29, 2024

Thank you! We'll apply a local patch with the contents of that PR.

vstinner added a commit that referenced this issue May 29, 2024
…19712) (#119716)

gh-119661: Add _Py_SINGLETON() include in Argumenet Clinic (#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.

(cherry picked from commit 7ca74a7)
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…hon#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…hon#119712)

When the _Py_SINGLETON() is used, Argument Clinic now adds an
explicit "pycore_runtime.h" include to get the macro. Previously, the
macro may or may not be included indirectly by another include.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants