Message ID | 20250422171955.11791-1-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | [RFC] buildsys: Disable 'unguarded-availability-new' warnings | expand |
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.
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.
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. >
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. >> >
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. >>> >> >
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'
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(+)