From 679b3c71ebfdabe98008efcf233c6b5dc9788dd0 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 28 May 2025 05:39:37 +0900 Subject: [PATCH 1/2] meson: check -ffinite-math-only in more detail Even if -fno-finite-math-only is specified, -ffinite-math-only, -ffast-math, or -Ofast may be also specified after that. In that case, -fno-finite-math-only has no effect, and test-json will fail. Replaces #37603. --- meson.build | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index c1cdfb2c8e..210e4814f3 100644 --- a/meson.build +++ b/meson.build @@ -442,8 +442,16 @@ possible_common_link_flags = [ c_args = get_option('c_args') # Our json library does not support -ffinite-math-only, which is enabled by -Ofast or -ffast-math. -if (('-Ofast' in c_args or '-ffast-math' in c_args or '-ffinite-math-only' in c_args) and '-fno-finite-math-only' not in c_args) - error('-Ofast, -ffast-math, or -ffinite-math-only is specified in c_args.') +have = false +foreach arg : c_args + if arg in ['-ffinite-math-only', '-ffast-math', '-Ofast'] + have = true + elif arg in ['-fno-finite-math-only', '-fno-fast-math'] + have = false + endif +endforeach +if have + error('-ffinite-math-only is enabled (may be implied by -ffast-math or -Ofast) in c_args.') endif # Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are From 3e018371d044dfcfeeb6f1b3e5b5f46253e5668f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 28 May 2025 05:43:48 +0900 Subject: [PATCH 2/2] meson: also disable -Wmaybe-uninitialized when -Ofast is specified At least with GCC-14, -Ofast produces many false-positive warnings. ``` $ gcc --version gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7) ``` --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 210e4814f3..63eac45bbb 100644 --- a/meson.build +++ b/meson.build @@ -463,7 +463,8 @@ if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or '-Os' in c_args or '-O1' in c_args or '-O3' in c_args or - '-Og' in c_args) + '-Og' in c_args or + '-Ofast' in c_args) possible_common_cc_flags += '-Wno-maybe-uninitialized' endif