On Thu, Jul 16, 2020 at 9:46 AM Ross Burton <[email protected]> wrote: > > On Thu, 16 Jul 2020 at 14:08, Zack Weinberg <[email protected]> wrote: > > > Commit 8173e5, 'Fix logic error in _AC_PROG_LEX_YYTEXT_DECL (#109320)', > > > causes AC_PROG_LEX to always fail when searching for a lex library. > > > > Before we give up on this patch I'd like to understand the conditions > > under which it fails. > > Agreed. I admit that the revert was a way of getting attention, I > filed a bug at https://savannah.gnu.org/support/index.php?110269 with > further details.
Bother. This regression is actually the behavior *intended* by the submitter of the original patch (see https://savannah.gnu.org/support/index.php?109320). Formerly, if there was no libl.a nor libfl.a available at all, configure would say "none needed" even though its test program (which uses yywrap without providing a definition) failed to link. They wanted it to fail instead. I presume that gdbm, flex, and gmp provide a definition of yywrap themselves, so they don't actually *need* lib{,f}l.a. > In Flex isn't libfl.so only needed if you want to turn a generated parser > into a stand-alone binary for testing? It also provides a fallback definition of yywrap. Clearly we need to preserve compatibility with these existing autoconf scripts, and I would guess that programs that define yywrap themselves are much more common than those that use the fallback, which is not that useful (all it does is return 1, causing the scanner to stop). I propose to make the following additional changes, instead of reverting the patch: - Change the conftest.l used by _AC_PROG_LEX_YYTEXT_DECL so that it defines yywrap itself (it already defines main). Thus, LEXLIB will only be set to -ll or -lfl if there's something in there *besides* yywrap and main that the generated scanner needs. Document this. - Add a new macro, tentatively AC_FUNC_YYWRAP([action-if-not-found]), that tries to find a definition of yywrap in libl and libfl, sets LEXLIB accordingly, and failing that executes action-if-not-found, which defaults to AC_LIBOBJ([yywrap]). What do you think? zw
