aports/main/python3/gnu-fallback-soabi.patch
Natanael Copa 9611da22b5 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)
2021-11-24 22:19:13 +01:00

34 lines
1.2 KiB
Diff

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