Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf85ce5

Browse files
committed
it *should* work now
1 parent820d140 commitdf85ce5

File tree

4 files changed

+70
-4
lines changed

4 files changed

+70
-4
lines changed

‎Makefile.pre.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,9 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydt
19381938
$(MULTIARCH_CPPFLAGS) \
19391939
-o $@ $(srcdir)/Python/sysmodule.c
19401940

1941+
Python/cpuinfo.o: $(srcdir)/Python/cpuinfo.c Makefile
1942+
$(CC) -c $(PY_CORE_CFLAGS) @CORE_CPUINFO_CFLAGS@ -o $@ $(srcdir)/Python/cpuinfo.c
1943+
19411944
$(IO_OBJS): $(IO_H)
19421945

19431946
.PHONY: regen-pegen-metaparser

‎Python/cpuinfo.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
# undef HAS_XGETBV_SUPPORT
2626
#endif
2727

28-
#undef HAS_XGETBV_SUPPORT
29-
3028
// Below, we declare macros for guarding the detection of SSE, AVX/AVX2
3129
// and AVX-512 instructions. If the compiler does not even recognize the
3230
// corresponding flags or if we are not on an 64-bit platform we do not
@@ -162,6 +160,18 @@ get_xgetbv(uint32_t index)
162160
{
163161
assert(index==0);// only XCR0 is supported for now
164162
# if defined(HAS_CPUID_SUPPORT)&& defined(__x86_64__)&& defined(__GNUC__)
163+
# if defined(__clang__)
164+
# if_Py__has_builtin(__builtin_ia32_xgetbv)
165+
return (uint64_t)_xgetbv(index);
166+
# else
167+
/*
168+
* Without -mxsave support, directly using xgetbv() with raw opcode
169+
* may still fail on some platforms (e.g., AMD64 + FreeBSD + clang).
170+
* To be on the safe side, we assume that XGETBV is not supported.
171+
*/
172+
return0;
173+
# endif
174+
# else/* gcc & icc */
165175
uint32_teax=0,edx=0;
166176
__asm__volatile(
167177
/* raw opcode for xgetbv for compatibility with older toolchains */
@@ -170,6 +180,7 @@ get_xgetbv(uint32_t index)
170180
:"c" (index)
171181
);
172182
return ((uint64_t)edx <<32) |eax;
183+
# endif
173184
# elif defined(HAS_CPUID_SUPPORT)&& defined(_M_X64)
174185
return (uint64_t)_xgetbv(index);
175186
# else

‎configure

Lines changed: 45 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎configure.ac

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8003,7 +8003,7 @@ AC_DEFUN([PY_SIMD_DETECT], [
80038003
# we do not necessarily know which instruction sets will be used,
80048004
# we disable SIMD support on some older Android platforms.
80058005
#
8006-
# Seepy_cpuid_features in pycore_cpuinfo.h for how to order fields
8006+
# See_Py_cpuid_features in pycore_cpuinfo.h for how to order fields
80078007
# and where to put blank lines to separate processor generations for
80088008
# AVX-512 instructions.
80098009
#
@@ -8058,6 +8058,14 @@ then
80588058
PY_SIMD_DETECT([AVX512_VP2INTERSECT],[-mavx512vp2intersect])
80598059
fi
80608060

8061+
dnl Check that -mxsave can be used for cpuinfo.c as the latter
8062+
dnl requires to be compiled with this option for xgetbv() support.
8063+
AX_CHECK_COMPILE_FLAG([-mxsave],
8064+
[AS_VAR_SET([CORE_CPUINFO_CFLAGS],[-mxsave])],
8065+
[AS_VAR_SET([CORE_CPUINFO_CFLAGS],[])],
8066+
[-Werror])
8067+
AC_SUBST([CORE_CPUINFO_CFLAGS])
8068+
80618069
###############################################################################
80628070
# HACL* compilation and linking configuration (contact: @picnixz)
80638071
#

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp