Github messages for voidlinux
 help / color / mirror / Atom feed
From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [ISSUE] python: patch for ctypes.util.find_library on musl is incorrect on glibc
Date: Wed, 22 Dec 2021 21:33:39 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-34669@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]

New 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$"`).




             reply	other threads:[~2021-12-22 20:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 20:33 tornaria [this message]
2022-06-20  2:13 ` github-actions
2022-07-04  2:15 ` [ISSUE] [CLOSED] " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-34669@inbox.vuxu.org \
    --to=tornaria@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).