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
gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but `pres…
…erve_none` and `musttail` do not exist. (GH-140548)

Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
(cherry picked from commit 2f60b8f)
  • Loading branch information
XChaitanyaX and chris-eibl committed Nov 2, 2025
commit a6d52fed8714fd3d9c21610e99376bedf6d1f76c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Generate a clear compilation error when ``_Py_TAIL_CALL_INTERP`` is enabled but
either ``preserve_none`` or ``musttail`` is not supported.
8 changes: 8 additions & 0 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@
#endif

#if Py_TAIL_CALL_INTERP
# if defined(__clang__) || defined(__GNUC__)
# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
# error "This compiler does not have support for efficient tail calling."
# endif
# elif defined(_MSC_VER)
# error "Tail calling not supported for MSVC."
# endif

// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
# define Py_MUSTTAIL [[clang::musttail]]
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))
Expand Down
Loading