From: Bruno Haible Date: Mon, 3 Feb 2025 21:28:51 +0000 (+0100) Subject: gnulib-tool: Allow compiler warnings in Gnulib code. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f4ba7b1bcfc8ee0af0a0d0929ee23451adccbeeb;p=gnulib.git gnulib-tool: Allow compiler warnings in Gnulib code. * gnulib-tool.sh (func_emit_lib_Makefile_am): Append $(GL_CFLAG_ALLOW_WARNINGS) to the ${libname}_${libext}_CFLAGS variable. * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 62827cda3f..62d6254359 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-02-03 Bruno Haible + + gnulib-tool: Allow compiler warnings in Gnulib code. + * gnulib-tool.sh (func_emit_lib_Makefile_am): Append + $(GL_CFLAG_ALLOW_WARNINGS) to the ${libname}_${libext}_CFLAGS variable. + * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Likewise. + 2025-02-03 Bruno Haible gnulib-tool: Apply libgnu.{,l}a specific CFLAGS to all its object files. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index eedeb306bc..bddd3073d6 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -4025,8 +4025,22 @@ func_emit_lib_Makefile_am () fi echo echo "${libname}_${libext}_SOURCES =" + # Insert a '-Wno-error' option in the compilation commands emitted by + # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@. + # Why? + # - Because every package maintainer has their preferred set of warnings + # that they may want to enforce in the main source code of their package, + # and some of these warnings (such as '-Wswitch-enum') complain about code + # that is just perfect. + # Gnulib source code is maintained according to Gnulib coding style. + # Package maintainers have no right to force their coding style upon Gnulib. + # Why before @CFLAGS@? + # - Because "the user is always right": If a user adds '-Werror' to their + # CFLAGS, they have asked for errors, they will get errors. But they have + # no right to complain about these errors, because Gnulib does not support + # '-Werror'. if ! $for_test; then - echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS)" + echo "${libname}_${libext}_CFLAGS = \$(AM_CFLAGS) \$(GL_CFLAG_GNULIB_WARNINGS) \$(GL_CFLAG_ALLOW_WARNINGS)" fi # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However, # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@. @@ -4391,7 +4405,9 @@ func_emit_tests_Makefile_am () # arguments, endless recursions, etc.) that a compiler may warn about, # even with just the normal '-Wall' option. # 2) Because every package maintainer has their preferred set of warnings - # that they may want to enforce in the main source code of their package. + # that they may want to enforce in the main source code of their package, + # and some of these warnings (such as '-Wswitch-enum') complain about code + # that is just perfect. # But Gnulib tests are maintained in Gnulib and don't end up in binaries # that that package installs; therefore it does not make sense for # package maintainers to enforce the absence of warnings on these tests. diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index a8f22ed97c..814ccae571 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -911,8 +911,22 @@ AC_DEFUN([%V1%_LIBSOURCES], [ emit += '\n' emit += '%s_%s_SOURCES =\n' % (libname, libext) + # Insert a '-Wno-error' option in the compilation commands emitted by + # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@. + # Why? + # - Because every package maintainer has their preferred set of warnings + # that they may want to enforce in the main source code of their package, + # and some of these warnings (such as '-Wswitch-enum') complain about code + # that is just perfect. + # Gnulib source code is maintained according to Gnulib coding style. + # Package maintainers have no right to force their coding style upon Gnulib. + # Why before @CFLAGS@? + # - Because "the user is always right": If a user adds '-Werror' to their + # CFLAGS, they have asked for errors, they will get errors. But they have + # no right to complain about these errors, because Gnulib does not support + # '-Werror'. if not for_test: - emit += '%s_%s_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)\n' % (libname, libext) + emit += '%s_%s_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) $(GL_CFLAG_ALLOW_WARNINGS)\n' % (libname, libext) # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However, # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@. emit += '%s_%s_LIBADD = $(%s_%s_%sLIBOBJS)\n' % (libname, libext, macro_prefix, libname, perhapsLT) @@ -1183,7 +1197,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [ # arguments, endless recursions, etc.) that a compiler may warn about, # even with just the normal '-Wall' option. # 2) Because every package maintainer has their preferred set of warnings - # that they may want to enforce in the main source code of their package. + # that they may want to enforce in the main source code of their package, + # and some of these warnings (such as '-Wswitch-enum') complain about code + # that is just perfect. # But Gnulib tests are maintained in Gnulib and don't end up in binaries # that that package installs; therefore it does not make sense for # package maintainers to enforce the absence of warnings on these tests.