Skip to content

Commit 3124d9a

Browse files
tiranAA-Turnerzoobaerlend-aasland
authored
gh-93491: Add support tier detection to configure (GH-93492)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Steve Dower <steve.dower@microsoft.com> Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
1 parent a87c9b5 commit 3124d9a

File tree

5 files changed

+196
-1
lines changed

5 files changed

+196
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``configure`` now detects and reports :pep:`11` support tiers.

PC/pyconfig.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,30 @@ WIN32 is still required for the locale module.
113113
#define MS_WIN64
114114
#endif
115115

116-
/* set the COMPILER */
116+
/* set the COMPILER and support tier
117+
*
118+
* win_amd64 MSVC (x86_64-pc-windows-msvc): 1
119+
* win32 MSVC (i686-pc-windows-msvc): 1
120+
* win_arm64 MSVC (aarch64-pc-windows-msvc): 3
121+
* other archs and ICC: 0
122+
*/
117123
#ifdef MS_WIN64
118124
#if defined(_M_X64) || defined(_M_AMD64)
119125
#if defined(__INTEL_COMPILER)
120126
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
127+
#define PY_SUPPORT_TIER 0
121128
#else
122129
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
130+
#define PY_SUPPORT_TIER 1
123131
#endif /* __INTEL_COMPILER */
124132
#define PYD_PLATFORM_TAG "win_amd64"
125133
#elif defined(_M_ARM64)
126134
#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)")
135+
#define PY_SUPPORT_TIER 3
127136
#define PYD_PLATFORM_TAG "win_arm64"
128137
#else
129138
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
139+
#define PY_SUPPORT_TIER 0
130140
#endif
131141
#endif /* MS_WIN64 */
132142

@@ -173,15 +183,19 @@ typedef _W64 int Py_ssize_t;
173183
#if defined(_M_IX86)
174184
#if defined(__INTEL_COMPILER)
175185
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
186+
#define PY_SUPPORT_TIER 0
176187
#else
177188
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
189+
#define PY_SUPPORT_TIER 1
178190
#endif /* __INTEL_COMPILER */
179191
#define PYD_PLATFORM_TAG "win32"
180192
#elif defined(_M_ARM)
181193
#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
182194
#define PYD_PLATFORM_TAG "win_arm32"
195+
#define PY_SUPPORT_TIER 0
183196
#else
184197
#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
198+
#define PY_SUPPORT_TIER 0
185199
#endif
186200
#endif /* MS_WIN32 && !MS_WIN64 */
187201

configure

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

configure.ac

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,35 @@ AC_PROG_GREP
770770
AC_PROG_SED
771771
AC_PROG_EGREP
772772

773+
dnl detect compiler name
774+
dnl check for xlc before clang, newer xlc's can use clang as frontend.
775+
dnl check for GCC last, other compilers set __GNUC__, too.
776+
dnl msvc is listed for completeness.
777+
AC_CACHE_CHECK([for CC compiler name], [ac_cv_cc_name], [
778+
cat > conftest.c <<EOF
779+
#if defined(__INTEL_COMPILER) || defined(__ICC)
780+
icc
781+
#elif defined(__ibmxl__) || defined(__xlc__) || defined(__xlC__)
782+
xlc
783+
#elif defined(_MSC_VER)
784+
msvc
785+
#elif defined(__clang__)
786+
clang
787+
#elif defined(__GNUC__)
788+
gcc
789+
#else
790+
# error unknown compiler
791+
#endif
792+
EOF
793+
794+
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
795+
ac_cv_cc_name=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
796+
else
797+
ac_cv_cc_name="unknown"
798+
fi
799+
rm -f conftest.c conftest.out
800+
])
801+
773802
# checks for UNIX variants that set C preprocessor variables
774803
# may set _GNU_SOURCE, __EXTENSIONS__, _POSIX_PTHREAD_SEMANTICS,
775804
# _POSIX_SOURCE, _POSIX_1_SOURCE, and more
@@ -1031,6 +1060,42 @@ if test x$MULTIARCH != x; then
10311060
fi
10321061
AC_SUBST(MULTIARCH_CPPFLAGS)
10331062

1063+
dnl Support tiers according to https://peps.python.org/pep-0011/
1064+
dnl
1065+
dnl NOTE: Windows support tiers are defined in PC/pyconfig.h.
1066+
dnl
1067+
AC_MSG_CHECKING([for PEP 11 support tier])
1068+
AS_CASE([$host/$ac_cv_cc_name],
1069+
[x86_64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=1], dnl Linux on AMD64, any vendor, glibc, gcc
1070+
[x86_64-apple-darwin*/clang], [PY_SUPPORT_TIER=1], dnl macOS on Intel, any version
1071+
[i686-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 32bit Windows on Intel, MSVC
1072+
[x86_64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=1], dnl 64bit Windows on AMD64, MSVC
1073+
1074+
[aarch64-apple-darwin*/clang], [PY_SUPPORT_TIER=2], dnl macOS on M1, any version
1075+
[aarch64-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux ARM64, glibc, gcc+clang
1076+
[aarch64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2],
1077+
[powerpc64le-*-linux-gnu/gcc], [PY_SUPPORT_TIER=2], dnl Linux on PPC64 little endian, glibc, gcc
1078+
[x86_64-*-linux-gnu/clang], [PY_SUPPORT_TIER=2], dnl Linux on AMD64, any vendor, glibc, clang
1079+
1080+
[aarch64-pc-windows-msvc/msvc], [PY_SUPPORT_TIER=3], dnl Windows ARM64, MSVC
1081+
[armv7l-*-linux-gnueabihf/gcc], [PY_SUPPORT_TIER=3], dnl ARMv7 LE with hardware floats, any vendor, glibc, gcc
1082+
[powerpc64le-*-linux-gnu/clang], [PY_SUPPORT_TIER=3], dnl Linux on PPC64 little endian, glibc, clang
1083+
[s390x-*-linux-gnu/gcc], [PY_SUPPORT_TIER=3], dnl Linux on 64bit s390x (big endian), glibc, gcc
1084+
dnl [wasm32-unknown-emscripten/clang], [PY_SUPPORT_TIER=3], dnl WebAssembly Emscripten
1085+
dnl [wasm32-unknown-wasi/clang], [PY_SUPPORT_TIER=3], dnl WebAssembly System Interface
1086+
[x86_64-*-freebsd/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64
1087+
[PY_SUPPORT_TIER=0]
1088+
)
1089+
1090+
AS_CASE([$PY_SUPPORT_TIER],
1091+
[1], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 1 (supported)])],
1092+
[2], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 2 (supported)])],
1093+
[3], [AC_MSG_RESULT([$host/$ac_cv_cc_name has tier 3 (partially supported)])],
1094+
[AC_MSG_WARN([$host/$ac_cv_cc_name is not supported])]
1095+
)
1096+
1097+
AC_DEFINE_UNQUOTED([PY_SUPPORT_TIER], [$PY_SUPPORT_TIER], [PEP 11 Support tier (1, 2, 3 or 0 for unsupported)])
1098+
10341099
AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [
10351100
save_LDFLAGS="$LDFLAGS"
10361101
AS_VAR_APPEND([LDFLAGS], [-Wl,--no-as-needed])
@@ -6878,3 +6943,9 @@ If you want a release build with all stable optimizations active (PGO, etc),
68786943
please run ./configure --enable-optimizations
68796944
])
68806945
fi
6946+
6947+
AS_VAR_IF([PY_SUPPORT_TIER], [0], [AC_MSG_WARN([
6948+
6949+
Platform "$host" with compiler "$ac_cv_cc_name" is not supported by the
6950+
CPython core team, see https://peps.python.org/pep-0011/ for more information.
6951+
])])

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,9 @@
15151515
/* Cipher suite string for PY_SSL_DEFAULT_CIPHERS=0 */
15161516
#undef PY_SSL_DEFAULT_CIPHER_STRING
15171517

1518+
/* PEP 11 Support tier (1, 2, 3 or 0 for unsupported) */
1519+
#undef PY_SUPPORT_TIER
1520+
15181521
/* Define if you want to build an interpreter with many run-time checks. */
15191522
#undef Py_DEBUG
15201523

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy