Skip to content

Resolve newer Linux os functions at runtime instead of compiling them out against old glibc #153400

Description

@daandemeyer

os gates functions like copy_file_range on an AC_CHECK_FUNCS probe at configure time and drops them entirely when the build libc lacks the symbol. Redistributable builds pay for this: python-build-standalone targets glibc 2.17 for portability, so every os function whose glibc wrapper is newer than 2.17 is gone for good, even when the interpreter later runs on a newer glibc or a kernel that implements the syscall.

Affected functions, with the glibc version that added the wrapper:

  • os.copy_file_range, os.memfd_create (2.27)
  • os.pidfd_open, os.pidfd_getfd (2.36)

pidfd_open and pidfd_getfd already sidestep it by calling the raw syscall directly.

On Linux we could resolve these at load time instead: dlsym the symbol once from a constructor, fall back to the raw syscall when the running libc doesn't have it, and keep the existing HAVE_* path everywhere else. Only functions above the 2.17 baseline need it. Same idea as #125022, but for libc symbols instead of SIMD.

Linked PRs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildextension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions