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
6 changes: 6 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,12 @@ Compiler flags

.. versionadded:: 3.7

.. envvar:: CFLAGS_CEVAL

Flags used to compile ``Python/ceval.c``.

.. versionadded:: 3.14.5

.. envvar:: CCSHARED

Compiler flags used to build a shared library.
Expand Down
5 changes: 5 additions & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ CONFIGURE_EXE_LDFLAGS=@EXE_LDFLAGS@
PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
# Strict or non-strict aliasing flags used to compile dtoa.c, see above
CFLAGS_ALIASING=@CFLAGS_ALIASING@
# Compilation flags only for ceval.c.
CFLAGS_CEVAL=@CFLAGS_CEVAL@


# Machine-dependent subdirectories
Expand Down Expand Up @@ -3203,6 +3205,9 @@ regen-jit:
Python/dtoa.o: Python/dtoa.c
$(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $<

Python/ceval.o: Python/ceval.c
$(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_CEVAL) -o $@ $<

# Run reindent on the library
.PHONY: reindent
reindent:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix high stack consumption in Python's interpreter loop on Clang 22 by setting function limits for inlining when building with computed gotos.
47 changes: 47 additions & 0 deletions configure

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

28 changes: 28 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7371,6 +7371,34 @@ if test "$have_glibc_memmove_bug" = yes; then
for memmove and bcopy.])
fi

AC_MSG_CHECKING([if we need to manually block large inlining in ceval.c])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
int main(void) {
// See gh-148284: Clang 22 seems to have interactions with inlining
// and the stackref buffer which cause 40 kB of stack usage on x86-64
// in buggy versions of _PyEval_EvalFrameDefault() in computed goto
// interpreter. The normal usage seen is normally 1-2 kB.
#if defined(__clang__) && (__clang_major__ == 22)
return 1;
#else
return 0;
#endif
}
]])],
[block_huge_inlining_in_ceval=no],
[block_huge_inlining_in_ceval=yes],
[block_huge_inlining_in_ceval=undefined])
AC_MSG_RESULT([$block_huge_inlining_in_ceval])

if test "$block_huge_inlining_in_ceval" = yes && test "$ac_cv_computed_gotos" = yes; then
# gh-148284: Suppress inlining of functions whose stack size exceeds
# 512 bytes. This number should be tuned to follow the C stack
# consumption in _PyEval_EvalFrameDefault() on computed goto
# interpreter.
CFLAGS_CEVAL="$CFLAGS_CEVAL -finline-max-stacksize=512"
fi
AC_SUBST([CFLAGS_CEVAL])

if test "$ac_cv_gcc_asm_for_x87" = yes; then
# Some versions of gcc miscompile inline asm:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
Expand Down
Loading