public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] opcodes: Make i386-init.h depend on i386-tbl.h
@ 2022-12-01 16:20 H.J. Lu
  2022-12-01 17:08 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2022-12-01 16:20 UTC (permalink / raw)
  To: binutils

i386-gen will generate both i386-tbl.h and i386-init.h in one go.  Since
both i386-tbl.h and i386-init.h depend on i386-gen, it leads to a race
condition for i386-gen.  Make i386-init.h depend on i386-tbl.h to avoid
the race condition.

	* Makefile.am ($(srcdir)/i386%tbl.h $(srcdir)/i386%init.h):
	Removed.
	($(srcdir)/i386-tbl.h): New rule.
	($(srcdir)/i386-init.h): Likewise.
	* Makefile.in: Regenerated.
---
 opcodes/Makefile.am | 8 +++++---
 opcodes/Makefile.in | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index cb6ff0ebc5e..8565a73e902 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -553,13 +553,15 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcdir)/../include/opcode/i386.h \
 	config.h sysdep.h
 	$(COMPILE_FOR_BUILD) -c $(srcdir)/i386-gen.c
 
-# i386-gen will generate both headers in one go.  Use a pattern rule to properly
-# express this, with the inner dash ('-') arbitrarily chosen to be the stem.
-$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
+# i386-gen will generate both i386-tbl.h and i386-init.h in one go.  Make
+# i386-init.h depend on i386-tbl.h to avoid the race condition.
+$(srcdir)/i386-tbl.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
 	$(AM_V_GEN)$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \
 		< $(srcdir)/i386-opc.tbl \
 		| ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
 
+$(srcdir)/i386-init.h: $(srcdir)/i386-tbl.h
+
 i386-opc.lo: $(srcdir)/i386-tbl.h
 # While not really a dependency, specify i386-init.h here as well to make sure
 # it is generated even if i386-tbl.h is present and up-to-date.
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 5524af5ccd2..ea6fc772def 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -1528,13 +1528,15 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcdir)/../include/opcode/i386.h \
 	config.h sysdep.h
 	$(COMPILE_FOR_BUILD) -c $(srcdir)/i386-gen.c
 
-# i386-gen will generate both headers in one go.  Use a pattern rule to properly
-# express this, with the inner dash ('-') arbitrarily chosen to be the stem.
-$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
+# i386-gen will generate both i386-tbl.h and i386-init.h in one go.  Make
+# i386-init.h depend on i386-tbl.h to avoid the race condition.
+$(srcdir)/i386-tbl.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
 	$(AM_V_GEN)$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \
 		< $(srcdir)/i386-opc.tbl \
 		| ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
 
+$(srcdir)/i386-init.h: $(srcdir)/i386-tbl.h
+
 i386-opc.lo: $(srcdir)/i386-tbl.h
 # While not really a dependency, specify i386-init.h here as well to make sure
 # it is generated even if i386-tbl.h is present and up-to-date.
-- 
2.38.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] opcodes: Make i386-init.h depend on i386-tbl.h
  2022-12-01 16:20 [PATCH] opcodes: Make i386-init.h depend on i386-tbl.h H.J. Lu
@ 2022-12-01 17:08 ` Jan Beulich
  2022-12-01 18:16   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2022-12-01 17:08 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On 01.12.2022 17:20, H.J. Lu via Binutils wrote:
> i386-gen will generate both i386-tbl.h and i386-init.h in one go.  Since
> both i386-tbl.h and i386-init.h depend on i386-gen, it leads to a race
> condition for i386-gen.

This is not true - the use of a pattern rule was specifically introduced
(not very long ago) to signal to make the creation of multiple files by
a single command / rule. What you describe would happen if this rule
wasn't a pattern one. You are in fact ...

>  Make i386-init.h depend on i386-tbl.h to avoid
> the race condition.

... proposing to re-introduce the original problem (just in the
opposite direction) - see commit 79d635fc64ba.

Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] opcodes: Make i386-init.h depend on i386-tbl.h
  2022-12-01 17:08 ` Jan Beulich
@ 2022-12-01 18:16   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2022-12-01 18:16 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On Thu, Dec 1, 2022 at 9:08 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 01.12.2022 17:20, H.J. Lu via Binutils wrote:
> > i386-gen will generate both i386-tbl.h and i386-init.h in one go.  Since
> > both i386-tbl.h and i386-init.h depend on i386-gen, it leads to a race
> > condition for i386-gen.
>
> This is not true - the use of a pattern rule was specifically introduced
> (not very long ago) to signal to make the creation of multiple files by
> a single command / rule. What you describe would happen if this rule
> wasn't a pattern one. You are in fact ...

I
> >  Make i386-init.h depend on i386-tbl.h to avoid
> > the race condition.
>
> ... proposing to re-introduce the original problem (just in the
> opposite direction) - see commit 79d635fc64ba.
>
> Jan

You are right.  I found my mistake.  This patch is withdrawn.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-01 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 16:20 [PATCH] opcodes: Make i386-init.h depend on i386-tbl.h H.J. Lu
2022-12-01 17:08 ` Jan Beulich
2022-12-01 18:16   ` H.J. Lu

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 read-only IMAP folder(s) and NNTP newsgroup(s).