59 lines
2.0 KiB
Diff
59 lines
2.0 KiB
Diff
--- a/numpy/distutils/command/autodist.py
|
|
+++ b/numpy/distutils/command/autodist.py
|
|
@@ -62,6 +62,22 @@
|
|
""")
|
|
return cmd.try_compile(body, None, None)
|
|
|
|
+def check_compiler_clang(cmd):
|
|
+ """Check if the compiler is Clang."""
|
|
+
|
|
+ cmd._check_compiler()
|
|
+ body = textwrap.dedent("""
|
|
+ int
|
|
+ main()
|
|
+ {
|
|
+ #if (! defined __clang__)
|
|
+ #error clang required
|
|
+ #endif
|
|
+ return 0;
|
|
+ }
|
|
+ """)
|
|
+ return cmd.try_compile(body, None, None)
|
|
+
|
|
|
|
def check_gcc_version_at_least(cmd, major, minor=0, patchlevel=0):
|
|
"""
|
|
--- a/numpy/distutils/command/config.py
|
|
+++ b/numpy/distutils/command/config.py
|
|
@@ -23,7 +23,8 @@
|
|
check_gcc_version_at_least,
|
|
check_inline,
|
|
check_restrict,
|
|
- check_compiler_gcc)
|
|
+ check_compiler_gcc,
|
|
+ check_compiler_clang)
|
|
|
|
LANG_EXT['f77'] = '.f'
|
|
LANG_EXT['f90'] = '.f90'
|
|
@@ -421,6 +422,10 @@
|
|
"""Return True if the C compiler is gcc"""
|
|
return check_compiler_gcc(self)
|
|
|
|
+ def check_compiler_clang(self):
|
|
+ """Return True if the C compiler is clang"""
|
|
+ return check_compiler_clang(self)
|
|
+
|
|
def check_gcc_function_attribute(self, attribute, name):
|
|
return check_gcc_function_attribute(self, attribute, name)
|
|
|
|
--- a/numpy/core/setup.py
|
|
+++ b/numpy/core/setup.py
|
|
@@ -182,6 +182,7 @@
|
|
if fn == 'attribute_target_avx512f':
|
|
if (sys.platform in ('win32', 'cygwin') and
|
|
config.check_compiler_gcc() and
|
|
+ not config.check_compiler_clang() and
|
|
not config.check_gcc_version_at_least(8, 4)):
|
|
ext.extra_compile_args.extend(
|
|
['-ffixed-xmm%s' % n for n in range(16, 32)])
|