summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/setup.py2
-rw-r--r--numpy/distutils/command/autodist.py17
-rw-r--r--numpy/distutils/command/config.py4
3 files changed, 22 insertions, 1 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 3e1556699..a0b2f6484 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -180,7 +180,7 @@ def check_math_capabilities(config, moredefs, mathlibs):
moredefs.append((fname2def(fn), 1))
for fn in OPTIONAL_VARIABLE_ATTRIBUTES:
- if config.check_compile_without_warning('int %s a;' % (fn)):
+ if config.check_gcc_variable_attribute(fn):
m = fn.replace("(", "_").replace(")", "_")
moredefs.append((fname2def(m), 1))
diff --git a/numpy/distutils/command/autodist.py b/numpy/distutils/command/autodist.py
index ec00bcbdb..8598b33e6 100644
--- a/numpy/distutils/command/autodist.py
+++ b/numpy/distutils/command/autodist.py
@@ -59,6 +59,23 @@ main()
""" % (attribute, name)
return cmd.try_compile(body, None, None) != 0
+def check_gcc_variable_attribute(cmd, attribute):
+ """Return True if the given variable attribute is supported."""
+ cmd._check_compiler()
+ body = """
+#pragma GCC diagnostic error "-Wattributes"
+#pragma clang diagnostic error "-Wattributes"
+
+int %s foo;
+
+int
+main()
+{
+ return 0;
+}
+""" % (attribute, )
+ return cmd.try_compile(body, None, None) != 0
+
def check_compile_without_warning(cmd, body):
cmd._check_compiler()
ret, output = cmd.try_output_compile(body, None, None)
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py
index 512471d7f..513d1b064 100644
--- a/numpy/distutils/command/config.py
+++ b/numpy/distutils/command/config.py
@@ -17,6 +17,7 @@ import distutils
from numpy.distutils.exec_command import exec_command
from numpy.distutils.mingw32ccompiler import generate_manifest
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
+ check_gcc_variable_attribute,
check_inline,
check_compiler_gcc4,
check_compile_without_warning)
@@ -428,6 +429,9 @@ int main ()
def check_gcc_function_attribute(self, attribute, name):
return check_gcc_function_attribute(self, attribute, name)
+ def check_gcc_variable_attribute(self, attribute):
+ return check_gcc_variable_attribute(self, attribute)
+
def check_compile_without_warning(self, code):
"""Returns True if the given code may be compiled without warning."""
return check_compile_without_warning(self, code)