Skip to content

gh-90548: Fix musl version detection with --strip-all - #137864

Merged
vstinner merged 3 commits into
python:mainfrom
cdce8p:musl-libc_ver
Sep 1, 2025
Merged

vstinner merged 3 commits into
python:mainfrom
cdce8p:musl-libc_ver

Conversation

@cdce8p

@cdce8p cdce8p commented Aug 16, 2025 •

Copy link
Copy Markdown
Contributor

The change introduced in #131313 accidentally broke the musl version detection for test.support.linked_with_musl if cpython is compiled with --strip-all. In these cases the regex in platform.libc_ver should match the filename: libc.musl-x86_64.so.1.
https://pkgs.alpinelinux.org/contents?file=libc.*&path=&name=musl&branch=edge&repo=main&arch=

--strip-all is used among other things by the Alpine based Python docker image.
https://github.com/docker-library/python/blob/19c93d12094b07ecc21f67144a309c2fa0a10ef0/3.14-rc/alpine3.22/Dockerfile#L74

With this change:

./configure
make LDFLAGS="-Wl,--strip-all"

/usr/src # LD_LIBRARY_PATH=$PWD ./python.exe
Python 3.14.0rc2 (main, Aug 16 2025, 14:50:44) [GCC 14.2.0] on linux
>>> import test.support
>>> test.support.linked_to_musl()
(1,)

/usr/src # LD_LIBRARY_PATH=$PWD ./python.exe -m test.pythoninfo|grep libc
platform.libc_ver: musl 1

/CC @bitdancer

@AA-Turner AA-Turner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The added pattern seems ostensibly reasonable.

Comment thread Lib/platform.py Resolved
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Comment thread Lib/platform.py Resolved
@cdce8p

cdce8p commented Aug 16, 2025

Copy link
Copy Markdown
Contributor Author

@AA-Turner I believe the OS-Linux label might be incorrect. Alpine is technically unsupported. Never the less, since #131313 was added in 3.14, I would still appreciate if it could be backported. Especially as it also indirectly fixes test.support.linked_with_musl and thus some of the test failures on Alpine linux.

@AA-Turner

Copy link
Copy Markdown
Member

I would still appreciate if it could be backported.

I already added the backport label. Anything else missing?

I believe the OS-Linux label might be incorrect. Alpine is technically unsupported.

Fair enough, though "linux" is sufficiently vague that I think it is probably fine. Ideally we'd have a "libc-musl" label, but given as you say Alpine is unsupported, it's too niche at present.

@cdce8p

cdce8p commented Aug 16, 2025

Copy link
Copy Markdown
Contributor Author

I would still appreciate if it could be backported.

I already added the backport label. Anything else missing?

No, all good. I just wasn't sure if a fix for an unsupported platform meant it couldn't be backported.

@StanFromIreland

Copy link
Copy Markdown
Member

Fair enough, though "linux" is sufficiently vague that I think it is probably fine. Ideally we'd have a "libc-musl" label, but given as you say Alpine is unsupported, it's too niche at present.

FWIW we have a "musl" section in the Unsupported platforms project.

@cdce8p

cdce8p commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

@vstinner Would you mind taking a look at this one? I believe you also reviewed the predecessor #131313.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@vstinner
vstinner merged commit 6528cf4 into python:main Sep 1, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @cdce8p for the PR, and @vstinner 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 Sep 1, 2025
…-137864)

(cherry picked from commit 6528cf4)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Sep 1, 2025

Copy link
Copy Markdown

GH-138348 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 Sep 1, 2025
@vstinner

vstinner commented Sep 1, 2025

Copy link
Copy Markdown
Member

Merged, thanks for the fix and added tests!

@cdce8p
cdce8p deleted the musl-libc_ver branch September 1, 2025 17:22
hugovk pushed a commit that referenced this pull request Sep 7, 2025
…) (#138348)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
…ythonGH-137864) (python#138348)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
…37864)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants