Skip to content

Commit

Permalink
BLD: Use -ftrapping-math for clang and for _so
Browse files Browse the repository at this point in the history
Apparently, there is a second `compiler_so` that is actually the
main compiler being used, and modifying only the first one is just
futile.

The old try was `-ffp-exception-behavior=strict`, but that seems to
be a fairly new addition (and doesn't even work on MacOS with 10.0)

`-ftrapping-math` seems to be the older, equivalent option.
  • Loading branch information
seberg committed Jul 15, 2021
1 parent f353371 commit e7d1841
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion numpy/distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ def CCompiler_customize_cmd(self, cmd, ignore=()):
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')
self.compiler.append('-ftrapping-math')
self.compiler_so.append('-ftrapping-math')

def allow(attr):
return getattr(cmd, attr, None) is not None and attr not in ignore
Expand Down

0 comments on commit e7d1841

Please sign in to comment.