Skip to content

Commit 621390f

Browse files
rgommerscharris
authored andcommitted
BLD: use -ftrapping-math with Clang on macOS
The distutils build also uses this flag, and it avoids some problems with `floor_divide` and similar functions (xref numpygh-19479). For older macOS arm64 Clang versions, the flag does get accepted, but then gets overridden because it's not actually supported - which yields these warnings: ``` warning: overriding currently unsupported use of floating point exceptions on this target [-Wunsupported-floating-point-opt] ``` Since they're a little annoying to suppress and will go away when updating to the latest XCode version, we'll ignore these warnings.
1 parent ef46300 commit 621390f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

meson.build

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ endif
5252
add_project_arguments(
5353
cc.get_supported_arguments( '-fno-strict-aliasing'), language : 'c'
5454
)
55+
#
56+
# Clang defaults to a non-strict floating error point model, but we need strict
57+
# behavior. `-ftrapping-math` is equivalent to `-ffp-exception-behavior=strict`.
58+
# Note that this is only supported on macOS arm64 as of XCode 14.3
59+
if cc.get_id() == 'clang'
60+
add_project_arguments(
61+
cc.get_supported_arguments('-ftrapping-math'), language: ['c', 'cpp'],
62+
)
63+
endif
5564

5665
# Generate version number. Note that this will not (yet) update the version
5766
# number seen by pip or reflected in wheel filenames. See

0 commit comments

Comments
 (0)