]> granicus.if.org Git - python/commitdiff
bpo-36722: Debug build loads libraries built in release mode (GH-12952)
authorVictor Stinner <vstinner@redhat.com>
Thu, 25 Apr 2019 23:40:00 +0000 (01:40 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2019 23:40:00 +0000 (01:40 +0200)
In debug build, import now also looks for C extensions compiled in
release mode and for C extensions compiled in the stable ABI.

Misc/NEWS.d/next/Core and Builtins/2019-04-25-21-02-40.bpo-36722.8NApVM.rst [new file with mode: 0644]
Python/dynload_shlib.c
configure
configure.ac
pyconfig.h.in

diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-04-25-21-02-40.bpo-36722.8NApVM.rst b/Misc/NEWS.d/next/Core and Builtins/2019-04-25-21-02-40.bpo-36722.8NApVM.rst
new file mode 100644 (file)
index 0000000..210a7e0
--- /dev/null
@@ -0,0 +1,2 @@
+In debug build, import now also looks for C extensions compiled in release
+mode and for C extensions compiled in the stable ABI.
index e5bddaab6caa0694fea760524cb31e8e5f47c869..c51f97abd286306ac4bf981945acdd0668e5a251 100644 (file)
@@ -38,9 +38,10 @@ const char *_PyImport_DynLoadFiletab[] = {
     ".dll",
 #else  /* !__CYGWIN__ */
     "." SOABI ".so",
-#ifndef Py_DEBUG
+#ifdef ALT_SOABI
+    "." ALT_SOABI ".so",
+#endif
     ".abi" PYTHON_ABI_STRING ".so",
-#endif /* ! Py_DEBUG */
     ".so",
 #endif  /* __CYGWIN__ */
     NULL,
index b02d17c053c6b5b859ed19dcd6762277ec539b9d..b2775cf04000fd0ab1eb6a74c34d2cdfa70d533d 100755 (executable)
--- a/configure
+++ b/configure
@@ -632,6 +632,7 @@ THREADHEADERS
 LIBPL
 PY_ENABLE_SHARED
 EXT_SUFFIX
+ALT_SOABI
 SOABI
 LIBC
 LIBM
@@ -15127,6 +15128,17 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFO
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
 $as_echo "$SOABI" >&6; }
 
+if test "$Py_DEBUG" = 'true'; then
+  # Similar to SOABI but remove "d" flag from ABIFLAGS
+
+  ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
+
+cat >>confdefs.h <<_ACEOF
+#define ALT_SOABI "${ALT_SOABI}"
+_ACEOF
+
+fi
+
 
 case $ac_sys_system in
     Linux*|GNU*|Darwin|VxWorks)
index 65d3f8e69129836daf03a5328dac656524f64e63..312758788e4d7aaca3409a7df8989deb4e92ab85 100644 (file)
@@ -4627,6 +4627,14 @@ AC_MSG_CHECKING(SOABI)
 SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
 AC_MSG_RESULT($SOABI)
 
+if test "$Py_DEBUG" = 'true'; then
+  # Similar to SOABI but remove "d" flag from ABIFLAGS
+  AC_SUBST(ALT_SOABI)
+  ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
+  AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}",
+            [Alternative SOABI used in debug build to load C extensions built in release mode])
+fi
+
 AC_SUBST(EXT_SUFFIX)
 case $ac_sys_system in
     Linux*|GNU*|Darwin|VxWorks)
index 562c0271133bdc78597e108b7c33b4b2206130e6..4b7796147274065fc4c40cda7b295866bec2d88f 100644 (file)
    support for AIX C++ shared extension modules. */
 #undef AIX_GENUINE_CPLUSPLUS
 
+/* Alternative SOABI used in debug build to load C extensions built in release
+   mode */
+#undef ALT_SOABI
+
 /* The Android API level. */
 #undef ANDROID_API_LEVEL