Skip to content

Commit fa53a96

Browse files
committed
gh-141600: fix musl detection on Void Linux
1 parent 85f3009 commit fa53a96

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
@@ -197,7 +197,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
197197
| (GLIBC_([0-9.]+))
198198
| (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
199199
| (musl-([0-9.]+))
200-
| (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
200+
| ((?:libc.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
201201
""",
202202
re.ASCII | re.VERBOSE)
203203

@@ -236,7 +236,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
236236
elif V(glibcversion) > V(ver):
237237
ver = glibcversion
238238
elif so:
239-
if lib != 'glibc':
239+
if lib not in ('glibc', 'musl'):
240240
lib = 'libc'
241241
if soversion and (not ver or V(soversion) > V(ver)):
242242
ver = soversion

Lib/test/test_platform.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@ def test_libc_ver(self):
569569
(b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')),
570570
(b'libc.musl.so.1', ('musl', '1')),
571571
(b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
572+
(b'ld-musl.so.1', ('musl', '1')),
573+
(b'ld-musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
572574
(b'', ('', '')),
573575
):
574576
with open(filename, 'wb') as fp:
@@ -591,6 +593,10 @@ def test_libc_ver(self):
591593
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',
592594
('musl', '2.1.1'),
593595
),
596+
(
597+
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',
598+
('musl', '2.1.1'),
599+
),
594600
(b'no match here, so defaults are used', ('test', '100.1.0')),
595601
):
596602
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
@@ -798,10 +798,10 @@ def test_linked_to_musl(self):
798798
self.assertTrue(linked)
799799
# The value is cached, so make sure it returns the same value again.
800800
self.assertIs(linked, support.linked_to_musl())
801-
# The unlike libc, the musl version is a triple.
801+
# The musl version is either triple or just a major version number.
802802
if linked:
803803
self.assertIsInstance(linked, tuple)
804-
self.assertEqual(3, len(linked))
804+
self.assertIn(len(linked), (1, 3))
805805
for v in linked:
806806
self.assertIsInstance(v, int)
807807

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)