Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,15 @@ also be used to improve performance.

- ``-fno-omit-frame-pointer`` and/or ``-mno-omit-leaf-frame-pointer``
are added when the compiler supports them.
- ``-marm`` is added on 32-bit ARM when supported,
- ``-marm`` and/or ``-mno-thumb`` is added on 32-bit ARM when supported,
- on s390x platforms, when supported, ``-mbackchain`` is added *instead*.
of the above frame pointer flags.
- on ppc64le platforms, no compiler flags is needed since the power ABI
requires that compilers maintain a back chain by default.

Frame pointers enable profilers, debuggers, and system tracing tools
(``perf``, ``eBPF``, ``dtrace``, ``gdb``) to walk the C call stack
without DWARF metadata.
The flags propagate to third-party C
without DWARF metadata. The flags propagate to third-party C
extensions through :mod:`sysconfig`. On compilers that do not
understand them, the build silently skips them.

Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_frame_pointer_unwind.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def _frame_pointers_expected(machine):
if sys.maxsize < 2**32:
return None
return True
if machine == "ppc64le":
# The power ABI specification requires that compilers maintain a
# back chain by default, so unwinding already works without a
# dedicated frame pointer.
# https://openpowerfoundation.org/specifications/64bitelfabi/
return True
if machine == "x86_64":
final_opt = ""
for opt in cflags.split():
Expand Down
6 changes: 6 additions & 0 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ static const uintptr_t min_frame_pointer_addr = 0x1000;
# define FRAME_POINTER_NEXT_OFFSET 0
# define FRAME_POINTER_RETURN_OFFSET \
(S390X_FRAME_RETURN_ADDRESS_OFFSET / (Py_ssize_t)sizeof(uintptr_t))
#elif defined(__powerpc64__) || defined(__ppc64__)
// ppc64le puts the return address at fp[2]; it saves the Condition Register
// in fp[1]. See:
// https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
# define FRAME_POINTER_NEXT_OFFSET 0
# define FRAME_POINTER_RETURN_OFFSET 2
#else
# define FRAME_POINTER_NEXT_OFFSET 0
# define FRAME_POINTER_RETURN_OFFSET 1
Expand Down
53 changes: 52 additions & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2549,9 +2549,16 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [
frame_pointer_cflags="$frame_pointer_cflags -mno-omit-leaf-frame-pointer"
], [], [-Werror])
AS_CASE([$host_cpu], [arm|armv*], [
dnl GCC uses "-marm"; clang uses "-mno-thumb"
AX_CHECK_COMPILE_FLAG([-marm], [
frame_pointer_cflags="$frame_pointer_cflags -marm"
], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-mno-thumb], [
frame_pointer_cflags="$frame_pointer_cflags -mno-thumb"
], [], [-Werror])
])
AS_CASE([$host_cpu], [powerpc64le], [
frame_pointer_cflags=""
])
AS_CASE([$host_cpu], [s390*], [
AX_CHECK_COMPILE_FLAG([-mbackchain], [
Expand Down
Loading