Skip to content

Commit 02617af

Browse files
committed
Adjust docs & comment
1 parent 92ee35e commit 02617af

6 files changed

Lines changed: 28 additions & 21 deletions

File tree

Doc/howto/perf_profiling.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,8 @@ How to obtain the best results
218218
------------------------------
219219

220220
For best results, keep frame pointers enabled. On supported GCC-compatible
221-
toolchains, CPython builds itself with ``-fno-omit-frame-pointer`` and, when
222-
available, ``-mno-omit-leaf-frame-pointer`` by default. On 32-bit ARM,
223-
CPython also adds ``-marm`` when supported. On s390 platforms, CPython also
224-
adds ``-mbackchain`` when supported. These flags allow
221+
toolchains, CPython builds itself with ``-fno-omit-frame-pointer`` and similar
222+
flags (see :option:`--without-frame-pointers` for details). These flags allow
225223
profilers to unwind using only the frame pointer and not on DWARF debug
226224
information. This is because as the code that is interposed to allow ``perf``
227225
support is dynamically generated it doesn't have any DWARF debugging information

Doc/using/configure.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,19 @@ also be used to improve performance.
784784

785785
Disable frame pointers, which are enabled by default (see :pep:`831`).
786786

787-
By default, the build appends ``-fno-omit-frame-pointer``,
788-
``-mno-omit-leaf-frame-pointer`` when the compiler supports it,
789-
``-marm`` on 32-bit ARM when supported, and ``-mbackchain`` on s390
790-
platforms when supported, to ``BASECFLAGS`` so
791-
profilers, debuggers, and system tracing tools
792-
(``perf``, ``eBPF``, ``dtrace``, ``gdb``) can walk the C call stack
793-
without DWARF metadata. The flags propagate to third-party C
787+
By default, the build appends flags to generate frame or backchain
788+
pointers to ``BASECFLAGS``:
789+
790+
- ``-fno-omit-frame-pointer`` and/or ``-mno-omit-leaf-frame-pointer``
791+
are added when the compiler supports them,
792+
- ``-marm`` is added on 32-bit ARM when supported,
793+
- on s390x platforms, when supported, ``-mbackchain`` is added *instead*
794+
of the above frame pointer flags
795+
796+
Frame pointers enable profilers, debuggers, and system tracing tools
797+
(``perf``, ``eBPF``, ``dtrace``, ``gdb``) to walk the C call stack
798+
without DWARF metadata.
799+
The flags propagate to third-party C
794800
extensions through :mod:`sysconfig`. On compilers that do not
795801
understand them, the build silently skips them.
796802

Doc/whatsnew/3.15.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,11 +2490,13 @@ Build changes
24902490

24912491
* CPython is now built with frame pointers enabled by default
24922492
(:pep:`831`). Pass :option:`--without-frame-pointers` to opt out.
2493+
24932494
Authors of C extensions and native libraries built with custom build
2494-
systems should add ``-fno-omit-frame-pointer`` and
2495-
``-mno-omit-leaf-frame-pointer`` to their own ``CFLAGS``,
2496-
``-marm`` on 32-bit ARM, and ``-mbackchain`` on s390 platforms,
2497-
to keep the unwind chain intact.
2495+
systems should ensure the unwind chain is intact.
2496+
This is usually done by adding ``-fno-omit-frame-pointer`` and
2497+
similar flags to ``CFLAGS``. See :option:`--without-frame-pointers`
2498+
documentation for the specific flags Python uses.
2499+
24982500
(Contributed by Pablo Galindo Salgado and Savannah Ostrowski in :gh:`149201`.)
24992501

25002502
.. _whatsnew315-windows-tail-calling-interpreter:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Enable frame pointers by default for GCC-compatible CPython builds, including
2-
``-mno-omit-leaf-frame-pointer``, ``-marm`` on 32-bit ARM, and ``-mbackchain``
3-
on s390 platforms when the compiler supports them, so profilers and debuggers
2+
``-mno-omit-leaf-frame-pointer``, ``-marm`` on 32-bit ARM, and/or ``-mbackchain``
3+
on s390x platforms when the compiler supports them, so profilers and debuggers
44
can unwind native interpreter frames more reliably. Users can pass
5-
``--without-frame-pointers`` to opt out.
5+
:option:`--without-frame-pointers` to ``./configure`` to opt out.

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,8 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [
25632563
if test -n "$frame_pointer_cflags" && test "x$with_frame_pointers" != xno; then
25642564
BASECFLAGS="$frame_pointer_cflags $BASECFLAGS"
25652565
AC_DEFINE([_Py_WITH_FRAME_POINTERS], [1],
2566-
[Define to 1 if frame unwinding via pointers is expected to work, 0 if not])
2566+
[Define to 1 if frame unwinding via pointers is expected
2567+
to work, 0 if not. Leave undefined if unknown.])
25672568
fi
25682569
25692570
CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"

pyconfig.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,8 @@
20732073
/* Define if you want to use tail-calling interpreters in CPython. */
20742074
#undef _Py_TAIL_CALL_INTERP
20752075

2076-
/* Define to 1 if frame unwinding via pointers is expected to work, 0 if not
2077-
*/
2076+
/* Define to 1 if frame unwinding via pointers is expected to work, 0 if not.
2077+
Leave undefined if unknown. */
20782078
#undef _Py_WITH_FRAME_POINTERS
20792079

20802080
/* Define to force use of thread-safe errno, h_errno, and other functions */

0 commit comments

Comments
 (0)