GNU bug report logs - #9933
Flex header files

Previous Next

Package: automake;

Reported by: Bruce Korb <bkorb <at> gnu.org>

Date: Tue, 1 Nov 2011 16:26:01 UTC

Severity: wishlist

Merged with 8844

Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9933 in the body.
You can then email your comments to 9933 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#9933; Package automake. (Tue, 01 Nov 2011 16:26:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefano Lattarini <stefano.lattarini <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Tue, 01 Nov 2011 16:26:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: bug-automake <at> gnu.org
Cc: Bruce Korb <bkorb <at> gnu.org>, automake <at> gnu.org
Subject: Re: ylwrap bug
Date: Tue, 1 Nov 2011 17:22:56 +0100
[CC:ing bug-automake]
[replies can drop the automake list]

Hi Bruce.  In the future, please send bug reports to bug-automake,
so that our bug tracker will keep track of them.  Thanks.

On Tuesday 01 November 2011, Bruce Korb wrote:
> PING:
> 
> The bison accepts the option, --header-file=whatever.h
> "ylwrap" is a wrapper script meant to canonicalize the invocation
> of yacc and bison.  True enough, if you use --header-file you
> had better be using bison, but here is the problem:
> 
> I am working on a project that will only build in a GNU tools environment.
> Therefore, I know that the .l -> .c transformation tool is flex, not
> POSIX lex.  The code I am working with presumes that it can use this:
>     AM_LFLAGS = @LEX_FL@ --header-file=$(LEX_HEADER) -DYY_NO_INPUT=1
> So ylwrap fires off the flex program and it runs just fine, the tiny
> problem is that it also removes the temporary directory before I can
> salvage the generated header.  This is inconvenient.
>
Long-standing bug/limitation.  There are a couple of (dormant) branches
in the automake repository that try to tackle similar issues for yacc
(see also automake bug#7648): `yacc-work' and `ylwrap-refactor'.  But
even if these branches will be finally completed and merged, the changes
they introduce will only appear in automake 1.12.

Regards,
  Stefano




Changed bug submitter to 'Bruce Korb <bkorb <at> gnu.org>' from 'Stefano Lattarini <stefano.lattarini <at> gmail.com>' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 01 Nov 2011 16:28:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#9933; Package automake. (Tue, 01 Nov 2011 18:34:02 GMT) Full text and rfc822 format available.

Message #10 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bruce Korb <bkorb <at> gnu.org>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: bug-automake <at> gnu.org
Subject: Re: ylwrap bug
Date: Tue, 01 Nov 2011 09:56:55 -0700
On 11/01/11 09:22, Stefano Lattarini wrote:
>>      AM_LFLAGS = @LEX_FL@ --header-file=$(LEX_HEADER) -DYY_NO_INPUT=1
>> So ylwrap fires off the flex program and it runs just fine, the tiny
>> problem is that it also removes the temporary directory before I can
>> salvage the generated header.  This is inconvenient.
>>
> Long-standing bug/limitation.  [...]  the changes
> [... might] only appear in automake 1.12.

Excellent!  I cannot expect any better.  I'll just need to know what
text to look for in ylwrap to indicate a proper fix so I can disable
that sed hackery that wiggles around the problem.  :)

Thank you so much!  Regards, Bruce




Information forwarded to bug-automake <at> gnu.org:
bug#9933; Package automake. (Mon, 23 Jul 2012 10:03:02 GMT) Full text and rfc822 format available.

Message #13 received at 9933 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Bruce Korb <bkorb <at> gnu.org>
Cc: 9933 <at> debbugs.gnu.org
Subject: Re: bug#9933: ylwrap bug
Date: Mon, 23 Jul 2012 11:55:53 +0200
tags 9933 + moreinfo
thanks

Hi Bruce, sorry for the delay.

On 11/01/2011 05:56 PM, Bruce Korb wrote:
> On 11/01/11 09:22, Stefano Lattarini wrote:
>>>      AM_LFLAGS = @LEX_FL@ --header-file=$(LEX_HEADER) -DYY_NO_INPUT=1
>>> So ylwrap fires off the flex program and it runs just fine, the tiny
>>> problem is that it also removes the temporary directory before I can
>>> salvage the generated header.  This is inconvenient.
>>>
>> Long-standing bug/limitation.  [...]  the changes
>> [... might] only appear in automake 1.12.
> 
> Excellent!  I cannot expect any better.  I'll just need to know what
> text to look for in ylwrap to indicate a proper fix so I can disable
> that sed hackery that wiggles around the problem.  :)
>
The recent flurry of ylwrap patches from Akim Demaille should have solved
your problem as well.  Could you give a try to the development version of
ylwrap:
 <http://git.savannah.gnu.org/cgit/automake.git/plain/lib/ylwrap?h=maint>
and see if it works correctly in your use case?

Thanks,
  Stefano




Added tag(s) moreinfo. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 23 Jul 2012 10:03:02 GMT) Full text and rfc822 format available.

Forcibly Merged 8844 9933. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 26 Aug 2012 16:44:02 GMT) Full text and rfc822 format available.

Removed tag(s) moreinfo. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 26 Aug 2012 16:49:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#9933; Package automake. (Sun, 26 Aug 2012 17:33:02 GMT) Full text and rfc822 format available.

Message #22 received at 9933 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: "automake-patches <at> gnu.org" <automake-patches <at> gnu.org>
Cc: 9933 <at> debbugs.gnu.org, Pippijn van Steenhoven <pip88nl <at> gmail.com>,
	Bruce Korb <bkorb <at> gnu.org>, 8844 <at> debbugs.gnu.org
Subject: Flex header files
Date: Sun, 26 Aug 2012 19:31:51 +0200
retitle 8844 Flex header files
retitle 9933 Flex header files
close 8844
close 9933
thanks

Replying to two old bug reports:

  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8844>
  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9933>

===========================================================================

> On Monday 13 June 2011, Pippijn van Steenhoven wrote:
>
>> Hi,
>>
>> in some of my projects, I use (reentrant) flex with the header-file
>> option. This causes flex to generate a .h file in addition to the usual
>> lex.yy.c file. However, ylwrap doesn't know about this. What would be the
>> correct way to use flex with header files?
>>
> I see two ways out, not mutually exclusive:
> 
>  1. Introduce a new automake option `no-ylwrap', instructing automake not
>     to use ylwrap to process Yacc and Lex files; this should assume that
>     bison and flex can be used, so that we know no problem with concurrent
>     make will arise (we can use the `--output' option for both tools).
>     Then you can manually add some rules about the header on your
>     Makefile.am, without ylwrap getting in your way.
> 
>  2. Improve ylwrap and automake Lex support to recognize the `--header'
>     Lex option, similarly to what is done for the `-d' Yacc option, and
>     emit code handling the header creation, dependencies, etc.
> 
> Regards,
>   Stefano
>

==========================================================================

On Tuesday 01 November 2011, Bruce Korb wrote:
>
> The bison accepts the option, --header-file=whatever.h
> "ylwrap" is a wrapper script meant to canonicalize the invocation
> of yacc and bison.  True enough, if you use --header-file you
> had better be using bison, but here is the problem:
>
> I am working on a project that will only build in a GNU tools environment.
> Therefore, I know that the .l -> .c transformation tool is flex, not
> POSIX lex.  The code I am working with presumes that it can use this:
>     AM_LFLAGS = @LEX_FL@ --header-file=$(LEX_HEADER) -DYY_NO_INPUT=1
> So ylwrap fires off the flex program and it runs just fine, the tiny
> problem is that it also removes the temporary directory before I can
> salvage the generated header.  This is inconvenient.
>

==========================================================================

These issues have been fixed thanks to the recent work done by Akim Demaille
on ylwrap.  I've checking in the test case below to ensure we won't regress
on this use case.  And I'm finally closing these bug reports.

Thanks,
  Stefano

-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

From 9557b2f89263c8ffe00106430fca8758f6118438 Mon Sep 17 00:00:00 2001
Message-Id: <9557b2f89263c8ffe00106430fca8758f6118438.1346001914.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Sun, 26 Aug 2012 19:25:02 +0200
Subject: [PATCH] coverage: bugs #8844 and #9933 (already fixed by Akim's work on ylwrap)

* t/flex-header.sh: New test, show that automake bug#8844 and have already
been fixed by the recent-ish improvements to ylwrap (merged with commit
v1.12.2-27-gec5cb49 of 2012-07-16, "Merge branch 'yacc-work' into maint").
* t/list-of-tests.mk: Update.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 t/lex-header.sh    | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 t/list-of-tests.mk |  1 +
 2 files changed, 86 insertions(+)
 create mode 100755 t/lex-header.sh

diff --git a/t/lex-header.sh b/t/lex-header.sh
new file mode 100755
index 0000000..06c8561
--- /dev/null
+++ b/t/lex-header.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Automake lex support can work with flex '--header' option (see
+# bugs #8844 and #9933).
+
+required='cc flex'
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = lexer.l main.c mylex.h
+foo_LFLAGS = --header-file=mylex.h
+BUILT_SOURCES = mylex.h
+# Recover from removal of header.
+mylex.h: foo-lexer.c
+	test -f $@ || rm -f foo-lexer.c
+	test -f $@ || $(MAKE) $(AM_MAKEFLAGS) foo-lexer.c
+END
+
+cat > lexer.l << 'END'
+%option noyywrap
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD"   return EOF;
+.
+%%
+END
+
+cat > main.c <<'END'
+#include "mylex.h"
+int main (void)
+{
+  /* We don't use a 'while' loop here (like a real lexer would do)
+     to avoid possible hangs. */
+  if (yylex () == EOF)
+    return 0;
+  else
+    return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Program should build and run.
+$MAKE
+if ! cross_compiling; then
+  echo GOOD | ./foo
+  echo BAD | ./foo && exit 1
+  : For shells with busted 'set -e'.
+fi
+
+# Recovering from header removal.
+rm -f mylexer.h
+$MAKE
+
+# Sanity check on distribution.
+yl_distcheck
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index f72a6fa..ff4448e 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -566,6 +566,7 @@ t/lex5.sh \
 t/lexcpp.sh \
 t/lexvpath.sh \
 t/lex-subobj-nodep.sh \
+t/lex-header.sh \
 t/lex-lib.sh \
 t/lex-lib-external.sh \
 t/lex-libobj.sh \
-- 
1.7.12





Changed bug title to 'Flex header files' from 'ylwrap bug' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 26 Aug 2012 17:33:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 8844 <at> debbugs.gnu.org and Stefano Lattarini <stefano.lattarini <at> gmail.com> Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 26 Aug 2012 17:33:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 24 Sep 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 215 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.