We should fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist. #140513
Copy link
Copy link
Closed
Labels
3.15bugs and security fixesbugs and security fixesbuildThe build process and cross-buildThe build process and cross-buildeasyinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The code should look something like this:
#if _Py_TAIL_CALL_INTERP && (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
#endifCPython versions tested on:
CPython main branch, 3.15, 3.14
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.15bugs and security fixesbugs and security fixesbuildThe build process and cross-buildThe build process and cross-buildeasyinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
XChaitanyaX commentedon Oct 24, 2025
Can I have a pr for this?
double exclamation
!!mark?? Shouldn't it be single?chris-eibl commentedon Oct 24, 2025
Maybe we can already handle that "earlier" in configure?
Fidget-Spinner commentedon Oct 24, 2025
This works too but I'd rather bloat up our C code rather than the configure code. The configure script is already pretty complex so I don't like adding more to it.
chris-eibl commentedon Oct 24, 2025
Yeah, and we could handle MSVC (#139962) here then in a similar way, too.
E.g. include a check for
_MSC_VERlike#if defined(_MSC_VER) && (_MSC_VER < 1950)?gh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but `pres…
Fidget-Spinner commentedon Nov 1, 2025
We missed the train for 3.14. Backporting now would break GCC 15.
Fidget-Spinner commentedon Nov 2, 2025
We need to backport this to 3.14 as well. The macro name has changed there. Can someone take care of the manual backport please?
chris-eibl commentedon Nov 2, 2025
Yeah, #139120 did not get backported.
I think it would be best to start fresh over against 3.14, cherry picker would be no help?
Also because the MSVC part shouldn't be part of it or needs extra care, too?
How to handle that? Something like
https://godbolt.org/z/d74ozM1oE
chris-eibl commentedon Nov 2, 2025
Or better break for GCC 15 like on main?
Fidget-Spinner commentedon Nov 2, 2025
Yes just break GCC 15.
chris-eibl commentedon Nov 2, 2025
Ok, I'll take care about the manual backport.
pythongh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but…
[3.14] gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but …
pythongh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but…
GH-148047: Check early whether tail-calling is possible for MSVC buil…
pythonGH-148047: Check early whether tail-calling is possible for MSV…