> On 9. Mar 2026, at 09:20, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 3/7/26 19:18, Mohamed Mediouni wrote:
>> 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
>
> Is -Wunguarded-availability-new enabled by default?
Hello,
Yes, it’s enabled by default at least by the CI.
> If it is enough to shut up the compiler maybe you can add a -mmacosx-version-min= flag, but
> workarounds on each function are not acceptable.
>
-mmacosx-version-min=15.4 or later would be overriding the macOS minimum version set by the user or
corresponding to the host machine QEMU is built on.
Another way would be to have the has_function have -Werror which should be enough to deal with
this case properly. Does that sound better?
For meson not sure whether it actually picks up the definition from the header or tries to use a dummy
definition though from looking at https://github.com/mesonbuild/meson/blob/6e67be7492d6982d2baf153387f9adbdb480d099/mesonbuild/compilers/mixins/clike.py#L738
If it picks the definition from the header, having Werror there ought to be enough. Otherwise, won’t be caught...
Thank you,
-Mohamed
> I'm applying the other patches, but for this one I don't think this is
> the right fix.
>
>
> Paolo
>