Closed issue by tornaria on void-packages repository https://github.com/void-linux/void-packages/issues/34669 Description: - Patch: https://github.com/void-linux/void-packages/blob/master/srcpkgs/python3/patches/musl-find_library.patch - Original file: https://hg.python.org/cpython/file/tip/Lib/ctypes/util.py#l243 The patch unconditonally replaces the logic for `find_library` by a custom version _"for Alpine Linux / musl - search manually system paths"_. This is incorrect in glibc as in the following snippet: ``` Python 3.10.1 (main, Dec 8 2021, 19:45:26) [GCC 10.2.1 20201203] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ctypes.util >>> ctypes.util.find_library('m') 'libc.so.6' >>> ctypes.util.find_library('pthread') 'libc.so.6' >>> ctypes.util.find_library('crypt') 'libc.so.6' ``` The correct values should be `libm.so.6`, `libpthreads.so.0` and `libcrypt.so.1`. Note also that ``` >>> ctypes.util.find_library('bz2') 'libbz2.so' ``` instead of `libbz2.so.1` just because I happen to have `bzip2-devel` installed. On unpatched python this always returns `libbz2.so.1` on glibc. On musl this fails (returns None) unless `bzip2-devel` (and `gcc` or `binutils`) are installed, and in this case it returns `libbz2.so.1`. It seems to me that it would be more appropriate to place the implementation in the patch as a separate function `_find_library_musl` that it's only called *after* the other cases in https://hg.python.org/cpython/file/tip/Lib/ctypes/util.py#l303 have been tried and failed. Also, in addition to crypt, m and pthread, there are more libraries included in libc.so: dl, resolv, rt, util, xnet (this list obtained by looking at `xbps-query -f musl-devel | grep "\.a$"`).