8000 bpo-36465: Make release and debug ABI compatible (GH-12615) · python/cpython@f4e4703 · GitHub
[go: up one dir, main page]

Skip to content

Commit f4e4703

Browse files
authored
bpo-36465: Make release and debug ABI compatible (GH-12615)
Release build and debug build are now ABI compatible: the Py_DEBUG define no longer implies Py_TRACE_REFS define which introduces the only ABI incompatibility. A new "./configure --with-trace-refs" build option is now required to get Py_TRACE_REFS define which adds sys.getobjects() function and PYTHONDUMPREFS environment variable. Changes: * Add ./configure --with-trace-refs * Py_DEBUG no longer implies Py_TRACE_REFS
1 parent 888f37b commit f4e4703

File tree

7 files changed

+57
-14
lines changed

7 files changed

+57
-14
lines changed

Doc/using/cmdline.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,15 +922,18 @@ conflict.
922922
Debug-mode variables
923923
~~~~~~~~~~~~~~~~~~~~
924924

925-
Setting these variables only has an effect in a debug build of Python, that is,
926-
if Python was configured with the ``--with-pydebug`` build option.
925+
Setting these variables only has an effect in a debug build of Python.
927926

928927
.. envvar:: PYTHONTHREADDEBUG
929928

930929
If set, Python will print threading debug info.
931930

931+
Need Python configured with the ``--with-pydebug`` build option.
932+
932933

933934
.. envvar:: PYTHONDUMPREFS
934935

935936
If set, Python will dump objects and reference counts still alive after
936937
shutting down the interpreter.
938+
939+
Need Python configured with the ``--with-trace-refs`` build option.

Include/object.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,8 @@ A standard interface exists for objects that contain an array of items
5454
whose size is determined when the object is allocated.
5555
*/
5656

57-
/* Py_DEBUG implies Py_TRACE_REFS. */
58-
#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)
59-
#define Py_TRACE_REFS
60-
#endif
61-
62-
/* Py_TRACE_REFS implies Py_REF_DEBUG. */
63-
#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
57+
/* Py_DEBUG implies Py_REF_DEBUG. */
58+
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
6459
#define Py_REF_DEBUG
6560
#endif
6661

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ def python_is_optimized():
16531653

16541654
_header = 'nP'
16551655
_align = '0n'
1656-
if hasattr(sys, "gettotalrefcount"):
1656+
if hasattr(sys, "getobjects"):
16571657
_header = '2P' + _header
16581658
_align = '0P'
16591659
_vheader = _header + 'n'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Release build and debug build are now ABI compatible: the ``Py_DEBUG`` define
2+
no longer implies ``Py_TRACE_REFS`` define which introduces the only ABI
3+
incompatibility. A new ``./configure --with-trace-refs`` build option is now
4+
required to get ``Py_TRACE_REFS`` define which adds :func:`sys.getobjects`
5+
function and ``PYTHONDUMPREFS`` environment variable.

configure

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ with_suffix
814814
enable_shared
815815
enable_profiling
816816
with_pydebug
817+
with_trace_refs
817818
with_assertions
818819
enable_optimizations
819820
with_lto
@@ -1500,6 +1501,7 @@ Optional Packages:
15001501
compiler
15011502
--with-suffix=.exe set executable suffix
15021503
--with-pydebug build with Py_DEBUG defined
1504+
--with-trace-refs enable tracing references for debugging purpose
15031505
--with-assertions build with C assertions enabled
15041506
--with-lto Enable Link Time Optimization in any build. Disabled
15051507
by default.
@@ -6333,8 +6335,30 @@ $as_echo "no" >&6; }
63336335
fi
63346336

63356337

6336-
# Check for --with-assertions. Py_DEBUG implies assertions, but also changes
6337-
# the ABI. This allows enabling assertions without changing the ABI.
6338+
# Check for --with-trace-refs
6339+
# --with-trace-refs
6340+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-trace-refs" >&5
6341+
$as_echo_n "checking for --with-trace-refs... " >&6; }
6342+
6343+
# Check whether --with-trace-refs was given.
6344+
if test "${with_trace_refs+set}" = set; then :
6345+
withval=$with_trace_refs;
6346+
else
6347+
with_trace_refs=no
6348+
fi
6349+
6350+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_trace_refs" >&5
6351+
$as_echo "$with_trace_refs" >&6; }
6352+
6353+
if test "$with_trace_refs" = "yes"
6354+
then
6355+
6356+
$as_echo "#define Py_TRACE_REFS 1" >>confdefs.h
6357+
6358+
fi
6359+
6360+
# Check for --with-assertions.
6361+
# This allows enabling assertions without Py_DEBUG.
63386362
assertions='false'
63396363
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-assertions" >&5
63406364
$as_echo_n "checking for --with-assertions... " >&6; }

configure.ac

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,21 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
12281228
fi],
12291229
[AC_MSG_RESULT(no)])
12301230

1231-
# Check for --with-assertions. Py_DEBUG implies assertions, but also changes
1232-
# the ABI. This allows enabling assertions without changing the ABI.
1231+
# Check for --with-trace-refs
1232+
# --with-trace-refs
1233+
AC_MSG_CHECKING(for --with-trace-refs)
1234+
AC_ARG_WITH(trace-refs,
1235+
AS_HELP_STRING([--with-trace-refs],[enable tracing references for debugging purpose]),,
1236+
with_trace_refs=no)
1237+
AC_MSG_RESULT($with_trace_refs)
1238+
1239+
if test "$with_trace_refs" = "yes"
1240+
then
1241+
AC_DEFINE(Py_TRACE_REFS, 1, [Define if you want to enable tracing references for debugging purpose])
1242+
fi
1243+
1244+
# Check for --with-assertions.
1245+
# This allows enabling assertions without Py_DEBUG.
12331246
assertions='false'
12341247
AC_MSG_CHECKING(for --with-assertions)
12351248
AC_ARG_WITH(assertions,

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,9 @@
13741374
externally defined: 0 */
13751375
#undef Py_HASH_ALGORITHM
13761376

1377+
/* Define if you want to enable tracing references for debugging purpose */
1378+
#undef Py_TRACE_REFS
1379+
13771380
/* assume C89 semantics that RETSIGTYPE is always void */
13781381
#undef RETSIGTYPE
13791382

0 commit comments

Comments
 (0)
0