public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: mips: fix missing prototype in multi-run generation
@ 2021-11-04  3:52 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-11-04  3:52 UTC (permalink / raw)
  To: gdb-patches

The multi-run logic for mips involves a bit of codegen and rewriting
of files to include per-architecture prefixes.  That can result in
files with missing prototypes which cause compiler errors.  In the
case of mips-sde-elf targets, we have:
$srcdir/m16run.c -> $builddir/m16mips64r2_run.c
  sim_engine_run -> m16mips64r2_engine_run
$srcdir/micromipsrun.c -> micromipsmicromips_run.c
  sim_engine_run -> micromips64micromips_engine_run

micromipsmicromips_run.c:80:1: error: no previous prototype for ‘micromips64micromips_engine_run’ [-Werror=missing-prototypes]
   80 | micromips64micromips_engine_run (SIM_DESC sd, int next_cpu_nr, int nr_cpus,

We generate headers for those prototypes in the configure script,
but only include them in the generated multi-run.c file.  Update the
rewrite logic to turn the sim-engine.h include into the relevant
generated engine include so these files also have their prototypes.
$srcdir/m16run.c -> $builddir/m16mips64r2_run.c
  sim-engine.h -> m16mips64r2_engine.h
$srcdir/micromipsrun.c -> micromipsmicromips_run.c
  sim-engine.h -> micromips64micromips_engine.h
---
 sim/mips/Makefile.in | 3 +++
 sim/mips/m16run.c    | 1 +
 2 files changed, 4 insertions(+)

diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index b34fdf5b461e..589c392edb53 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -553,6 +553,7 @@ tmp-run-multi: $(srcdir)/m16run.c $(srcdir)/micromipsrun.c
 	      m=`echo $${t} | sed -e 's/^m16//' -e 's/:.*//'`; \
 	      sed <  $(srcdir)/m16run.c > tmp-run \
 		    -e "s/^sim_/m16$${m}_/" \
+		    -e "/include/s/sim-engine/m16$${m}_engine/" \
 		    -e "s/m16_/m16$${m}_/" \
 		    -e "s/m32_/m32$${m}_/" ; \
 	      $(SHELL) $(srcdir)/../../move-if-change tmp-run \
@@ -562,6 +563,7 @@ tmp-run-multi: $(srcdir)/m16run.c $(srcdir)/micromipsrun.c
 	      m=`echo $${t} | sed -e 's/^micromips32//' -e 's/:.*//'`; \
 	      sed <  $(srcdir)/micromipsrun.c > tmp-run \
 		    -e "s/^sim_/micromips32$${m}_/" \
+		    -e "/include/s/sim-engine/micromips32$${m}_engine/" \
 		    -e "s/micromips16_/micromips16$${m}_/" \
 		    -e "s/micromips32_/micromips32$${m}_/" \
 		    -e "s/m32_/m32$${m}_/" ; \
@@ -572,6 +574,7 @@ tmp-run-multi: $(srcdir)/m16run.c $(srcdir)/micromipsrun.c
 	      m=`echo $${t} | sed -e 's/^micromips64//' -e 's/:.*//'`; \
 	      sed <  $(srcdir)/micromipsrun.c > tmp-run \
 		    -e "s/^sim_/micromips64$${m}_/" \
+		    -e "/include/s/sim-engine/micromips64$${m}_engine/" \
 		    -e "s/micromips16_/micromips16$${m}_/" \
 		    -e "s/micromips32_/micromips64$${m}_/" \
 		    -e "s/m32_/m64$${m}_/" ; \
diff --git a/sim/mips/m16run.c b/sim/mips/m16run.c
index a04e3eed3bf3..bbe487e4e513 100644
--- a/sim/mips/m16run.c
+++ b/sim/mips/m16run.c
@@ -24,6 +24,7 @@
 #include "m16_idecode.h"
 #include "m32_idecode.h"
 #include "bfd.h"
+#include "sim-engine.h"
 
 
 #define SD sd
-- 
2.33.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-04  3:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  3:52 [PATCH] sim: mips: fix missing prototype in multi-run generation Mike Frysinger

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).