public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: cr16/d10v: move storage out of header
@ 2021-01-09  8:12 Mike Frysinger
  2021-01-09 11:36 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2021-01-09  8:12 UTC (permalink / raw)
  To: gdb-patches

These ports declare their State variable in a header and then include
multiple times.  This causes linker errors with newer gcc due to the
change in -fno-common behavior.  Move the storage to a C file so we
only have one instance of it in the final program.
---
 sim/cr16/cr16_sim.h | 4 +++-
 sim/cr16/interp.c   | 2 ++
 sim/d10v/d10v_sim.h | 4 +++-
 sim/d10v/interp.c   | 2 ++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/sim/cr16/cr16_sim.h b/sim/cr16/cr16_sim.h
index 4d6f1b95077b..8232f0743f7b 100644
--- a/sim/cr16/cr16_sim.h
+++ b/sim/cr16/cr16_sim.h
@@ -243,7 +243,9 @@ struct _state
 
   enum _ins_type ins_type;
 
-} State;
+};
+
+extern struct _state State;
 
 
 extern uint32 OP[4];
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 0adb68a77225..cff7b8857189 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -33,6 +33,8 @@
 #include "gdb/signals.h"
 #include "opcode/cr16.h"
 
+struct _state State;
+
 int cr16_debug;
 
 uint32 OP[4];
diff --git a/sim/d10v/d10v_sim.h b/sim/d10v/d10v_sim.h
index 86243c9f7002..a3755bf3ccb9 100644
--- a/sim/d10v/d10v_sim.h
+++ b/sim/d10v/d10v_sim.h
@@ -270,7 +270,9 @@ struct _state
 
   enum _ins_type ins_type;
 
-} State;
+};
+
+extern struct _state State;
 
 
 extern uint16 OP[4];
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index cb8c6cf61f5c..5c70b38d9d8f 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -25,6 +25,8 @@
 
 enum _leftright { LEFT_FIRST, RIGHT_FIRST };
 
+struct _state State;
+
 int d10v_debug;
 
 /* Set this to true to get the previous segment layout. */
-- 
2.28.0


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

* Re: [PATCH] sim: cr16/d10v: move storage out of header
  2021-01-09  8:12 [PATCH] sim: cr16/d10v: move storage out of header Mike Frysinger
@ 2021-01-09 11:36 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2021-01-09 11:36 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

* Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-01-09 03:12:43 -0500]:

> These ports declare their State variable in a header and then include
> multiple times.  This causes linker errors with newer gcc due to the
> change in -fno-common behavior.  Move the storage to a C file so we
> only have one instance of it in the final program.
> ---
>  sim/cr16/cr16_sim.h | 4 +++-
>  sim/cr16/interp.c   | 2 ++
>  sim/d10v/d10v_sim.h | 4 +++-
>  sim/d10v/interp.c   | 2 ++
>  4 files changed, 10 insertions(+), 2 deletions(-)

LGTM, but will need a ChangeLog entry.

> 
> diff --git a/sim/cr16/cr16_sim.h b/sim/cr16/cr16_sim.h
> index 4d6f1b95077b..8232f0743f7b 100644
> --- a/sim/cr16/cr16_sim.h
> +++ b/sim/cr16/cr16_sim.h
> @@ -243,7 +243,9 @@ struct _state
>  
>    enum _ins_type ins_type;
>  
> -} State;
> +};
> +
> +extern struct _state State;
>  
>  
>  extern uint32 OP[4];
> diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
> index 0adb68a77225..cff7b8857189 100644
> --- a/sim/cr16/interp.c
> +++ b/sim/cr16/interp.c
> @@ -33,6 +33,8 @@
>  #include "gdb/signals.h"
>  #include "opcode/cr16.h"
>  
> +struct _state State;
> +
>  int cr16_debug;
>  
>  uint32 OP[4];
> diff --git a/sim/d10v/d10v_sim.h b/sim/d10v/d10v_sim.h
> index 86243c9f7002..a3755bf3ccb9 100644
> --- a/sim/d10v/d10v_sim.h
> +++ b/sim/d10v/d10v_sim.h
> @@ -270,7 +270,9 @@ struct _state
>  
>    enum _ins_type ins_type;
>  
> -} State;
> +};
> +
> +extern struct _state State;
>  
>  
>  extern uint16 OP[4];
> diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
> index cb8c6cf61f5c..5c70b38d9d8f 100644
> --- a/sim/d10v/interp.c
> +++ b/sim/d10v/interp.c
> @@ -25,6 +25,8 @@
>  
>  enum _leftright { LEFT_FIRST, RIGHT_FIRST };
>  
> +struct _state State;
> +
>  int d10v_debug;
>  
>  /* Set this to true to get the previous segment layout. */
> -- 
> 2.28.0


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

end of thread, other threads:[~2021-01-09 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09  8:12 [PATCH] sim: cr16/d10v: move storage out of header Mike Frysinger
2021-01-09 11:36 ` Andrew Burgess

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