gh-141600: Fix musl version detection on Void Linux (GH-141602)

This commit is contained in:
Andrew J. Hesford 2025-11-22 13:17:40 -05:00 committed by GitHub
parent c41fce08a5
commit 08477dbf30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 4 deletions

View file

@ -197,7 +197,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
| (GLIBC_([0-9.]+)) | (GLIBC_([0-9.]+))
| (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?) | (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
| (musl-([0-9.]+)) | (musl-([0-9.]+))
| (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?) | ((?:libc\.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
""", """,
re.ASCII | re.VERBOSE) re.ASCII | re.VERBOSE)
@ -236,7 +236,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
elif V(glibcversion) > V(ver): elif V(glibcversion) > V(ver):
ver = glibcversion ver = glibcversion
elif so: elif so:
if lib != 'glibc': if lib not in ('glibc', 'musl'):
lib = 'libc' lib = 'libc'
if soversion and (not ver or V(soversion) > V(ver)): if soversion and (not ver or V(soversion) > V(ver)):
ver = soversion ver = soversion

View file

@ -569,6 +569,8 @@ def test_libc_ver(self):
(b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')), (b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')),
(b'libc.musl.so.1', ('musl', '1')), (b'libc.musl.so.1', ('musl', '1')),
(b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')), (b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
(b'ld-musl.so.1', ('musl', '1')),
(b'ld-musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
(b'', ('', '')), (b'', ('', '')),
): ):
with open(filename, 'wb') as fp: with open(filename, 'wb') as fp:
@ -591,6 +593,10 @@ def test_libc_ver(self):
b'libc.musl-x86_64.so.1.4.1\0libc.musl-x86_64.so.2.1.1\0libc.musl-x86_64.so.2.0.1', b'libc.musl-x86_64.so.1.4.1\0libc.musl-x86_64.so.2.1.1\0libc.musl-x86_64.so.2.0.1',
('musl', '2.1.1'), ('musl', '2.1.1'),
), ),
(
b'ld-musl-x86_64.so.1.4.1\0ld-musl-x86_64.so.2.1.1\0ld-musl-x86_64.so.2.0.1',
('musl', '2.1.1'),
),
(b'no match here, so defaults are used', ('test', '100.1.0')), (b'no match here, so defaults are used', ('test', '100.1.0')),
): ):
with open(filename, 'wb') as f: with open(filename, 'wb') as f:

View file

@ -798,10 +798,10 @@ def test_linked_to_musl(self):
self.assertTrue(linked) self.assertTrue(linked)
# The value is cached, so make sure it returns the same value again. # The value is cached, so make sure it returns the same value again.
self.assertIs(linked, support.linked_to_musl()) self.assertIs(linked, support.linked_to_musl())
# The unlike libc, the musl version is a triple. # The musl version is either triple or just a major version number.
if linked: if linked:
self.assertIsInstance(linked, tuple) self.assertIsInstance(linked, tuple)
self.assertEqual(3, len(linked)) self.assertIn(len(linked), (1, 3))
for v in linked: for v in linked:
self.assertIsInstance(v, int) self.assertIsInstance(v, int)

View file

@ -0,0 +1 @@
Fix musl version detection on Void Linux.