Skip to content

Commit 6132746

Browse files
Autoconf detection
1 parent f1d3190 commit 6132746

File tree

4 files changed

+136
-49
lines changed

4 files changed

+136
-49
lines changed

Include/Python.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {"
99
// is not needed.
1010

11-
#define Py_TAIL_CALL_INTERP 1
12-
1311
// Include Python header files
1412
#include "patchlevel.h"
1513
#include "pyconfig.h"

configure

Lines changed: 80 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,22 +1717,6 @@ then
17171717
ABI_THREAD="t"
17181718
fi
17191719

1720-
# Check for --enable-tail-call-interp
1721-
# --enable-tail-call-interp
1722-
AC_MSG_CHECKING([for --enable-tail-call-interp])
1723-
AC_ARG_ENABLE([tail-call-interp],
1724-
[AS_HELP_STRING([--enable-tail-call-interp], [enable tail calling interpreter]) ],
1725-
[
1726-
if test "$enableval" != no
1727-
then
1728-
AC_MSG_RESULT([yes]);
1729-
AC_DEFINE([Py_TAIL_CALL_INTERP], [1],
1730-
[Define if you want to enable tail calling interpreter])
1731-
else
1732-
AC_MSG_RESULT([no]);
1733-
fi],
1734-
[AC_MSG_RESULT([no])])
1735-
17361720
# Check for --with-pydebug
17371721
AC_MSG_CHECKING([for --with-pydebug])
17381722
AC_ARG_WITH([pydebug],
@@ -7013,6 +6997,60 @@ case "$ac_cv_computed_gotos" in yes*)
70136997
[Define if the C compiler supports computed gotos.])
70146998
esac
70156999

7000+
# Check for --with-tail-calling-interp
7001+
AC_MSG_CHECKING([for --with-tail-calling-interp])
7002+
AC_ARG_WITH(
7003+
[tail-calling-interp],
7004+
[AS_HELP_STRING(
7005+
[--tail-calling-interp],
7006+
[enable tail-calling interpreter in evaluation loop and rest of CPython (enabled by default on supported compilers)]
7007+
)],
7008+
[
7009+
if test "$withval" = yes
7010+
then
7011+
AC_DEFINE([Py_TAIL_CALLING_INTERP], [1],
7012+
[Define if you want to use tail-calling interpreters in CPython.])
7013+
AC_MSG_RESULT([yes])
7014+
fi
7015+
if test "$withval" = no
7016+
then
7017+
AC_DEFINE([Py_TAIL_CALLING_INTERP], [0],
7018+
[Define if you want to use tail-calling interpreters in CPython.])
7019+
AC_MSG_RESULT([no])
7020+
fi
7021+
],
7022+
[AC_MSG_RESULT([no value specified])])
7023+
7024+
7025+
AC_CACHE_CHECK([whether $CC supports efficient proper tail calls], [ac_cv_tail_call],
7026+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[[
7027+
7028+
#if __has_attribute(musttail)
7029+
# if __has_attribute(preserve_none)
7030+
// Only allowlist x86_64 and AArch64. Add more architectures as compilers gain support for them.
7031+
# if defined(__x86_64__) || defined(__aarch64__)
7032+
# define PROPER_TAIL_CALLS 1
7033+
# endif
7034+
# endif
7035+
#endif
7036+
7037+
#ifndef PROPER_TAIL_CALLS
7038+
# error "No proper tail calls"
7039+
#endif
7040+
7041+
]]])],
7042+
[ac_cv_tail_call=yes],
7043+
[ac_cv_tail_call=no],
7044+
[if test "${with_tail_calling_interp+set}" = set; then
7045+
ac_cv_tail_call="$with_tail_calling_interp -- configured --with(out)-tail-calling-interp"
7046+
else
7047+
ac_cv_tail_call=no
7048+
fi]))
7049+
case "$ac_cv_tail_call" in yes*)
7050+
AC_DEFINE([Py_TAIL_CALLING_INTERP], [1],
7051+
[Define if the C compiler supports efficient proper tail calls.])
7052+
esac
7053+
70167054
case $ac_sys_system in
70177055
AIX*)
70187056
AC_DEFINE([HAVE_BROKEN_PIPE_BUF], [1],

pyconfig.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,8 +1718,8 @@
17181718
/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */
17191719
#undef Py_SUNOS_VERSION
17201720

1721-
/* Define if you want to enable tail calling interpreter */
1722-
#undef Py_TAIL_CALL_INTERP
1721+
/* Define if the C compiler supports efficient proper tail calls. */
1722+
#undef Py_TAIL_CALLING_INTERP
17231723

17241724
/* Define if you want to enable tracing references for debugging purpose */
17251725
#undef Py_TRACE_REFS

0 commit comments

Comments
 (0)