Skip to content

We should fail to compile if _Py_TAIL_CALL_INTERP is set but preserve_none and musttail do not exist. #140513

Description

@Fidget-Spinner

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
#endif

CPython versions tested on:

CPython main branch, 3.15, 3.14

Operating systems tested on:

No response

Linked PRs

Activity

  1. XChaitanyaX commented on Oct 24, 2025

    @XChaitanyaX
    Contributor

    Can I have a pr for this?

    !!_Py__has_attribute(musttail)

    double exclamation !! mark?? Shouldn't it be single?

  2. chris-eibl commented on Oct 24, 2025

    @chris-eibl
    Member

    Maybe we can already handle that "earlier" in configure?

  3. Fidget-Spinner commented on Oct 24, 2025

    @Fidget-Spinner
    MemberAuthor

    Maybe we can already handle that "earlier" in configure?

    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.

  4. chris-eibl commented on Oct 24, 2025

    @chris-eibl
    Member

    Yeah, and we could handle MSVC (#139962) here then in a similar way, too.

    E.g. include a check for _MSC_VER like #if defined(_MSC_VER) && (_MSC_VER < 1950)?

  5. added a commit that references this issue on Nov 1, 2025
  6. Fidget-Spinner commented on Nov 1, 2025

    @Fidget-Spinner
    MemberAuthor

    We missed the train for 3.14. Backporting now would break GCC 15.

  7. Fidget-Spinner commented on Nov 2, 2025

    @Fidget-Spinner
    MemberAuthor

    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?

  8. chris-eibl commented on Nov 2, 2025

    @chris-eibl
    Member

    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?

    We missed the train for 3.14. Backporting now would break GCC 15.
    which has musttail but no preserve_none

    How to handle that? Something like

    // GCC 15 has support for musttail, but not for preserve_none.
    // Because we previously have allowed this, let's continue to do so.
    #   if defined(__clang__) || defined(__GNUC__)
    #       if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
    #           if (__GNUC__ != 15)
    #               error "This compiler does not have support for efficient tail calling."
    #           endif
    #       endif
    #   elif defined(_MSC_VER)
    #       error "tail calling is not supported for MSVC."
    #   endif
    

    https://godbolt.org/z/d74ozM1oE

  9. chris-eibl commented on Nov 2, 2025

    @chris-eibl
    Member

    Or better break for GCC 15 like on main?

  10. Fidget-Spinner commented on Nov 2, 2025

    @Fidget-Spinner
    MemberAuthor

    Yes just break GCC 15.

  11. chris-eibl commented on Nov 2, 2025

    @chris-eibl
    Member

    Ok, I'll take care about the manual backport.

  12. added a commit that references this issue on Nov 2, 2025
  13. added a commit that references this issue on Nov 4, 2025
  14. added a commit that references this issue on Dec 6, 2025
  15. added a commit that references this issue on Apr 12, 2026
  16. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15bugs and security fixesbuildThe build process and cross-buildeasyinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions