diff options
| -rw-r--r-- | doc/release/upcoming_changes/19049.compatibility.rst | 6 | ||||
| -rw-r--r-- | numpy/distutils/ccompiler.py | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/19049.compatibility.rst b/doc/release/upcoming_changes/19049.compatibility.rst new file mode 100644 index 000000000..5a6eadc7a --- /dev/null +++ b/doc/release/upcoming_changes/19049.compatibility.rst @@ -0,0 +1,6 @@ +Distutils forces strict floating point model on clang +----------------------------------------------------- +NumPy distutils will now always add the ``-ffp-exception-behavior=strict`` +compiler flag when compiling with clang. Clang defaults to a non-strict +version, which allows the compiler to generate code that does not set +floating point warnings/errors correctly. diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index f025c8904..061f4862d 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -384,6 +384,12 @@ def CCompiler_customize_cmd(self, cmd, ignore=()): """ log.info('customize %s using %s' % (self.__class__.__name__, cmd.__class__.__name__)) + + if hasattr(self, 'compiler') and 'clang' in self.compiler[0]: + # clang defaults to a non-strict floating error point model. + # Since NumPy and most Python libs give warnings for these, override: + self.compiler.append('-ffp-exception-behavior=strict') + def allow(attr): return getattr(cmd, attr, None) is not None and attr not in ignore |
