bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parse-datetime: Fix compilation error with bison 3.7


From: Bruno Haible
Subject: Re: parse-datetime: Fix compilation error with bison 3.7
Date: Sun, 13 Sep 2020 22:04:27 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-189-generic; KDE/5.18.0; x86_64; ; )

Hi Daiki,

> One thing I noticed though is that
> parse-datetime-gen.h has no dependency declaration and fails to build
> with parallel make:
> 
>   make[2]: *** No rule to make target 'parse-datetime-gen.h', needed by 
> 'all'.  Stop.
>   make[2]: *** Waiting for unfinished jobs....
>     YACC     parse-datetime.c
>   make[2]: Leaving directory '/tmp/gnutls/build/src/gl'
>   make[1]: *** [Makefile:1761: all-recursive] Error 1

Thanks for reporting this.

> The attached patch fixes it; OK to push?

No, this is not OK. It exhibits the bug mentioned by Paul Smith [1]. Namely,
if parse-datetime-gen.h somehow gets removed, "make" will not rebuild it
and instead will go on to compile parse-datetime.c — which will fail since
parse-datetime-gen.h is not present.

We need a general approach for rules that produce multiple files. There are
three approaches that work without a stamp file [2].

  (I) Assuming GNU make >= 4.3, the "Grouped explicit target" syntax does it.
      But we can't ignore BSD make, Solaris make etc. in gnulib.

  (II) It is possible to turn off parallel make. But some people will cry
       if building the gnulib subdirectory now takes 3 times as long than
       before.

  (III) Use portable make syntax and still allow parallel make.

Below I apply the approach (III).

[1] https://lists.gnu.org/archive/html/bug-make/2019-05/msg00020.html
[2] https://lists.gnu.org/archive/html/bug-make/2020-09/msg00008.html


2020-09-13  Bruno Haible  <bruno@clisp.org>

        parse-datetime: Make the build rule work with parallel 'make'.
        Reported by Daiki Ueno <ueno@gnu.org> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00036.html>.
        * modules/parse-datetime (Makefile.am): Use a phony target and the
        general idiom for rules that produce multiple files.

diff --git a/modules/parse-datetime b/modules/parse-datetime
index 1467519..a16b90f 100644
--- a/modules/parse-datetime
+++ b/modules/parse-datetime
@@ -43,7 +43,10 @@ Makefile.am:
 # Additionally, here we assume GNU Bison and therefore don't need the ylwrap
 # script.
 # Therefore we override this rule.
-parse-datetime.c: parse-datetime.y
+# Since this is a rule that produces multiple files, we apply the idiom from
+# <https://lists.gnu.org/archive/html/bug-make/2020-09/msg00008.html>, so that
+# it works also in parallel 'make'.
+generate-parse-datetime:
        $(AM_V_YACC)$(PARSE_DATETIME_BISON) -d $(YFLAGS) $(AM_YFLAGS) 
$(srcdir)/parse-datetime.y \
        && test ':' = '$(PARSE_DATETIME_BISON)' || { \
          sed -e 's|".*/parse-datetime\.y"|"parse-datetime.y"|' \
@@ -57,6 +60,13 @@ parse-datetime.c: parse-datetime.y
          && mv parse-datetime.c-tmp $(srcdir)/parse-datetime.c \
          && mv parse-datetime-gen.h-tmp $(srcdir)/parse-datetime-gen.h; \
        }
+.PHONY: generate-parse-datetime
+# The above rule will generate files with time stamp order
+# parse-datetime.y <= parse-datetime.c <= parse-datetime-gen.h.
+parse-datetime.c: parse-datetime.y
+       @{ test -f $(srcdir)/parse-datetime.c && test ! 
$(srcdir)/parse-datetime.c -ot $(srcdir)/parse-datetime.y; } || $(MAKE) 
generate-parse-datetime
+parse-datetime-gen.h: parse-datetime.c
+       @{ test -f $(srcdir)/parse-datetime-gen.h && test ! 
$(srcdir)/parse-datetime-gen.h -ot $(srcdir)/parse-datetime.c; } || $(MAKE) 
generate-parse-datetime
 lib_SOURCES += parse-datetime.y
 BUILT_SOURCES += parse-datetime.c parse-datetime-gen.h
 MOSTLYCLEANFILES += parse-datetime.tab.c parse-datetime.tab.h 
parse-datetime.c-tmp parse-datetime-gen.h-tmp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]