Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def win32_checks(deflist):
if a == "Intel" or a == "AMD64":
deflist.append('FORCE_NO_LONG_DOUBLE_FORMATTING')

def check_math_capabilities(config, moredefs, mathlibs):
def check_math_capabilities(config, ext, moredefs, mathlibs):
def check_func(func_name):
return config.check_func(func_name, libraries=mathlibs,
decl=True, call=True)
Expand Down Expand Up @@ -167,6 +167,14 @@ def check_funcs(funcs_name):
for dec, fn in OPTIONAL_FUNCTION_ATTRIBUTES:
if config.check_gcc_function_attribute(dec, fn):
moredefs.append((fname2def(fn), 1))
if fn == 'attribute_target_avx512f':
# GH-14787: Work around GCC<8.4 bug when compiling with AVX512
# support on Windows-based platforms
if (sys.platform in ('win32', 'cygwin') and
config.check_compiler_gcc() 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)])

for dec, fn, code, header in OPTIONAL_FUNCTION_ATTRIBUTES_WITH_INTRINSICS:
if config.check_gcc_function_attribute_with_intrinsics(dec, fn, code,
Expand Down Expand Up @@ -434,7 +442,7 @@ def generate_config_h(ext, build_dir):
mathlibs = check_mathlib(config_cmd)
moredefs.append(('MATHLIB', ','.join(mathlibs)))

check_math_capabilities(config_cmd, moredefs, mathlibs)
check_math_capabilities(config_cmd, ext, moredefs, mathlibs)
moredefs.extend(cocache.check_ieee_macros(config_cmd)[0])
moredefs.extend(cocache.check_complex(config_cmd, mathlibs)[0])

Expand Down
33 changes: 29 additions & 4 deletions numpy/distutils/command/autodist.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,47 @@ def check_restrict(cmd):
return ''


def check_compiler_gcc4(cmd):
"""Return True if the C compiler is GCC 4.x."""
def check_compiler_gcc(cmd):
"""Check if the compiler is GCC."""

cmd._check_compiler()
body = textwrap.dedent("""
int
main()
{
#if (! defined __GNUC__) || (__GNUC__ < 4)
#error gcc >= 4 required
#if (! defined __GNUC__)
#error gcc required
#endif
return 0;
}
""")
return cmd.try_compile(body, None, None)


def check_gcc_version_at_least(cmd, major, minor=0, patchlevel=0):
"""
Check that the gcc version is at least the specified version."""

cmd._check_compiler()
version = '.'.join([str(major), str(minor), str(patchlevel)])
body = textwrap.dedent("""
int
main()
{
#if (! defined __GNUC__) || (__GNUC__ < %(major)d) || \\
(__GNUC_MINOR__ < %(minor)d) || \\
(__GNUC_PATCHLEVEL__ < %(patchlevel)d)
#error gcc >= %(version)s required
#endif
return 0;
}
""")
kw = {'version': version, 'major': major, 'minor': minor,
'patchlevel': patchlevel}

return cmd.try_compile(body % kw, None, None)


def check_gcc_function_attribute(cmd, attribute, name):
"""Return True if the given function attribute is supported."""
cmd._check_compiler()
Expand Down
14 changes: 10 additions & 4 deletions numpy/distutils/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
check_gcc_function_attribute_with_intrinsics,
check_gcc_variable_attribute,
check_gcc_version_at_least,
check_inline,
check_restrict,
check_compiler_gcc4)
check_compiler_gcc)

LANG_EXT['f77'] = '.f'
LANG_EXT['f90'] = '.f90'
Expand Down Expand Up @@ -416,9 +417,9 @@ def check_restrict(self):
otherwise."""
return check_restrict(self)

def check_compiler_gcc4(self):
"""Return True if the C compiler is gcc >= 4."""
return check_compiler_gcc4(self)
def check_compiler_gcc(self):
"""Return True if the C compiler is gcc"""
return check_compiler_gcc(self)

def check_gcc_function_attribute(self, attribute, name):
return check_gcc_function_attribute(self, attribute, name)
Expand All @@ -431,6 +432,11 @@ def check_gcc_function_attribute_with_intrinsics(self, attribute, name,
def check_gcc_variable_attribute(self, attribute):
return check_gcc_variable_attribute(self, attribute)

def check_gcc_version_at_least(self, major, minor=0, patchlevel=0):
"""Return True if the GCC version is greater than or equal to the
specified version."""
return check_gcc_version_at_least(self, major, minor, patchlevel)

def get_output(self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c", use_tee=None):
Expand Down