[PATCH v5 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK

Mohamed Mediouni posted 9 patches 1 month ago
Maintainers: Pedro Barbuda <pbarbuda@microsoft.com>, Mohamed Mediouni <mohamed@unpredictable.fr>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Wei Liu <wei.liu@kernel.org>
There is a newer version of this series
[PATCH v5 2/9] meson.build: older macOS targeting compatibility with macOS 15.4 SDK
Posted by Mohamed Mediouni 1 month ago
Using strchrnul eagerly results in a failure to compile when using the newest SDKs, with:

error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]

Working around that by not using strchrnul when targeting macOS.

This didn't show up on the CI because it used the macOS 15.1 SDK instead of a macOS 15.4 SDK or later.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 7b4e5bc72b..78bde0611b 100644
--- a/meson.build
+++ b/meson.build
@@ -2646,7 +2646,12 @@ config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
 config_host_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
 config_host_data.set('HAVE_GLIB_WITH_SLICE_ALLOCATOR', glib_has_gslice)
 config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
-config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix))
+
+# strchrnul was introduced in macOS 15.4.
+# Keep this condition for compatibility of new macOS SDKs with older releases.
+if host_os != 'darwin'
+  config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul', prefix: osdep_prefix))
+endif
 config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
 if rbd.found()
   config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS',
-- 
2.50.1 (Apple Git-155)