Skip to content

Conversation

@ahesford
Copy link
Contributor

@ahesford ahesford commented Nov 15, 2025

This patch amends the search patterns in the function platform.libc_ver to properly recognize musl on Void Linux. Unlike Alpine, Void does not provide a libc.musl symlink that points to the linker, so executables link to a generic (and unversioned) libc.so, which is just a symlink to the linker at ld-musl-${arch}.so.${version}. By slightly modifying the pattern to accept ld-musl in addition to libc.musl, the function will pick up the linker encoded in executable rather than the generic C library path.

This patch also prevents a match against libc.so from setting the returned library name to libc when the library name has already been set to glibc or musl. Previously, the exclusion only applied when the library name was already set to glibc. This change is necessary because the pattern matching will pick up Void's generic libc.so after it has picked up the ld-linux linker path.

Finally, a unit test that relies (via the linked_to_musl function) on the version returned by libc_ver has been amended to accept a returned version consisting only of a single major number in addition to a complete full (major, minor, patch) triplet. The patterns admit the possibility that only the major version is known, so this must be accommodated.

@python-cla-bot
Copy link

python-cla-bot bot commented Nov 15, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@zware
Copy link
Member

zware commented Nov 17, 2025

!buildbot Alpine

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @zware for commit 87f95c1 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F141602%2Fmerge

The command will test the builders whose names match following regular expression: Alpine

The builders matched are:

  • AMD64 Alpine Linux PR
  • AMD64 Alpine Linux NoGIL PR

Lib/platform.py Outdated
| (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
| (musl-([0-9.]+))
| (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
| ((?:libc.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug in the existing regex, it should be libc\. instead of libc., no?

Suggested change
| ((?:libc.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
| ((?:libc\.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the bug and thought about fixing it, but then I wondered what esoteric musl-based distribution would break if the regex gets more specific. If this is not a concern, we can quote the dot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If later we discover Linux distributions where musl is not properly detected, we can update the regex again. For now, I would prefer to use a strict libc\..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@zware zware merged commit 08477db into python:main Nov 22, 2025
50 checks passed
@zware zware added the needs backport to 3.14 bugs and security fixes label Nov 22, 2025
@miss-islington-app
Copy link

Thanks @ahesford for the PR, and @zware for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2025
@bedevere-app
Copy link

bedevere-app bot commented Nov 22, 2025

GH-141850 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Nov 22, 2025
@ahesford ahesford deleted the zuppa_di_pesce branch November 22, 2025 19:14
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants