From 928cd7478dfe7f4d8702df307a62e6fd85aeda43 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 27 Jun 2023 12:03:59 +0200 Subject: [PATCH] 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 gh-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. --- meson.build | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meson.build b/meson.build index e193907f42f4..1bd3933432b9 100644 --- a/meson.build +++ b/meson.build @@ -52,6 +52,15 @@ endif add_project_arguments( cc.get_supported_arguments( '-fno-strict-aliasing'), language : 'c' ) +# +# Clang defaults to a non-strict floating error point model, but we need strict +# behavior. `-ftrapping-math` is equivalent to `-ffp-exception-behavior=strict`. +# Note that this is only supported on macOS arm64 as of XCode 14.3 +if cc.get_id() == 'clang' + add_project_arguments( + cc.get_supported_arguments('-ftrapping-math'), language: ['c', 'cpp'], + ) +endif # Generate version number. Note that this will not (yet) update the version # number seen by pip or reflected in wheel filenames. See