main/python3: add fallback for -gnu soabi

In commit b89cfd222ae3 (main/python3: use musl SOABI) a patch was
introduced to make it easier to detect a musl built python and with the
intention to make it easier to build python wheels without clashing with
musl binaries. It was a wrong assumption that pip acutally care about
the SOABI.

Meanwhile upstream python has been working on adding support for musl
binaries (pep 656), which does not rely on SOABI. This has resulted in
breakage with alpine built python which no longer loads binaries with
-gnu.so suffix.

As a workaround we add a patch to also look for shared libraries with
-gnu.so suffix in addition to -musl.so.

ref https://gitlab.alpinelinux.org/alpine/aports/-/issues/13227

(cherry picked from commit 6ad1b1f09f10f406e90ea8471fe5f3ff1942448b)
This commit is contained in:
Natanael Copa 2021-11-24 21:18:39 +01:00
parent 17cf5cdf48
commit 9611da22b5
2 changed files with 36 additions and 1 deletions

View File

@ -6,7 +6,7 @@ pkgname=python3
pkgver=3.9.5
_bluez_ver=5.55
_basever="${pkgver%.*}"
pkgrel=1
pkgrel=2
pkgdesc="A high-level scripting language"
url="https://www.python.org/"
arch="all"
@ -23,6 +23,7 @@ source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
arm-alignment.patch
mpdecimal-2.5.1.patch
bpo-43112.patch
gnu-fallback-soabi.patch
"
options="net" # Required for tests
builddir="$srcdir/Python-$pkgver"
@ -202,4 +203,5 @@ ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e9
a84483246e413650a904c34c18f5e4f4168c39067d069f48557c330de6eb3db19fd96a4d453d742db3dcb7c7f962722903f62823c752ff90510c89830435ffc0 arm-alignment.patch
d95e36ef3c315a2ddf689c9319e027cf56e8817b0cae139e3ade4742ab6f9efcb3cc4adca178e9bbc8757bd0e3fb924ac2b37e66e70eaa7288202a25339eed7d mpdecimal-2.5.1.patch
68a3b0bc270e4f7ec8593945c8c891fab988489f4ba9ee78a0e4351df0699db16dfad7d374f13758c80962b0cea048ff577c0462857cd13919d6cefa1f6a382f bpo-43112.patch
7500d4e51975446fd59231985f75a198e8074b9f0a0941b7998958e8a4175de09bd08fd1b4db26aa82f9cef0db922078bf4a6f05e50abc37a200c5f6169e6868 gnu-fallback-soabi.patch
"

View File

@ -0,0 +1,33 @@
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
index 23828898d3..6ad95e757e 100644
--- a/Python/dynload_shlib.c
+++ b/Python/dynload_shlib.c
@@ -39,6 +39,9 @@ const char *_PyImport_DynLoadFiletab[] = {
".dll",
#else /* !__CYGWIN__ */
"." SOABI ".so",
+#ifdef GNU_FALLBACK_SOABI
+ "." GNU_FALLBACK_SOABI ".so",
+#endif
#ifdef ALT_SOABI
"." ALT_SOABI ".so",
#endif
diff --git a/configure.ac b/configure.ac
index 0e6b617080..72700cba84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4781,6 +4781,14 @@ AC_MSG_CHECKING(SOABI)
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
AC_MSG_RESULT($SOABI)
+# musl libc fallback to read -gnu SOABI for backwards compat
+if test "$SOABI" != "${SOABI%-musl}"; then
+ AC_SUBST(GNU_FALLBACK_SOABI)
+ GNU_FALLBACK_SOABI="${SOABI%-musl}-gnu"
+ AC_DEFINE_UNQUOTED(GNU_FALLBACK_SOABI, "${GNU_FALLBACK_SOABI}",
+ [Compatibility to read C extentions with -gnu suffix on musl libc])
+fi
+
# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI
if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then
# Similar to SOABI but remove "d" flag from ABIFLAGS