Skip to content

Enable os.memfd_create through runtime weak linking#1164

Open
jjhelmus wants to merge 6 commits into
mainfrom
jjh/weak_sym_memfd_create
Open

Enable os.memfd_create through runtime weak linking#1164
jjhelmus wants to merge 6 commits into
mainfrom
jjh/weak_sym_memfd_create

Conversation

@jjhelmus

Copy link
Copy Markdown
Contributor

Always build CPython with os.memfd_create but remove the Python function from the namespace at runtime when glibc does not provide the an implementation.

This is accomplished using a weak memfd_create symbol which is evaluated at runtime.

This requires the modern kernel UAPI headers from #1163 to define the MFD_* constants.

jjhelmus added 6 commits June 24, 2026 15:14
Package Debian's linux-libc-dev headers as a build dependency for
*-linux-gnu targets.

This new linux-uapi package provides userspace header from a modern
Linux kernel (currently 7.0.12).

When building CPython on *-linux-gnu targets use these headers to enable
modern kernel features, such as os.pidfp_open. At runtime if the kernel
does not support the needed syscalls ENOSYS will be returned.
Verify that no sysconfig variables contains the build-only linux-uapi path.
Verify that building against the modern Linux UAPI headers enables
os.pidfd_open on GNU/Linux targets.
@jjhelmus jjhelmus added platform:linux Specific to the Linux platform arch:all Select all architectures labels Jun 24, 2026
@zanieb

zanieb commented Jun 24, 2026

Copy link
Copy Markdown
Member

We should definitely try to upstream any weak linking implementations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:all Select all architectures platform:linux Specific to the Linux platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants