Hello,

I'm working on integrating a new version of GNULIB into GRUB.

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]
 2748 | # if __clang_major__ >= 15
      |      ^~~~~~~~~~~~~~~
../config-util.h:2756:6: error: "__clang_major__" is not defined,
evaluates to 0 [-Werror=undef]
 2756 | # if __clang_major__ >= 15
      |      ^~~~~~~~~~~~~~~
../config-util.h:2764:6: error: "__clang_major__" is not defined,
evaluates to 0 [-Werror=undef]
 2764 | # if __clang_major__ >= 15
      |      ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:50273: video/emu/sdl_module-sdl.o] Error 1

It seems one possible solution to this is something like the following change:
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
@@ -919,7 +919,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # endif
 #endif
 #ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY
-# if __clang_major__ >= 15
+# if defined __clang__ && __clang_major__ >= 15
 #  define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \
      __attribute__ ((__acquire_capability__ (resource)))
 # else
@@ -927,7 +927,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # endif
 #endif
 #ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY
-# if __clang_major__ >= 15
+# if defined __clang__ && __clang_major__ >= 15
 #  define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \
      __attribute__ ((__release_capability__ (resource)))
 # else


I'm curious if you think this is something that should be addressed in
GNULIB or if I'm doing something wrong on the GRUB side.  For the
moment, I have a patch like the above that I plan to include as part
of the GRUB build process.

Test configuration:
GNULIB revision 1b2025c05025f140777c397d470a56536a5cb826
GCC version "gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0"
Compiled with "-Werror" and "

Please let me know if you need any more info or have thoughts on this.
If you'd like, I can submit a patch per your preferred workflow or
you're welcome to take the above and run with it if you think it's a
good approach.


Thank you,
Andrew Hamilton

Reply via email to