Skip to content

Commit 2f60b8f

Browse files
gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist. (GH-140548)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
1 parent b155414 commit 2f60b8f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Generate a clear compilation error when ``_Py_TAIL_CALL_INTERP`` is enabled but
2+
either ``preserve_none`` or ``musttail`` is not supported.

Python/ceval_macros.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@
7979
#endif
8080

8181
#if _Py_TAIL_CALL_INTERP
82+
# if defined(__clang__) || defined(__GNUC__)
83+
# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
84+
# error "This compiler does not have support for efficient tail calling."
85+
# endif
86+
# elif defined(_MSC_VER) && (_MSC_VER < 1950)
87+
# error "You need at least VS 2026 / PlatformToolset v145 for tail calling."
88+
# endif
89+
8290
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
8391
# define Py_MUSTTAIL [[clang::musttail]]
8492
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))

0 commit comments

Comments
 (0)