]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: check -ffinite-math-only in more detail
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 May 2025 20:39:37 +0000 (05:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 May 2025 20:39:43 +0000 (05:39 +0900)
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

index c1cdfb2c8ee8a1a18eb5cae0903e7380b7afe992..210e4814f3caa54401be0261f32ed56d41efb300 100644 (file)
@@ -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