[Python-checkins] bpo-35758: Fix building on ARM + MSVC (gh-11531)

Antoine Pitrou webhook-mailer at python.org
Mon Jan 21 15:49:45 EST 2019


https://github.com/python/cpython/commit/7a2368063f25746d4008a74aca0dc0b82f86ff7b
commit: 7a2368063f25746d4008a74aca0dc0b82f86ff7b
branch: master
author: Minmin Gong <gongminmin at msn.com>
committer: Antoine Pitrou <pitrou at free.fr>
date: 2019-01-21T21:49:40+01:00
summary:

bpo-35758: Fix building on ARM + MSVC (gh-11531)

* Disable x87 control word for non-x86 targets

On msvc, x87 control word is only available on x86 target. Need to disable it for other targets to prevent compiling problems.

* Include immintrin.h on x86 and x64 only

Immintrin.h is only available on x86 and x64. Need to disable it for other targets to prevent compiling problems.

files:
A Misc/NEWS.d/next/Windows/2019-01-21-05-18-14.bpo-35758.8LsY3l.rst
M Include/internal/pycore_atomic.h
M Include/pyport.h

diff --git a/Include/internal/pycore_atomic.h b/Include/internal/pycore_atomic.h
index f430a5c26ff8..5669f71b941f 100644
--- a/Include/internal/pycore_atomic.h
+++ b/Include/internal/pycore_atomic.h
@@ -19,7 +19,9 @@ extern "C" {
 
 #if defined(_MSC_VER)
 #include <intrin.h>
-#include <immintrin.h>
+#if defined(_M_IX86) || defined(_M_X64)
+#  include <immintrin.h>
+#endif
 #endif
 
 /* This is modeled after the atomics interface from C1x, according to
diff --git a/Include/pyport.h b/Include/pyport.h
index 7f88c4f629a0..4971a493ccee 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -406,7 +406,7 @@ extern "C" {
 #endif
 
 /* get and set x87 control word for VisualStudio/x86 */
-#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
+#if defined(_MSC_VER) && defined(_M_IX86) /* x87 only supported in x86 */
 #define HAVE_PY_SET_53BIT_PRECISION 1
 #define _Py_SET_53BIT_PRECISION_HEADER \
     unsigned int old_387controlword, new_387controlword, out_387controlword
diff --git a/Misc/NEWS.d/next/Windows/2019-01-21-05-18-14.bpo-35758.8LsY3l.rst b/Misc/NEWS.d/next/Windows/2019-01-21-05-18-14.bpo-35758.8LsY3l.rst
new file mode 100644
index 000000000000..c1e19d465b3c
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2019-01-21-05-18-14.bpo-35758.8LsY3l.rst
@@ -0,0 +1 @@
+Allow building on ARM with MSVC.



More information about the Python-checkins mailing list