[Python-checkins] bpo-43112: detect musl as a separate SOABI (GH-24502)

miss-islington webhook-mailer at python.org
Fri Jan 28 18:03:04 EST 2022


https://github.com/python/cpython/commit/1f036ede59e2c4befc07714cf76603c591d5c972
commit: 1f036ede59e2c4befc07714cf76603c591d5c972
branch: main
author: Natanael Copa <ncopa at alpinelinux.org>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-01-28T15:02:54-08:00
summary:

bpo-43112: detect musl as a separate SOABI (GH-24502)



musl libc and gnu libc are not ABI compatible so we need set different
SOABI for musl and not simply assume that all linux is linux-gnu.

Replace linux-gnu with the detected os for the build from config.guess
for linux-musl*.

files:
A Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
M Lib/test/test_sysconfig.py
M configure
M configure.ac

diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 80fe9c8a8b1e0..7ba004d77315d 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -433,11 +433,11 @@ def test_triplet_in_ext_suffix(self):
             self.assertTrue('linux' in suffix, suffix)
         if re.match('(i[3-6]86|x86_64)$', machine):
             if ctypes.sizeof(ctypes.c_char_p()) == 4:
-                self.assertTrue(suffix.endswith('i386-linux-gnu.so') or
-                                suffix.endswith('x86_64-linux-gnux32.so'),
-                                suffix)
+                expected_suffixes = 'i386-linux-gnu.so', 'x86_64-linux-gnux32.so', 'i386-linux-musl.so'
             else: # 8 byte pointer size
-                self.assertTrue(suffix.endswith('x86_64-linux-gnu.so'), suffix)
+                expected_suffixes = 'x86_64-linux-gnu.so', 'x86_64-linux-musl.so'
+        self.assertTrue(suffix.endswith(expected_suffixes),
+                        f'unexpected suffix {suffix!r}')
 
     @unittest.skipUnless(sys.platform == 'darwin', 'OS X-specific test')
     def test_osx_ext_suffix(self):
diff --git a/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst b/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
new file mode 100644
index 0000000000000..0e250edfa3ec1
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-02-10-17-54-04.bpo-43112.H5Lat6.rst
@@ -0,0 +1 @@
+Detect musl libc as a separate SOABI (tagged as ``linux-musl``).
\ No newline at end of file
diff --git a/configure b/configure
index 22c65e492fbab..da4af32cc17aa 100755
--- a/configure
+++ b/configure
@@ -6090,6 +6090,11 @@ EOF
 
 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
   PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' 	'`
+  case "$build_os" in
+  linux-musl*)
+    PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
+    ;;
+  esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PLATFORM_TRIPLET" >&5
 $as_echo "$PLATFORM_TRIPLET" >&6; }
 else
diff --git a/configure.ac b/configure.ac
index 9bc6e3beecbcc..5a076646b96dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -981,6 +981,11 @@ EOF
 
 if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
   PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' 	'`
+  case "$build_os" in
+  linux-musl*)
+    PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
+    ;;
+  esac
   AC_MSG_RESULT([$PLATFORM_TRIPLET])
 else
   AC_MSG_RESULT([none])



More information about the Python-checkins mailing list