diff --git a/Include/pyport.h b/Include/pyport.h index c6cc47f7a14103d..abdaeb822729399 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -311,7 +311,7 @@ extern "C" { * its time must use it. Use a profiler when running performance benchmark * suite to find these functions. */ -#if defined(__GNUC__) \ +#if _Py__has_attribute(hot) || defined(__GNUC__) \ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) #define _Py_HOT_FUNCTION __attribute__((hot)) #else diff --git a/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst b/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst new file mode 100644 index 000000000000000..ae34c60e989ead1 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst @@ -0,0 +1 @@ +Enable the use of ``__attribute__((hot))`` when building CPython with Clang and other compilers that support it.