* [PATCH 1/2] Makefile: limit make re-execution to avoid infinite spin
@ 2022-09-25 10:42 Sergei Trofimovich
[not found] ` <20220925104203.648449-1-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Trofimovich @ 2022-09-25 10:42 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Sergei Trofimovich
make-4.4 became intentionally more eager at rebuilding outdated Makefile
includes. Currently this causes `dtc` to spin infinitely in
parser/dependency loop:
$ make
...
CHK version_gen.h
BISON dtc-parser.tab.h
DEP dtc-lexer.lex.c
DEP dtc-parser.tab.c
CHK version_gen.h
BISON dtc-parser.tab.h
DEP dtc-lexer.lex.c
DEP dtc-parser.tab.c
... # never stops
After the change build eventually fails when gets into this state:
$ make
...
CHK version_gen.h
UPD version_gen.h
DEP util.c
BISON dtc-parser.tab.h
DEP dtc-lexer.lex.c
DEP dtc-parser.tab.c
CHK version_gen.h
BISON dtc-parser.tab.h
DEP dtc-lexer.lex.c
DEP dtc-parser.tab.c
Makefile:394: *** "Make re-executed itself 10 times. Infinite recursion?". Stop.
The actual recursion will be fixed separately.
Signed-off-by: Sergei Trofimovich <slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index 9f1223f..e7a0dcb 100644
--- a/Makefile
+++ b/Makefile
@@ -389,3 +389,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
$(BISON) -b $(basename $(basename $@)) -d $<
FORCE:
+
+ifeq ($(MAKE_RESTARTS),10)
+$(error "Make re-executed itself $(MAKE_RESTARTS) times. Infinite recursion?")
+endif
--
2.37.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] Makefile: fix infinite recursion by dropping non-existent `%.output`
[not found] ` <20220925104203.648449-1-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-09-25 10:42 ` Sergei Trofimovich
[not found] ` <20220925104203.648449-2-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Trofimovich @ 2022-09-25 10:42 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Sergei Trofimovich
Without the change GNU `make-4.4` falls into infinite recursion of trying
to generate %.output files (bison is not passed flags to generate debug
output).
This happens on GNU `make-4.4` only after GNU make change to more eagerly
rebuild all target outputs in multiple targets:
https://savannah.gnu.org/bugs/index.php?63098
The recursion here is the following:
- Makefile depends on *.d files
- *.d files depend on *.c files
- *.c files are generated by bison
- bison is triggered whenever some of it's multiple targets are missing
In our case `%.output` is always missing and bison is always reran.
*.d files are always regenerated on `make` run. And make is always
restarted as *.d files are always regenerated.
The fix removes infeasible `%.output`.
Signed-off-by: Sergei Trofimovich <slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index e7a0dcb..d4e7551 100644
--- a/Makefile
+++ b/Makefile
@@ -384,7 +384,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
@$(VECHO) LEX $@
$(LEX) -o$@ $<
-%.tab.c %.tab.h %.output: %.y
+%.tab.c %.tab.h: %.y
@$(VECHO) BISON $@
$(BISON) -b $(basename $(basename $@)) -d $<
--
2.37.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] Makefile: fix infinite recursion by dropping non-existent `%.output`
[not found] ` <20220925104203.648449-2-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-09-26 5:24 ` David Gibson
0 siblings, 0 replies; 3+ messages in thread
From: David Gibson @ 2022-09-26 5:24 UTC (permalink / raw)
To: Sergei Trofimovich; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]
On Sun, Sep 25, 2022 at 11:42:03AM +0100, Sergei Trofimovich wrote:
> Without the change GNU `make-4.4` falls into infinite recursion of trying
> to generate %.output files (bison is not passed flags to generate debug
> output).
>
> This happens on GNU `make-4.4` only after GNU make change to more eagerly
> rebuild all target outputs in multiple targets:
> https://savannah.gnu.org/bugs/index.php?63098
>
> The recursion here is the following:
>
> - Makefile depends on *.d files
> - *.d files depend on *.c files
> - *.c files are generated by bison
> - bison is triggered whenever some of it's multiple targets are missing
>
> In our case `%.output` is always missing and bison is always reran.
> *.d files are always regenerated on `make` run. And make is always
> restarted as *.d files are always regenerated.
>
> The fix removes infeasible `%.output`.
>
> Signed-off-by: Sergei Trofimovich <slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Huh, interesting. That .output target seems to have been there since
the dawn of time, really can't remember why it was included in the
first place.
Anyway, both patches applied, thanks.
> ---
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index e7a0dcb..d4e7551 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -384,7 +384,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
> @$(VECHO) LEX $@
> $(LEX) -o$@ $<
>
> -%.tab.c %.tab.h %.output: %.y
> +%.tab.c %.tab.h: %.y
> @$(VECHO) BISON $@
> $(BISON) -b $(basename $(basename $@)) -d $<
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-26 5:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 10:42 [PATCH 1/2] Makefile: limit make re-execution to avoid infinite spin Sergei Trofimovich
[not found] ` <20220925104203.648449-1-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-09-25 10:42 ` [PATCH 2/2] Makefile: fix infinite recursion by dropping non-existent `%.output` Sergei Trofimovich
[not found] ` <20220925104203.648449-2-slyich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-09-26 5:24 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).