Hello,
Thank you for the analysis.

On Tue, Oct 20, 2026 at 1:32 AM Bruno Haible <[email protected]> wrote:

> Hello,
>
> Andrew Hamilton wrote:
> > While doing this, I've encountered a scenario where I get a compile
> > error like the following:
> > In file included from video/emu/sdl.c:21:
> > ../config-util.h:2748:6: error: "__clang_major__" is not defined,
> > evaluates to 0 [-Werror=undef]
>
> To be precise, you got a warning from the compiler. Turning the warning
> into an error was _your_ choice, via '-Werror'.
>

Yes this is true, it is a long standing practice in GRUB to make sure
compilation warnings are corrected.

>
> > diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
> > index 719c627..d4c3624 100644
> > --- a/m4/gnulib-common.m4
> > +++ b/m4/gnulib-common.m4
> > @@ -911,7 +911,7 @@ AC_DEFUN([gl_COMMON_BODY], [
> >     -Wthread-safety is enabled.  For usage, see
> >     <https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>.  */
> >  #ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE
> > -# if __clang_major__ >= 15
> > +# if defined __clang__ && __clang_major__ >= 15
> >  #  define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \
> >       __attribute__ ((__capability__ (concept)))
> >  # else
>
> The patch that you propose is not wrong, but it would fix only the
> first occurrence of the '-Wundef' warning. Surely there will be
> other ones later (that you would see by not using '-Werror').
>
> Gnulib does not care about -Wundef warnings, because eliminating all
> of them would require many changes, that are just code verbosity:
> it would make reading and maintaining the code harder, without real
> benefit.


The problem is this is in a header included by non-Gnulib source so it is
compiled with the Grub compile flags instead of the Grub-Gnulib compiler
flags. We do actually disable Wundef for when we compile Gnulib:
https://gitlab.freedesktop.org/gnu-grub/grub/-/blob/master/conf/Makefile.common?ref_type=heads#L80

This was the only such case I found when pulling in the new Gnulib, the
above change allowed Grub to compile along with the new Gnulib.

I think I agree you don’t need to update all of Gnulib to deal with Wundef,
maybe just this case.

Thank you,
Andrew

Reply via email to