Message ID | 20180528211028.24130-1-yann.morin.1998@free.fr (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Yann E. MORIN <yann.morin.1998@free.fr> wrote: > When neither token.h nor token_var.h exist, and we are building in > parallel, it is possible that make will spawn two mktokens at roughly > the same time, because of two different rules, one that needs token.h ad > another that need token_vars.h. > > For example, make can have a dependency chain toward just token.h, from > syntax.c, and another dependency chain toweard token_vars.h from the > generic BUILT_SOURCES. > > So, make will "quickly" decide that it needs token.h, then spawn > mktoken. A bit later, while that mktoken still runs but hasn't yet > created token_vars.h, make will need it, and thus spawn a second > mktoken. > > While the second one runs, the first terminates. However, the token.h it > had generated has been in the meantime overwritten by the second mktoken > that is still generating it, and token.h is still empty. > > But make proceeds to the rule that required token.h in the first place, > and the still-empty token.h gets icluded from a C file, and the build > fails because of missing defines. > > For example: > http://autobuild.buildroot.org/results/fc4/fc4e4ab47455ac47dd4a3a60083cec2848e74dbb/build-end.log > > Fix that by serialising both headers. > > Reported-by: Baruch Siach <baruch@tkos.co.il> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > Cc: Baruch Siach <baruch@tkos.co.il> > --- > src/Makefile.am | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/Makefile.am b/src/Makefile.am > index 46399c7..5bf5a52 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -44,7 +44,8 @@ EXTRA_DIST = \ > mktokens mkbuiltins builtins.def.in mkinit.c \ > mknodes.c nodetypes nodes.c.pat mksyntax.c mksignames.c > > -token.h token_vars.h: mktokens > +token_vars.h: token.h > +token.h: mktokens > $(SHELL) $^ I don't think this is always going to work. If you do a make and then remove token_vars.h wouldn't this fail? Also there is no guarantee that the two timestamps will be in the order that you expect. The same problem also applies to all the other rules in the Makefile with multiple targets. Until there is a good solution to rules with multiple targets, perhaps we should just disable parallel building in dash. Thanks,
diff --git a/src/Makefile.am b/src/Makefile.am index 46399c7..5bf5a52 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,8 @@ EXTRA_DIST = \ mktokens mkbuiltins builtins.def.in mkinit.c \ mknodes.c nodetypes nodes.c.pat mksyntax.c mksignames.c -token.h token_vars.h: mktokens +token_vars.h: token.h +token.h: mktokens $(SHELL) $^ builtins.def: builtins.def.in $(top_builddir)/config.h
When neither token.h nor token_var.h exist, and we are building in parallel, it is possible that make will spawn two mktokens at roughly the same time, because of two different rules, one that needs token.h ad another that need token_vars.h. For example, make can have a dependency chain toward just token.h, from syntax.c, and another dependency chain toweard token_vars.h from the generic BUILT_SOURCES. So, make will "quickly" decide that it needs token.h, then spawn mktoken. A bit later, while that mktoken still runs but hasn't yet created token_vars.h, make will need it, and thus spawn a second mktoken. While the second one runs, the first terminates. However, the token.h it had generated has been in the meantime overwritten by the second mktoken that is still generating it, and token.h is still empty. But make proceeds to the rule that required token.h in the first place, and the still-empty token.h gets icluded from a C file, and the build fails because of missing defines. For example: http://autobuild.buildroot.org/results/fc4/fc4e4ab47455ac47dd4a3a60083cec2848e74dbb/build-end.log Fix that by serialising both headers. Reported-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Baruch Siach <baruch@tkos.co.il> --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)