Skip to content

Commit c9a4a3d

Browse files
[3.14] gh-141600: Fix musl version detection on Void Linux (GH-141850)
(cherry picked from commit 08477db) Co-authored-by: Andrew J. Hesford <[email protected]>
1 parent 43d8b7f commit c9a4a3d

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Lib/platform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
199199
| (GLIBC_([0-9.]+))
200200
| (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
201201
| (musl-([0-9.]+))
202-
| (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
202+
| ((?:libc\.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
203203
""",
204204
re.ASCII | re.VERBOSE)
205205

@@ -238,7 +238,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
238238
elif V(glibcversion) > V(ver):
239239
ver = glibcversion
240240
elif so:
241-
if lib != 'glibc':
241+
if lib not in ('glibc', 'musl'):
242242
lib = 'libc'
243243
if soversion and (not ver or V(soversion) > V(ver)):
244244
ver = soversion

Lib/test/test_platform.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ def test_libc_ver(self):
562562
(b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')),
563563
(b'libc.musl.so.1', ('musl', '1')),
564564
(b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
565+
(b'ld-musl.so.1', ('musl', '1')),
566+
(b'ld-musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
565567
(b'', ('', '')),
566568
):
567569
with open(filename, 'wb') as fp:
@@ -584,6 +586,10 @@ def test_libc_ver(self):
584586
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',
585587
('musl', '2.1.1'),
586588
),
589+
(
590+
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',
591+
('musl', '2.1.1'),
592+
),
587593
(b'no match here, so defaults are used', ('test', '100.1.0')),
588594
):
589595
with open(filename, 'wb') as f:

Lib/test/test_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,10 @@ def test_linked_to_musl(self):
788788
self.assertTrue(linked)
789789
# The value is cached, so make sure it returns the same value again.
790790
self.assertIs(linked, support.linked_to_musl())
791-
# The unlike libc, the musl version is a triple.
791+
# The musl version is either triple or just a major version number.
792792
if linked:
793793
self.assertIsInstance(linked, tuple)
794-
self.assertEqual(3, len(linked))
794+
self.assertIn(len(linked), (1, 3))
795795
for v in linked:
796796
self.assertIsInstance(v, int)
797797

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix musl version detection on Void Linux.

0 commit comments

Comments
 (0)