Fallout from _AC_UNDECLARED_WARNING in autoconf 2.70beta
Stephan Bergmann
sbergman at redhat.com
Thu Nov 5 16:38:01 CET 2020
One issue I encountered in the wild (when building LibreOffice, with its
zoo of bundled 3rd-party projects) with (the latest git trunk for)
autoconf 2.70beta is related to how gpgme's configure.ac
(<https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=blob;f=configure.ac;h=03c260cd759dfda37ef047a143b6875ae81305cb;hb=HEAD>)
is organized. (It may or may not be considered a regression in
autoconf, or a bug in gpgme, hence I'm only writing here for now, not
filing an issue. The relevant gpgme mailing list is on CC.)
That configure.ac checks whether one specific GCC
-Wno-missing-field-initializers flag is supported (l. 606), based on
that one check optimistically goes ahead and adds a whole bunch of
-Wno-... flags to CFLAGS, and only then (l. 661) happens to call
_AC_UNDECLARED_WARNING (via gnupg_REPLACE_TTYNAME_R ->
AC_CHECK_DECLS_ONCE -> _AC_CHECK_DECL_BODY) for the first time.
If that configure is invoked with CC=clang supporting
-Wno-missing-field-initializers but not supporting e.g.
-Wno-format-truncation (which is among the bunch of flags optimistically
added to CFLAGS), that was not much of an issue in the past; invocations
of clang kept emitting noisy but harmless
> warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
lines. But now, _AC_CHECK_DECL_BODY fails hard with
> configure:21628: checking how clang reports undeclared, standard C functions
> configure:21645: clang -c -g -O2 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wno-format-y2k -Wno-missing-field-initializers -Wno-sign-compare -Wno-format-zero-length -Wno-format-truncation -Wno-sizeof-pointer-div conftest.c >&5
> warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
> conftest.c:51:8: warning: implicitly declaring library function 'strchr' with type 'char *(const char *, int)' [-Wimplicit-function-declaration]
> (void) strchr;
> ^
> conftest.c:51:8: note: include the header <string.h> or explicitly provide a declaration for 'strchr'
> 2 warnings generated.
> configure:21645: $? = 0
> configure:21675: clang -c -g -O2 -Wall -Wcast-align -Wshadow -Wstrict-prototypes -Wno-format-y2k -Wno-missing-field-initializers -Wno-sign-compare -Wno-format-zero-length -Wno-format-truncation -Wno-sizeof-pointer-div conftest.c >&5
> warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
> 1 warning generated.
> configure:21675: $? = 0
> configure:21679: error: in `/home/sbergman/git.gnupg.org/gpgme':
> configure:21681: error: cannot detect from compiler exit status or warnings
One workaround is to move the gnupg_REPLACE_TTYNAME_R before the
-Wno-missing-field-initializers etc. block in configure.ac. And maybe
there would be a dedicated macro that can be called early to set up
_AC_UNDECLARED_WARNING prior to modifying CFLAGS?
More information about the Gnupg-devel
mailing list