From f701f98052e906af9a065d68bdf2398ef3b476d9 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Sun, 2 Nov 2025 00:22:59 +0800 Subject: [PATCH 1/3] gh-140312: Set lltrace on JIT debug builds (GH-140313) Co-authored-by: Mark Shannon --- Tools/jit/template.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tools/jit/template.c b/Tools/jit/template.c index 8f71010a1aff58..2f146014a1c26b 100644 --- a/Tools/jit/template.c +++ b/Tools/jit/template.c @@ -69,9 +69,11 @@ do { \ } while (0) #undef LLTRACE_RESUME_FRAME -#define LLTRACE_RESUME_FRAME() \ - do { \ - } while (0) +#ifdef Py_DEBUG +#define LLTRACE_RESUME_FRAME() (frame->lltrace = 0) +#else +#define LLTRACE_RESUME_FRAME() do {} while (0) +#endif #define PATCH_JUMP(ALIAS) \ do { \ From b1554146c29182803d1df23d6367c07a429d21ba Mon Sep 17 00:00:00 2001 From: Dino Viehland Date: Sat, 1 Nov 2025 12:23:58 -0400 Subject: [PATCH 2/3] gh-140868: Don't rely on undefined left shift behavior in assert (#140869) Don't rely on undefined left shift behavior in assert --- Include/internal/pycore_stackref.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 94fcb1d8aee52b..15a703a08204da 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -403,7 +403,8 @@ PyStackRef_IsTaggedInt(_PyStackRef i) static inline _PyStackRef PyStackRef_TagInt(intptr_t i) { - assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (i << Py_TAGGED_SHIFT), Py_TAGGED_SHIFT) == i); + assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (intptr_t)(((uintptr_t)i) << Py_TAGGED_SHIFT), + Py_TAGGED_SHIFT) == i); return (_PyStackRef){ .bits = ((((uintptr_t)i) << Py_TAGGED_SHIFT) | Py_INT_TAG) }; } From 2f60b8f02fe7cb83dd589d9664460082c13e85ef Mon Sep 17 00:00:00 2001 From: Krishna Chaitanya <141550576+XChaitanyaX@users.noreply.github.com> Date: Sat, 1 Nov 2025 22:11:23 +0530 Subject: [PATCH 3/3] 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> --- .../Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst | 2 ++ Python/ceval_macros.h | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst diff --git a/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst b/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst new file mode 100644 index 00000000000000..1035ebf8d781cf --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst @@ -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. diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index 8083913b1a1cfc..868ab6f755874f 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -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) && (_MSC_VER < 1950) +# error "You need at least VS 2026 / PlatformToolset v145 for tail calling." +# 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))