* [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
@ 2025-04-22 17:19 Philippe Mathieu-Daudé
2025-04-22 18:36 ` Pierrick Bouvier
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-22 17:19 UTC (permalink / raw)
To: qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Pierrick Bouvier, Akihiko Odaki,
Philippe Mathieu-Daudé
When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
I get:
In file included from ../../qapi/string-output-visitor.c:14:
qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
144 | return strchrnul(s, c);
| ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: 'strchrnul' has been marked as being introduced in macOS 15.4 here, but the deployment target is macOS 15.0.0
198 | strchrnul(const char *__s, int __c);
| ^
qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a __builtin_available check to silence this warning
144 | return strchrnul(s, c);
| ^~~~~~~~~
1 error generated.
Disable this -Wunguarded-availability-new warning as a
short term band-aid fix.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
meson.build | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meson.build b/meson.build
index 41f68d38069..539368f82b1 100644
--- a/meson.build
+++ b/meson.build
@@ -735,6 +735,7 @@ warn_flags = [
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wundef',
+ '-Wunguarded-availability',
'-Wvla',
'-Wwrite-strings',
@@ -747,6 +748,7 @@ warn_flags = [
'-Wno-string-plus-int',
'-Wno-tautological-type-limit-compare',
'-Wno-typedef-redefinition',
+ '-Wno-unguarded-availability-new',
]
if host_os != 'darwin'
--
2.47.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
2025-04-22 17:19 [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings Philippe Mathieu-Daudé
@ 2025-04-22 18:36 ` Pierrick Bouvier
2025-04-22 19:45 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: Pierrick Bouvier @ 2025-04-22 18:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Akihiko Odaki
On 4/22/25 10:19, Philippe Mathieu-Daudé wrote:
> When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
> I get:
>
> In file included from ../../qapi/string-output-visitor.c:14:
> qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
> 144 | return strchrnul(s, c);
> | ^~~~~~~~~
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_string.h:198:9: note: 'strchrnul' has been marked as being introduced in macOS 15.4 here, but the deployment target is macOS 15.0.0
> 198 | strchrnul(const char *__s, int __c);
> | ^
> qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a __builtin_available check to silence this warning
> 144 | return strchrnul(s, c);
> | ^~~~~~~~~
> 1 error generated.
>
> Disable this -Wunguarded-availability-new warning as a
> short term band-aid fix.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> meson.build | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 41f68d38069..539368f82b1 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -735,6 +735,7 @@ warn_flags = [
> '-Wstrict-prototypes',
> '-Wtype-limits',
> '-Wundef',
> + '-Wunguarded-availability',
> '-Wvla',
> '-Wwrite-strings',
>
> @@ -747,6 +748,7 @@ warn_flags = [
> '-Wno-string-plus-int',
> '-Wno-tautological-type-limit-compare',
> '-Wno-typedef-redefinition',
> + '-Wno-unguarded-availability-new',
> ]
>
> if host_os != 'darwin'
I solved it the same way locally, but didn't send a patch because I'm
not sure what happens if the code runs on MacOS < 15.4, and I don't have
such a machine available.
Is the symbol already there?
Does it crash?
I guess the warning is here for a good reason.
You can find a lot of issues open in various open source projects with
this warning (with various fixes) since this update was released.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
2025-04-22 18:36 ` Pierrick Bouvier
@ 2025-04-22 19:45 ` Philippe Mathieu-Daudé
2025-04-22 20:31 ` Pierrick Bouvier
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-22 19:45 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Akihiko Odaki
On 22/4/25 20:36, Pierrick Bouvier wrote:
> On 4/22/25 10:19, Philippe Mathieu-Daudé wrote:
>> When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
>> I get:
>>
>> In file included from ../../qapi/string-output-visitor.c:14:
>> qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only
>> available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
>> 144 | return strchrnul(s, c);
>> | ^~~~~~~~~
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
>> _string.h:198:9: note: 'strchrnul' has been marked as being introduced
>> in macOS 15.4 here, but the deployment target is macOS 15.0.0
>> 198 | strchrnul(const char *__s, int __c);
>> | ^
>> qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a
>> __builtin_available check to silence this warning
>> 144 | return strchrnul(s, c);
>> | ^~~~~~~~~
>> 1 error generated.
>>
>> Disable this -Wunguarded-availability-new warning as a
>> short term band-aid fix.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> meson.build | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/meson.build b/meson.build
>> index 41f68d38069..539368f82b1 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -735,6 +735,7 @@ warn_flags = [
>> '-Wstrict-prototypes',
>> '-Wtype-limits',
>> '-Wundef',
>> + '-Wunguarded-availability',
>> '-Wvla',
>> '-Wwrite-strings',
>> @@ -747,6 +748,7 @@ warn_flags = [
>> '-Wno-string-plus-int',
>> '-Wno-tautological-type-limit-compare',
>> '-Wno-typedef-redefinition',
>> + '-Wno-unguarded-availability-new',
>> ]
>> if host_os != 'darwin'
>
> I solved it the same way locally, but didn't send a patch because I'm
> not sure what happens if the code runs on MacOS < 15.4,
I'd expect meson to Do The Right Thing and not define HAVE_STRCHRNUL.
> and I don't have
> such a machine available.
>
> Is the symbol already there?
> Does it crash?
> I guess the warning is here for a good reason.
>
> You can find a lot of issues open in various open source projects with
> this warning (with various fixes) since this update was released.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
2025-04-22 19:45 ` Philippe Mathieu-Daudé
@ 2025-04-22 20:31 ` Pierrick Bouvier
2025-04-23 5:24 ` Akihiko Odaki
0 siblings, 1 reply; 6+ messages in thread
From: Pierrick Bouvier @ 2025-04-22 20:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé, Akihiko Odaki
On 4/22/25 12:45, Philippe Mathieu-Daudé wrote:
> On 22/4/25 20:36, Pierrick Bouvier wrote:
>> On 4/22/25 10:19, Philippe Mathieu-Daudé wrote:
>>> When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
>>> I get:
>>>
>>> In file included from ../../qapi/string-output-visitor.c:14:
>>> qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only
>>> available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
>>> 144 | return strchrnul(s, c);
>>> | ^~~~~~~~~
>>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
>>> _string.h:198:9: note: 'strchrnul' has been marked as being introduced
>>> in macOS 15.4 here, but the deployment target is macOS 15.0.0
>>> 198 | strchrnul(const char *__s, int __c);
>>> | ^
>>> qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a
>>> __builtin_available check to silence this warning
>>> 144 | return strchrnul(s, c);
>>> | ^~~~~~~~~
>>> 1 error generated.
>>>
>>> Disable this -Wunguarded-availability-new warning as a
>>> short term band-aid fix.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> meson.build | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/meson.build b/meson.build
>>> index 41f68d38069..539368f82b1 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -735,6 +735,7 @@ warn_flags = [
>>> '-Wstrict-prototypes',
>>> '-Wtype-limits',
>>> '-Wundef',
>>> + '-Wunguarded-availability',
>>> '-Wvla',
>>> '-Wwrite-strings',
>>> @@ -747,6 +748,7 @@ warn_flags = [
>>> '-Wno-string-plus-int',
>>> '-Wno-tautological-type-limit-compare',
>>> '-Wno-typedef-redefinition',
>>> + '-Wno-unguarded-availability-new',
>>> ]
>>> if host_os != 'darwin'
>>
>> I solved it the same way locally, but didn't send a patch because I'm
>> not sure what happens if the code runs on MacOS < 15.4,
>
> I'd expect meson to Do The Right Thing and not define HAVE_STRCHRNUL.
>
The trick is that it compiles with a warning, but meson tests are not
done with -Werror enabled.
This might be the proper fix at the moment, if we identify that a crash
happen on MacOS < 15.4. Else, the warning can safely be silenced as you did.
>> and I don't have
>> such a machine available.
>>
>> Is the symbol already there?
>> Does it crash?
>> I guess the warning is here for a good reason.
>>
>> You can find a lot of issues open in various open source projects with
>> this warning (with various fixes) since this update was released.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
2025-04-22 20:31 ` Pierrick Bouvier
@ 2025-04-23 5:24 ` Akihiko Odaki
2025-04-23 5:30 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: Akihiko Odaki @ 2025-04-23 5:24 UTC (permalink / raw)
To: Pierrick Bouvier, Philippe Mathieu-Daudé, qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé
On 2025/04/23 5:31, Pierrick Bouvier wrote:
> On 4/22/25 12:45, Philippe Mathieu-Daudé wrote:
>> On 22/4/25 20:36, Pierrick Bouvier wrote:
>>> On 4/22/25 10:19, Philippe Mathieu-Daudé wrote:
>>>> When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
>>>> I get:
>>>>
>>>> In file included from ../../qapi/string-output-visitor.c:14:
>>>> qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only
>>>> available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-new]
>>>> 144 | return strchrnul(s, c);
>>>> | ^~~~~~~~~
>>>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
>>>> _string.h:198:9: note: 'strchrnul' has been marked as being introduced
>>>> in macOS 15.4 here, but the deployment target is macOS 15.0.0
>>>> 198 | strchrnul(const char *__s, int __c);
>>>> | ^
>>>> qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a
>>>> __builtin_available check to silence this warning
>>>> 144 | return strchrnul(s, c);
>>>> | ^~~~~~~~~
>>>> 1 error generated.
>>>>
>>>> Disable this -Wunguarded-availability-new warning as a
>>>> short term band-aid fix.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> ---
>>>> meson.build | 2 ++
>>>> 1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/meson.build b/meson.build
>>>> index 41f68d38069..539368f82b1 100644
>>>> --- a/meson.build
>>>> +++ b/meson.build
>>>> @@ -735,6 +735,7 @@ warn_flags = [
>>>> '-Wstrict-prototypes',
>>>> '-Wtype-limits',
>>>> '-Wundef',
>>>> + '-Wunguarded-availability',
>>>> '-Wvla',
>>>> '-Wwrite-strings',
>>>> @@ -747,6 +748,7 @@ warn_flags = [
>>>> '-Wno-string-plus-int',
>>>> '-Wno-tautological-type-limit-compare',
>>>> '-Wno-typedef-redefinition',
>>>> + '-Wno-unguarded-availability-new',
>>>> ]
>>>> if host_os != 'darwin'
>>>
>>> I solved it the same way locally, but didn't send a patch because I'm
>>> not sure what happens if the code runs on MacOS < 15.4,
>>
>> I'd expect meson to Do The Right Thing and not define HAVE_STRCHRNUL.
>>
>
> The trick is that it compiles with a warning, but meson tests are not
> done with -Werror enabled.
> This might be the proper fix at the moment, if we identify that a crash
> happen on MacOS < 15.4. Else, the warning can safely be silenced as you
> did.
We need to take two components into consideration: SDK, which includes
header files, and macOS that runs the binary. If you use a SDK that
defines strchrnul() to build, the resulting binary will not work on
macOS < 15.04. My idea of fixing this properly is as follows:
- Define the MACOSX_DEPLOYMENT_TARGET environment variable to tell the
macOS version you are targeting.
- Pass -Werror=unguarded-availability-new to cc.has_function() so that
Meson will not define HAVE_STRCHRNUL if strchrnul() is not available
on the targeted macOS version.
>
>>> and I don't have
>>> such a machine available.
>>>
>>> Is the symbol already there?
>>> Does it crash?
>>> I guess the warning is here for a good reason.
>>>
>>> You can find a lot of issues open in various open source projects with
>>> this warning (with various fixes) since this update was released.
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings
2025-04-23 5:24 ` Akihiko Odaki
@ 2025-04-23 5:30 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-23 5:30 UTC (permalink / raw)
To: Akihiko Odaki, Pierrick Bouvier, qemu-devel
Cc: Eric Blake, Marc-André Lureau, Paolo Bonzini,
Daniel P. Berrangé
Hi Akihiko,
On 23/4/25 07:24, Akihiko Odaki wrote:
> On 2025/04/23 5:31, Pierrick Bouvier wrote:
>> On 4/22/25 12:45, Philippe Mathieu-Daudé wrote:
>>> On 22/4/25 20:36, Pierrick Bouvier wrote:
>>>> On 4/22/25 10:19, Philippe Mathieu-Daudé wrote:
>>>>> When using Visual Studio Code (v1.99.3) and Apple clangd v17.0.0
>>>>> I get:
>>>>>
>>>>> In file included from ../../qapi/string-output-visitor.c:14:
>>>>> qemu/include/qemu/cutils.h:144:12: error: 'strchrnul' is only
>>>>> available on macOS 15.4 or newer [-Werror,-Wunguarded-availability-
>>>>> new]
>>>>> 144 | return strchrnul(s, c);
>>>>> | ^~~~~~~~~
>>>>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
>>>>> _string.h:198:9: note: 'strchrnul' has been marked as being introduced
>>>>> in macOS 15.4 here, but the deployment target is macOS 15.0.0
>>>>> 198 | strchrnul(const char *__s, int __c);
>>>>> | ^
>>>>> qemu/include/qemu/cutils.h:144:12: note: enclose 'strchrnul' in a
>>>>> __builtin_available check to silence this warning
>>>>> 144 | return strchrnul(s, c);
>>>>> | ^~~~~~~~~
>>>>> 1 error generated.
>>>>>
>>>>> Disable this -Wunguarded-availability-new warning as a
>>>>> short term band-aid fix.
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>>> ---
>>>>> meson.build | 2 ++
>>>>> 1 file changed, 2 insertions(+)
>>>>>
>>>>> diff --git a/meson.build b/meson.build
>>>>> index 41f68d38069..539368f82b1 100644
>>>>> --- a/meson.build
>>>>> +++ b/meson.build
>>>>> @@ -735,6 +735,7 @@ warn_flags = [
>>>>> '-Wstrict-prototypes',
>>>>> '-Wtype-limits',
>>>>> '-Wundef',
>>>>> + '-Wunguarded-availability',
>>>>> '-Wvla',
>>>>> '-Wwrite-strings',
>>>>> @@ -747,6 +748,7 @@ warn_flags = [
>>>>> '-Wno-string-plus-int',
>>>>> '-Wno-tautological-type-limit-compare',
>>>>> '-Wno-typedef-redefinition',
>>>>> + '-Wno-unguarded-availability-new',
>>>>> ]
>>>>> if host_os != 'darwin'
>>>>
>>>> I solved it the same way locally, but didn't send a patch because I'm
>>>> not sure what happens if the code runs on MacOS < 15.4,
>>>
>>> I'd expect meson to Do The Right Thing and not define HAVE_STRCHRNUL.
>>>
>>
>> The trick is that it compiles with a warning, but meson tests are not
>> done with -Werror enabled.
>> This might be the proper fix at the moment, if we identify that a
>> crash happen on MacOS < 15.4. Else, the warning can safely be silenced
>> as you did.
>
> We need to take two components into consideration: SDK, which includes
> header files, and macOS that runs the binary. If you use a SDK that
> defines strchrnul() to build, the resulting binary will not work on
> macOS < 15.04. My idea of fixing this properly is as follows:
> - Define the MACOSX_DEPLOYMENT_TARGET environment variable to tell the
> macOS version you are targeting.
I read a bit about this variable but don't gather its implications.
> - Pass -Werror=unguarded-availability-new to cc.has_function() so that
> Meson will not define HAVE_STRCHRNUL if strchrnul() is not available
> on the targeted macOS version.
This was my guess but I couldn't find precedent of -Werror in
cc.has_function() so wasn't sure.
I'd feel better if you are willing to correct fix this :)
Regards,
Phil.
>
>>
>>>> and I don't have
>>>> such a machine available.
>>>>
>>>> Is the symbol already there?
>>>> Does it crash?
>>>> I guess the warning is here for a good reason.
>>>>
>>>> You can find a lot of issues open in various open source projects with
>>>> this warning (with various fixes) since this update was released.
>>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-23 5:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 17:19 [RFC PATCH] buildsys: Disable 'unguarded-availability-new' warnings Philippe Mathieu-Daudé
2025-04-22 18:36 ` Pierrick Bouvier
2025-04-22 19:45 ` Philippe Mathieu-Daudé
2025-04-22 20:31 ` Pierrick Bouvier
2025-04-23 5:24 ` Akihiko Odaki
2025-04-23 5:30 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).