Skip to content

Commit a41782c

Browse files
authored
bpo-43774: Document configure options (GH-25283)
Add Doc/using/configure.rst documentation to document configure, preprocessor, compiler and linker options. Add a new section about the "Python debug build".
1 parent d92c59f commit a41782c

20 files changed

+678
-47
lines changed

Doc/c-api/init_config.rst

+12-7
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ PyPreConfig
241241
* ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc
242242
memory allocator <pymalloc>` with debug hooks
243243
244-
``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG``
245-
are not supported if Python is configured using ``--without-pymalloc``
244+
``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are
245+
not supported if Python is :option:`configured using --without-pymalloc
246+
<--without-pymalloc>`.
246247
247248
See :ref:`Memory Management <memory>`.
248249
@@ -636,7 +637,8 @@ PyConfig
636637
637638
Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable.
638639
639-
Need a special build of Python with the ``Py_TRACE_REFS`` macro defined.
640+
Need a special build of Python with the ``Py_TRACE_REFS`` macro defined:
641+
see :option:`configure --with-trace-refs <--with-trace-refs>`.
640642
641643
Default: ``0``.
642644
@@ -817,7 +819,8 @@ PyConfig
817819
818820
Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable.
819821
820-
The option is ignored if Python is built using ``--without-pymalloc``.
822+
The option is ignored if Python is :option:`configured using
823+
--without-pymalloc <--without-pymalloc>`.
821824
822825
Default: ``0``.
823826
@@ -827,8 +830,9 @@ PyConfig
827830
828831
Set by the :envvar:`PYTHONPLATLIBDIR` environment variable.
829832
830-
Default: value of the ``PLATLIBDIR`` macro which is set at configure time
831-
by ``--with-platlibdir`` (default: ``"lib"``).
833+
Default: value of the ``PLATLIBDIR`` macro which is set by the
834+
:option`configure --with-platlibdir option <--with-platlibdir>` (default:
835+
``"lib"``).
832836
833837
Part of the :ref:`Python Path Configuration <init-path-config>` input.
834838
@@ -1016,7 +1020,8 @@ PyConfig
10161020
10171021
Set to 1 by :option:`-X showrefcount <-X>` command line option.
10181022
1019-
Need a debug build of Python (``Py_REF_DEBUG`` macro must be defined).
1023+
Need a :ref:`debug build of Python <debug-build>` (the ``Py_REF_DEBUG``
1024+
macro must be defined).
10201025
10211026
Default: ``0``.
10221027

Doc/c-api/intro.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,10 @@ allocator, or low-level profiling of the main interpreter loop. Only the most
742742
frequently-used builds will be described in the remainder of this section.
743743

744744
Compiling the interpreter with the :c:macro:`Py_DEBUG` macro defined produces
745-
what is generally meant by "a debug build" of Python. :c:macro:`Py_DEBUG` is
746-
enabled in the Unix build by adding ``--with-pydebug`` to the
747-
:file:`./configure` command. It is also implied by the presence of the
745+
what is generally meant by :ref:`a debug build of Python <debug-build>`.
746+
:c:macro:`Py_DEBUG` is enabled in the Unix build by adding
747+
:option:`--with-pydebug` to the :file:`./configure` command.
748+
It is also implied by the presence of the
748749
not-Python-specific :c:macro:`_DEBUG` macro. When :c:macro:`Py_DEBUG` is enabled
749750
in the Unix build, compiler optimization is disabled.
750751

@@ -778,7 +779,7 @@ Defining :c:macro:`Py_TRACE_REFS` enables reference tracing. When defined, a
778779
circular doubly linked list of active objects is maintained by adding two extra
779780
fields to every :c:type:`PyObject`. Total allocations are tracked as well. Upon
780781
exit, all existing references are printed. (In interactive mode this happens
781-
after every statement run by the interpreter.) Implied by :c:macro:`Py_DEBUG`.
782+
after every statement run by the interpreter.)
782783

783784
Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution
784785
for more detailed information.

Doc/c-api/memory.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,12 @@ Debug build, without pymalloc ``"malloc_debug"`` ``malloc`` + debug ``mal
385385
386386
Legend:
387387
388-
* Name: value for :envvar:`PYTHONMALLOC` environment variable
388+
* Name: value for :envvar:`PYTHONMALLOC` environment variable.
389389
* ``malloc``: system allocators from the standard C library, C functions:
390-
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`
391-
* ``pymalloc``: :ref:`pymalloc memory allocator <pymalloc>`
392-
* "+ debug": with debug hooks installed by :c:func:`PyMem_SetupDebugHooks`
390+
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.
391+
* ``pymalloc``: :ref:`pymalloc memory allocator <pymalloc>`.
392+
* "+ debug": with debug hooks installed by :c:func:`PyMem_SetupDebugHooks`.
393+
* "Debug build": :ref:`Python build in debug mode <debug-build>`.
393394
394395
.. _customize-memory-allocators:
395396
@@ -500,8 +501,8 @@ Customize Memory Allocators
500501
memory block was traced.
501502
502503
These hooks are :ref:`installed by default <default-memory-allocators>` if
503-
Python is compiled in debug
504-
mode. The :envvar:`PYTHONMALLOC` environment variable can be used to install
504+
:ref:`Python is built in debug mode <debug-build>`.
505+
The :envvar:`PYTHONMALLOC` environment variable can be used to install
505506
debug hooks on a Python compiled in release mode.
506507
507508
.. versionchanged:: 3.6

Doc/extending/newtypes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This section aims to give a quick fly-by on the various type methods you can
1212
implement and what they do.
1313

1414
Here is the definition of :c:type:`PyTypeObject`, with some fields only used in
15-
debug builds omitted:
15+
:ref:`debug builds <debug-build>` omitted:
1616

1717
.. literalinclude:: ../includes/typestruct.h
1818

Doc/extending/newtypes_tutorial.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ at the start of each object struct and defines a field called ``ob_base``
6969
of type :c:type:`PyObject`, containing a pointer to a type object and a
7070
reference count (these can be accessed using the macros :c:macro:`Py_REFCNT`
7171
and :c:macro:`Py_TYPE` respectively). The reason for the macro is to
72-
abstract away the layout and to enable additional fields in debug builds.
72+
abstract away the layout and to enable additional fields in :ref:`debug builds
73+
<debug-build>`.
7374

7475
.. note::
7576
There is no semicolon above after the :c:macro:`PyObject_HEAD` macro.

Doc/howto/instrumentation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ should instead read:
266266
267267
probe process("python").library("libpython3.6dm.so.1.0").mark("function__entry") {
268268
269-
(assuming a debug build of CPython 3.6)
269+
(assuming a :ref:`debug build <debug-build>` of CPython 3.6)
270270

271271

272272
Available static markers

Doc/library/decimal.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,8 @@ are also included in the pure Python version for compatibility.
14841484

14851485
.. data:: HAVE_CONTEXTVAR
14861486

1487-
The default value is ``True``. If Python is compiled ``--without-decimal-contextvar``,
1487+
The default value is ``True``. If Python is :option:`configured with
1488+
--without-decimal-contextvar <--without-decimal-contextvar>`,
14881489
the C version uses a thread-local rather than a coroutine-local context and the value
14891490
is ``False``. This is slightly faster in some nested context scenarios.
14901491

Doc/library/devmode.rst

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ detected.
1313
It can be enabled using the :option:`-X dev <-X>` command line option or by
1414
setting the :envvar:`PYTHONDEVMODE` environment variable to ``1``.
1515

16+
See also :ref:`Python debug build <debug-build>`.
17+
1618
Effects of the Python Development Mode
1719
======================================
1820

Doc/library/stdtypes.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -1581,13 +1581,15 @@ expression support in the :mod:`re` module).
15811581

15821582
By default, the *errors* argument is not checked for best performances, but
15831583
only used at the first encoding error. Enable the :ref:`Python Development
1584-
Mode <devmode>`, or use a debug build to check *errors*.
1584+
Mode <devmode>`, or use a :ref:`debug build <debug-build>` to check
1585+
*errors*.
15851586

15861587
.. versionchanged:: 3.1
15871588
Support for keyword arguments added.
15881589

15891590
.. versionchanged:: 3.9
1590-
The *errors* is now checked in development mode and in debug mode.
1591+
The *errors* is now checked in development mode and
1592+
in :ref:`debug mode <debug-build>`.
15911593

15921594

15931595
.. method:: str.endswith(suffix[, start[, end]])
@@ -2710,7 +2712,7 @@ arbitrary binary data.
27102712

27112713
By default, the *errors* argument is not checked for best performances, but
27122714
only used at the first decoding error. Enable the :ref:`Python Development
2713-
Mode <devmode>`, or use a debug build to check *errors*.
2715+
Mode <devmode>`, or use a :ref:`debug build <debug-build>` to check *errors*.
27142716

27152717
.. note::
27162718

@@ -2722,7 +2724,8 @@ arbitrary binary data.
27222724
Added support for keyword arguments.
27232725

27242726
.. versionchanged:: 3.9
2725-
The *errors* is now checked in development mode and in debug mode.
2727+
The *errors* is now checked in development mode and
2728+
in :ref:`debug mode <debug-build>`.
27262729

27272730

27282731
.. method:: bytes.endswith(suffix[, start[, end]])

Doc/library/sys.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ always available.
250250
Print low-level information to stderr about the state of CPython's memory
251251
allocator.
252252

253-
If Python is configured --with-pydebug, it also performs some expensive
254-
internal consistency checks.
253+
If Python is :option:`configured --with-pydebug <--with-pydebug>`, it also
254+
performs some expensive internal consistency checks.
255255

256256
.. versionadded:: 3.3
257257

Doc/library/warnings.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ In regular release builds, the default warning filter has the following entries
229229
ignore::ImportWarning
230230
ignore::ResourceWarning
231231

232-
In debug builds, the list of default warning filters is empty.
232+
In a :ref:`debug build <debug-build>`, the list of default warning filters is empty.
233233

234234
.. versionchanged:: 3.2
235235
:exc:`DeprecationWarning` is now ignored by default in addition to

Doc/using/cmdline.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ Miscellaneous options
433433
* ``-X faulthandler`` to enable :mod:`faulthandler`;
434434
* ``-X showrefcount`` to output the total reference count and number of used
435435
memory blocks when the program finishes or after each statement in the
436-
interactive interpreter. This only works on debug builds.
436+
interactive interpreter. This only works on :ref:`debug builds
437+
<debug-build>`.
437438
* ``-X tracemalloc`` to start tracing Python memory allocations using the
438439
:mod:`tracemalloc` module. By default, only the most recent frame is
439440
stored in a traceback of a trace. Use ``-X tracemalloc=NFRAME`` to start
@@ -926,18 +927,16 @@ conflict.
926927
Debug-mode variables
927928
~~~~~~~~~~~~~~~~~~~~
928929

929-
Setting these variables only has an effect in a debug build of Python.
930-
931930
.. envvar:: PYTHONTHREADDEBUG
932931

933932
If set, Python will print threading debug info.
934933

935-
Need Python configured with the ``--with-pydebug`` build option.
934+
Need a :ref:`debug build of Python <debug-build>`.
936935

937936

938937
.. envvar:: PYTHONDUMPREFS
939938

940939
If set, Python will dump objects and reference counts still alive after
941940
shutting down the interpreter.
942941

943-
Need Python configured with the ``--with-trace-refs`` build option.
942+
Need Python configured with the :option:`--with-trace-refs` build option.

0 commit comments

Comments
 (0)