Skip to content

Commit 5422e3c

Browse files
authored
bpo-36722: Debug build loads libraries built in release mode (GH-12952)
In debug build, import now also looks for C extensions compiled in release mode and for C extensions compiled in the stable ABI.
1 parent 62dfd7d commit 5422e3c

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In debug build, import now also looks for C extensions compiled in release
2+
mode and for C extensions compiled in the stable ABI.

Python/dynload_shlib.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ const char *_PyImport_DynLoadFiletab[] = {
3838
".dll",
3939
#else /* !__CYGWIN__ */
4040
"." SOABI ".so",
41-
#ifndef Py_DEBUG
41+
#ifdef ALT_SOABI
42+
"." ALT_SOABI ".so",
43+
#endif
4244
".abi" PYTHON_ABI_STRING ".so",
43-
#endif /* ! Py_DEBUG */
4445
".so",
4546
#endif /* __CYGWIN__ */
4647
NULL,

configure

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ THREADHEADERS
632632
LIBPL
633633
PY_ENABLE_SHARED
634634
EXT_SUFFIX
635+
ALT_SOABI
635636
SOABI
636637
LIBC
637638
LIBM
@@ -15127,6 +15128,17 @@ SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFO
1512715128
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
1512815129
$as_echo "$SOABI" >&6; }
1512915130

15131+
if test "$Py_DEBUG" = 'true'; then
15132+
# Similar to SOABI but remove "d" flag from ABIFLAGS
15133+
15134+
ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
15135+
15136+
cat >>confdefs.h <<_ACEOF
15137+
#define ALT_SOABI "${ALT_SOABI}"
15138+
_ACEOF
15139+
15140+
fi
15141+
1513015142

1513115143
case $ac_sys_system in
1513215144
Linux*|GNU*|Darwin|VxWorks)

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4627,6 +4627,14 @@ AC_MSG_CHECKING(SOABI)
46274627
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
46284628
AC_MSG_RESULT($SOABI)
46294629

4630+
if test "$Py_DEBUG" = 'true'; then
4631+
# Similar to SOABI but remove "d" flag from ABIFLAGS
4632+
AC_SUBST(ALT_SOABI)
4633+
ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
4634+
AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}",
4635+
[Alternative SOABI used in debug build to load C extensions built in release mode])
4636+
fi
4637+
46304638
AC_SUBST(EXT_SUFFIX)
46314639
case $ac_sys_system in
46324640
Linux*|GNU*|Darwin|VxWorks)

pyconfig.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
support for AIX C++ shared extension modules. */
1313
#undef AIX_GENUINE_CPLUSPLUS
1414

15+
/* Alternative SOABI used in debug build to load C extensions built in release
16+
mode */
17+
#undef ALT_SOABI
18+
1519
/* The Android API level. */
1620
#undef ANDROID_API_LEVEL
1721

0 commit comments

Comments
 (0)