8000 BLD,API: (distutils) Force strict floating point error model on clang by seberg · Pull Request #19049 · numpy/numpy · GitHub
[go: up one dir, main page]

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
6 changes: 6 additions & 0 deletions doc/release/upcoming_changes/19049.compatibility.rst
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions numpy/distutils/ccompiler.py
64DD
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
0