]> granicus.if.org Git - python/commitdiff
bpo-36465: Make release and debug ABI compatible (GH-12615)
authorVictor Stinner <vstinner@redhat.com>
Wed, 24 Apr 2019 22:56:28 +0000 (00:56 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Apr 2019 22:56:28 +0000 (00:56 +0200)
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

Doc/using/cmdline.rst
Include/object.h
Lib/test/support/__init__.py
Misc/NEWS.d/next/Build/2019-04-09-18-19-43.bpo-36465.-w6vx6.rst [new file with mode: 0644]
configure
configure.ac
pyconfig.h.in

index 0574336cf354038e6fe90440224d76552c9b1022..fd47ce2ab538497e59b6dfbf950e0a63df985c3f 100644 (file)
@@ -922,15 +922,18 @@ conflict.
 Debug-mode variables
 ~~~~~~~~~~~~~~~~~~~~
 
-Setting these variables only has an effect in a debug build of Python, that is,
-if Python was configured with the ``--with-pydebug`` build option.
+Setting these variables only has an effect in a debug build of Python.
 
 .. envvar:: PYTHONTHREADDEBUG
 
    If set, Python will print threading debug info.
 
+   Need Python configured with the ``--with-pydebug`` build option.
+
 
 .. envvar:: PYTHONDUMPREFS
 
    If set, Python will dump objects and reference counts still alive after
    shutting down the interpreter.
+
+   Need Python configured with the ``--with-trace-refs`` build option.
index 86cbfc581ed181427e51362c98d8dd95a832a94b..13e88a6dc6f02a6b67c9c6e2ef91b1049496f30b 100644 (file)
@@ -54,13 +54,8 @@ A standard interface exists for objects that contain an array of items
 whose size is determined when the object is allocated.
 */
 
-/* Py_DEBUG implies Py_TRACE_REFS. */
-#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)
-#define Py_TRACE_REFS
-#endif
-
-/* Py_TRACE_REFS implies Py_REF_DEBUG. */
-#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
+/* Py_DEBUG implies Py_REF_DEBUG. */
+#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
 #define Py_REF_DEBUG
 #endif
 
index 2bb561b4cee1371ede367d2b6cabeabfd9244c8d..dc96318b38f7b9a4cdfc28aaba0e0a3abeb2e7e7 100644 (file)
@@ -1653,7 +1653,7 @@ def python_is_optimized():
 
 _header = 'nP'
 _align = '0n'
-if hasattr(sys, "gettotalrefcount"):
+if hasattr(sys, "getobjects"):
     _header = '2P' + _header
     _align = '0P'
 _vheader = _header + 'n'
diff --git a/Misc/NEWS.d/next/Build/2019-04-09-18-19-43.bpo-36465.-w6vx6.rst b/Misc/NEWS.d/next/Build/2019-04-09-18-19-43.bpo-36465.-w6vx6.rst
new file mode 100644 (file)
index 0000000..52de1ef
--- /dev/null
@@ -0,0 +1,5 @@
+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 :func:`sys.getobjects`
+function and ``PYTHONDUMPREFS`` environment variable.
index e96c03ad4f59422d59aa7141f63e16fc2b235cd6..b02d17c053c6b5b859ed19dcd6762277ec539b9d 100755 (executable)
--- a/configure
+++ b/configure
@@ -814,6 +814,7 @@ with_suffix
 enable_shared
 enable_profiling
 with_pydebug
+with_trace_refs
 with_assertions
 enable_optimizations
 with_lto
@@ -1500,6 +1501,7 @@ Optional Packages:
                           compiler
   --with-suffix=.exe      set executable suffix
   --with-pydebug          build with Py_DEBUG defined
+  --with-trace-refs       enable tracing references for debugging purpose
   --with-assertions       build with C assertions enabled
   --with-lto              Enable Link Time Optimization in any build. Disabled
                           by default.
@@ -6333,8 +6335,30 @@ $as_echo "no" >&6; }
 fi
 
 
-# Check for --with-assertions. Py_DEBUG implies assertions, but also changes
-# the ABI. This allows enabling assertions without changing the ABI.
+# Check for --with-trace-refs
+# --with-trace-refs
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-trace-refs" >&5
+$as_echo_n "checking for --with-trace-refs... " >&6; }
+
+# Check whether --with-trace-refs was given.
+if test "${with_trace_refs+set}" = set; then :
+  withval=$with_trace_refs;
+else
+  with_trace_refs=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_trace_refs" >&5
+$as_echo "$with_trace_refs" >&6; }
+
+if test "$with_trace_refs" = "yes"
+then
+
+$as_echo "#define Py_TRACE_REFS 1" >>confdefs.h
+
+fi
+
+# Check for --with-assertions.
+# This allows enabling assertions without Py_DEBUG.
 assertions='false'
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-assertions" >&5
 $as_echo_n "checking for --with-assertions... " >&6; }
index 3f378c97345e2aead88aa2b4ae545f44ed70e7ba..65d3f8e69129836daf03a5328dac656524f64e63 100644 (file)
@@ -1228,8 +1228,21 @@ else AC_MSG_RESULT(no); Py_DEBUG='false'
 fi],
 [AC_MSG_RESULT(no)])
 
-# Check for --with-assertions. Py_DEBUG implies assertions, but also changes
-# the ABI. This allows enabling assertions without changing the ABI.
+# Check for --with-trace-refs
+# --with-trace-refs
+AC_MSG_CHECKING(for --with-trace-refs)
+AC_ARG_WITH(trace-refs,
+  AS_HELP_STRING([--with-trace-refs],[enable tracing references for debugging purpose]),,
+  with_trace_refs=no)
+AC_MSG_RESULT($with_trace_refs)
+
+if test "$with_trace_refs" = "yes"
+then
+  AC_DEFINE(Py_TRACE_REFS, 1, [Define if you want to enable tracing references for debugging purpose])
+fi
+
+# Check for --with-assertions.
+# This allows enabling assertions without Py_DEBUG.
 assertions='false'
 AC_MSG_CHECKING(for --with-assertions)
 AC_ARG_WITH(assertions,
index d41d57932766be92702d0a0754ca9d89aca693b2..562c0271133bdc78597e108b7c33b4b2206130e6 100644 (file)
    externally defined: 0 */
 #undef Py_HASH_ALGORITHM
 
+/* Define if you want to enable tracing references for debugging purpose */
+#undef Py_TRACE_REFS
+
 /* assume C89 semantics that RETSIGTYPE is always void */
 #undef RETSIGTYPE