Does CPython have a minimum supported Linux kernel version and/or a minimum supported glibc version? PEP 11 gives a Windows version support policy, but doesn’t say anything about Linux versions.
I have a particular reason for asking this that may not require y’all to decide on a general policy right now. (Though I do think a general policy, or the documented lack of one, would be a good idea.)
I’m working on a PR to use Linux statx(2) to implement os.stat to provide st_birthtime and new Linux-specific fields. My PR would be simpler if I could assume the statx system call exists at runtime and that libc provides a syscall wrapper function at compile time and run time. (I wrote about this in the issue, but so far only the author of an older PR responded.)
The statx system call was introduced in Linux 4.11, released April 2017. The oldest currently-supported upstream LTS branch is 5.4, released November 2019. If I am reading the RHEL life cycle and RHEL release dates correctly, the oldest supported release is RHEL8, based on kernel 4.18. It is likely that all mainstream Linux distributions ship kernels supporting statx, but also likely that some embedded environments are stuck on older kernels.
The code to fall back to the regular stat system call is not complex, but it is difficult to test. (Possible approaches include somehow poking the function-static variable that triggers the fallback, using an LD_PRELOAD hook to provide a new statx wrapper function that fails with ENOSYS, using a seccomp policy to fall the syscall with ENOSYS, or specifically testing on an older kernel or older glibc.)
glibc introduced a wrapper function for statx in version 2.28, released August 2018.
If I can’t depend on the wrapper being available at build time, I can provide my own definition for struct statx and use syscall(2) to make the call, falling back to stat on ENOSYS. I already have to provide a few constant definitions because of how statx is extensible, but this would add more. (I presume simply building a binary without statx support isn’t an option because explaining why some builds don’t have it would be difficult.)
If I can’t depend on the wrapper being available at run time, I can weakly link and fall back to stat if it isn’t available (or on ENOSYS).
My PR currently assumes the wrapper function is available at build time, but falls back to stat if the wrapper isn’t available at runtime or if it fails with ENOSYS. I don’t plan to implement tests for the fallback path unless someone else has a simpler idea of how to do that.
