[1/3] sim: split sim/callback.h include out

Message ID 20210616063302.20722-1-vapier@gentoo.org
State New
Headers show
Series
  • [1/3] sim: split sim/callback.h include out
Related show

Commit Message

Eli Zaretskii via Gdb-patches June 16, 2021, 6:33 a.m.
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.

Start with splitting out sim/callback.h.
---
 sim/common/cgen-trace.c  | 1 +
 sim/common/nrun.c        | 1 +
 sim/common/sim-basics.h  | 1 -
 sim/common/sim-endian.h  | 1 +
 sim/common/sim-hw.c      | 1 +
 sim/common/sim-io.c      | 1 +
 sim/common/sim-syscall.c | 1 +
 sim/common/sim-syscall.h | 2 ++
 sim/common/sim-trace.c   | 1 +
 sim/common/sim-utils.h   | 1 +
 sim/cris/traps.c         | 1 +
 sim/frv/traps.c          | 1 +
 sim/h8300/compile.c      | 1 +
 sim/m68hc11/sim-main.h   | 1 -
 14 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.31.1

Comments

Eli Zaretskii via Gdb-patches June 20, 2021, 3:11 p.m. | #1
On 2021-06-16 2:33 a.m., Mike Frysinger via Gdb-patches wrote:
> The sim-basics.h is too big and includes too many things.  This leads

> to some arch's sim-main.h having circular loop issues with defs, and

> makes it hard to separate out common objects from arch-specific defs.

> By splitting up sim-basics.h and killing off sim-main.h, it'll make

> it easier to separate out the two.

> 

> Start with splitting out sim/callback.h.


Starting with this patch (according to bisect), I get this link error:


make[3]: Entering directory '/home/simark/build/binutils-gdb/sim/erc32'
ccache gcc -DHAVE_CONFIG_H     -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0   -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration   -I. -I/home/simark/src/binutils-gdb/sim/erc32 -I../common -I/home/simark/src/binutils-gdb/sim/erc32/../common -I../../include -I/home/simark/src/binutils-gdb/sim/erc32/../../include -I../../bfd -I/home/simark/src/binutils-gdb/sim/erc32/../../bfd -I../../opcodes -I/home/simark/src/binutils-gdb/sim/erc32/../../opcodes -I../..  -I/home/simark/src/binutils-gdb/sim/erc32/../../gnulib/import -I../../gnulib/import  -DFAST_UART -I/home/simark/src/binutils-gdb/sim/erc32/../.. -g3 -O0 -fsanitize=address -fmax-errors=1 -fdiagnostics-color=always   -o sis \
  sis.o exec.o erc32.o func.o help.o float.o ../common/common_libcommon_a-portability.o ../common/common_libcommon_a-sim-load.o ../common/common_libcommon_a-version.o ../../bfd/libbfd.a ../../opcodes/libopcodes.a  ../../libiberty/libiberty.a -lm -ltinfo -ldl -lnsl  -lz -lreadline -ltinfo -lm  ../../gnulib/import/libgnu.a 
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: warning: relocation against `current_target_byte_order' in read-only section `.text'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `LSEXTRACTED':
/home/simark/src/binutils-gdb/sim/common/sim-bits.c:64: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `MSEXTRACTED':
/home/simark/src/binutils-gdb/sim/common/sim-bits.c:99: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `LSINSERTED':
/home/simark/src/binutils-gdb/sim/common/sim-bits.c:134: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `MSINSERTED':
/home/simark/src/binutils-gdb/sim/common/sim-bits.c:170: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `LSSEXT':
/home/simark/src/binutils-gdb/sim/common/sim-bits.c:207: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o:/home/simark/src/binutils-gdb/sim/common/sim-bits.c:234: more undefined references to `sim_io_error' follow
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_t2h_1':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_h2t_1':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `offset_1':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:145: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:146: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:147: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_t2h_2':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_h2t_2':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `offset_2':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:145: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:146: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:147: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_t2h_4':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_h2t_4':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `offset_4':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:145: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:146: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:147: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_t2h_8':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_h2t_8':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `offset_8':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:145: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:146: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:147: undefined reference to `sim_io_error'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_t2h_16':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:47: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `endian_h2t_16':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:61: undefined reference to `current_target_byte_order'
/usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `offset_16':
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:145: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:146: undefined reference to `sim_io_error'
/usr/bin/ld: /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:147: undefined reference to `sim_io_error'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

Simon
Eli Zaretskii via Gdb-patches June 20, 2021, 8:56 p.m. | #2
On 20 Jun 2021 11:11, Simon Marchi wrote:
> On 2021-06-16 2:33 a.m., Mike Frysinger via Gdb-patches wrote:

> > The sim-basics.h is too big and includes too many things.  This leads

> > to some arch's sim-main.h having circular loop issues with defs, and

> > makes it hard to separate out common objects from arch-specific defs.

> > By splitting up sim-basics.h and killing off sim-main.h, it'll make

> > it easier to separate out the two.

> > 

> > Start with splitting out sim/callback.h.

> 

> Starting with this patch (according to bisect), I get this link error:


bisecting is why i've been doing small/medium patches and not giant dumps :).

> make[3]: Entering directory '/home/simark/build/binutils-gdb/sim/erc32'

> ccache gcc -DHAVE_CONFIG_H     -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0   -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration   -I. -I/home/simark/src/binutils-gdb/sim/erc32 -I../common -I/home/simark/src/binutils-gdb/sim/erc32/../common -I../../include -I/home/simark/src/binutils-gdb/sim/erc32/../../include -I../../bfd -I/home/simark/src/binutils-gdb/sim/erc32/../../bfd -I../../opcodes -I/home/simark/src/binutils-gdb/sim/erc32/../../opcodes -I../..  -I/home/simark/src/binutils-gdb/sim/erc32/../../gnulib/import -I../../gnulib/import  -DFAST_UART -I/home/simark/src/binutils-gdb/sim/erc32/../.. -g3 -O0 -fsanitize=address -fmax-errors=1 -fdiagnostics-color=always   -o sis \

>   sis.o exec.o erc32.o func.o help.o float.o ../common/common_libcommon_a-portability.o ../common/common_libcommon_a-sim-load.o ../common/common_libcommon_a-version.o ../../bfd/libbfd.a ../../opcodes/libopcodes.a  ../../libiberty/libiberty.a -lm -ltinfo -ldl -lnsl  -lz -lreadline -ltinfo -lm  ../../gnulib/import/libgnu.a 

> /usr/bin/ld: ../common/common_libcommon_a-sim-load.o: warning: relocation against `current_target_byte_order' in read-only section `.text'

> /usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `LSEXTRACTED':

> /home/simark/src/binutils-gdb/sim/common/sim-bits.c:64: undefined reference to `sim_io_error'


this is weird.  it builds fine for me with -O0.  i just tried with sanitizers
enabled too and still passes.  all with gcc-11.1.

but let's focus on the error.

LSEXTRACTED doesn't call sim_io_error.  it does call the ASSERT macro which
might expand to calling sim_io_error, but that includes sim-io.h before using
the func.  so that part looks ok.

sim_io_error is defined in sim-io.o.  but erc32 doesn't link that in.  but it
also doesn't use it in general ...

why does your sim-load have references to LSEXTRACTED et al in the first place ?
sim-load doesn't use any of those APIs.  i guess this gets back to your system
not handling static/inline the way others are for some reason ?

$ readelf -sW common/common_libcommon_a-sim-load.o  | grep sim
  1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS sim-load.c
 17: 0000000000000127   990 FUNC    GLOBAL DEFAULT    1 sim_load_file
-mike
Eli Zaretskii via Gdb-patches June 21, 2021, 5:38 p.m. | #3
On 2021-06-20 4:56 p.m., Mike Frysinger wrote:
> On 20 Jun 2021 11:11, Simon Marchi wrote:

>> On 2021-06-16 2:33 a.m., Mike Frysinger via Gdb-patches wrote:

>>> The sim-basics.h is too big and includes too many things.  This leads

>>> to some arch's sim-main.h having circular loop issues with defs, and

>>> makes it hard to separate out common objects from arch-specific defs.

>>> By splitting up sim-basics.h and killing off sim-main.h, it'll make

>>> it easier to separate out the two.

>>>

>>> Start with splitting out sim/callback.h.

>>

>> Starting with this patch (according to bisect), I get this link error:

> 

> bisecting is why i've been doing small/medium patches and not giant dumps :).

> 

>> make[3]: Entering directory '/home/simark/build/binutils-gdb/sim/erc32'

>> ccache gcc -DHAVE_CONFIG_H     -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0   -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration   -I. -I/home/simark/src/binutils-gdb/sim/erc32 -I../common -I/home/simark/src/binutils-gdb/sim/erc32/../common -I../../include -I/home/simark/src/binutils-gdb/sim/erc32/../../include -I../../bfd -I/home/simark/src/binutils-gdb/sim/erc32/../../bfd -I../../opcodes -I/home/simark/src/binutils-gdb/sim/erc32/../../opcodes -I../..  -I/home/simark/src/binutils-gdb/sim/erc32/../../gnulib/import -I../../gnulib/import  -DFAST_UART -I/home/simark/src/binutils-gdb/sim/erc32/../.. -g3 -O0 -fsanitize=address -fmax-errors=1 -fdiagnostics-color=always   -o sis \

>>   sis.o exec.o erc32.o func.o help.o float.o ../common/common_libcommon_a-portability.o ../common/common_libcommon_a-sim-load.o ../common/common_libcommon_a-version.o ../../bfd/libbfd.a ../../opcodes/libopcodes.a  ../../libiberty/libiberty.a -lm -ltinfo -ldl -lnsl  -lz -lreadline -ltinfo -lm  ../../gnulib/import/libgnu.a 

>> /usr/bin/ld: ../common/common_libcommon_a-sim-load.o: warning: relocation against `current_target_byte_order' in read-only section `.text'

>> /usr/bin/ld: ../common/common_libcommon_a-sim-load.o: in function `LSEXTRACTED':

>> /home/simark/src/binutils-gdb/sim/common/sim-bits.c:64: undefined reference to `sim_io_error'

> 

> this is weird.  it builds fine for me with -O0.  i just tried with sanitizers

> enabled too and still passes.  all with gcc-11.1.

> 

> but let's focus on the error.

> 

> LSEXTRACTED doesn't call sim_io_error.  it does call the ASSERT macro which

> might expand to calling sim_io_error, but that includes sim-io.h before using

> the func.  so that part looks ok.

> 

> sim_io_error is defined in sim-io.o.  but erc32 doesn't link that in.  but it

> also doesn't use it in general ...

> 

> why does your sim-load have references to LSEXTRACTED et al in the first place ?

> sim-load doesn't use any of those APIs.  i guess this gets back to your system

> not handling static/inline the way others are for some reason ?

> 

> $ readelf -sW common/common_libcommon_a-sim-load.o  | grep sim

>   1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS sim-load.c

>  17: 0000000000000127   990 FUNC    GLOBAL DEFAULT    1 sim_load_file

> -mike

> 


Well, it builds fine now, I probably was just in a bad state.  Sorry for
the noise.

Simon
Eli Zaretskii via Gdb-patches June 21, 2021, 11:48 p.m. | #4
On 21 Jun 2021 13:38, Simon Marchi via Gdb-patches wrote:
> Well, it builds fine now, I probably was just in a bad state.  Sorry for

> the noise.


np.  i've been a bit unhappy with the build in general and it detecting
changes.  i'm hoping the move to automake will help more with that, and
with getting more knobs out of CPPFLAGS and into config.h (or doing it
at runtime).

i've gotten a bit in the habit of doing `make clean` and leaning on ccache
to keep rebuilds fast.
-mike

Patch

diff --git a/sim/common/cgen-trace.c b/sim/common/cgen-trace.c
index 66250c09be75..206720ca1395 100644
--- a/sim/common/cgen-trace.c
+++ b/sim/common/cgen-trace.c
@@ -26,6 +26,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "bfd.h"
 #include "sim-main.h"
 #include "sim-fpu.h"
+#include "sim/callback.h"
 
 #ifndef SIZE_INSTRUCTION
 #define SIZE_INSTRUCTION 16
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index e39a0c6ed546..ba293d1ce736 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -23,6 +23,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <string.h>
 
 #include "sim-main.h"
+#include "sim/callback.h"
 
 #include "bfd.h"
 #include "environ.h"
diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h
index ac63aef456ac..13547422d3c3 100644
--- a/sim/common/sim-basics.h
+++ b/sim/common/sim-basics.h
@@ -112,7 +112,6 @@  typedef enum {
 /* Basic definitions - ordered so that nothing calls what comes after it.  */
 
 #include "ansidecl.h"
-#include "sim/callback.h"
 #include "sim/sim.h"
 
 #include "sim-config.h"
diff --git a/sim/common/sim-endian.h b/sim/common/sim-endian.h
index 6e9101fa3f02..7b663a3375ce 100644
--- a/sim/common/sim-endian.h
+++ b/sim/common/sim-endian.h
@@ -23,6 +23,7 @@ 
 #ifndef SIM_ENDIAN_H
 #define SIM_ENDIAN_H
 
+#include "bfd.h"
 
 /* C byte conversion functions */
 
diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c
index 95d95042ded4..9a3db171d1b3 100644
--- a/sim/common/sim-hw.c
+++ b/sim/common/sim-hw.c
@@ -23,6 +23,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-main.h"
 #include "sim-assert.h"
 #include "sim-options.h"
+#include "sim/callback.h"
 
 #include "sim-hw.h"
 
diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c
index b5e874bef794..e09a4af7ba2e 100644
--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -24,6 +24,7 @@ 
 
 #include "sim-main.h"
 #include "sim-io.h"
+#include "sim/callback.h"
 #include "targ-vals.h"
 
 #include <errno.h>
diff --git a/sim/common/sim-syscall.c b/sim/common/sim-syscall.c
index 0f7601cafd73..be3ff8f82e2c 100644
--- a/sim/common/sim-syscall.c
+++ b/sim/common/sim-syscall.c
@@ -24,6 +24,7 @@ 
 
 #include "sim-main.h"
 #include "sim-syscall.h"
+#include "sim/callback.h"
 #include "targ-vals.h"
 
 /* Read/write functions for system call interface.  */
diff --git a/sim/common/sim-syscall.h b/sim/common/sim-syscall.h
index 6f79d9dfce96..562f443cb99a 100644
--- a/sim/common/sim-syscall.h
+++ b/sim/common/sim-syscall.h
@@ -20,6 +20,8 @@ 
 #ifndef SIM_SYSCALL_H
 #define SIM_SYSCALL_H
 
+struct cb_syscall;
+
 /* Perform a syscall on the behalf of the target program.  The error/result are
    normalized into a single value (like a lot of operating systems do).  If you
    want the split values, see the other function below.
diff --git a/sim/common/sim-trace.c b/sim/common/sim-trace.c
index b8224e0b8346..2c3798933db3 100644
--- a/sim/common/sim-trace.c
+++ b/sim/common/sim-trace.c
@@ -24,6 +24,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-io.h"
 #include "sim-options.h"
 #include "sim-fpu.h"
+#include "sim/callback.h"
 
 #include "bfd.h"
 #include "libiberty.h"
diff --git a/sim/common/sim-utils.h b/sim/common/sim-utils.h
index 9cc19f5567bc..bfc8ac72d08e 100644
--- a/sim/common/sim-utils.h
+++ b/sim/common/sim-utils.h
@@ -60,6 +60,7 @@  SIM_RC sim_analyze_program (SIM_DESC sd, const char *prog_name,
    write the program sections at LMA interpreted as a virtual address.
    This is still accommodated for backward compatibility reasons. */
 
+typedef struct host_callback_struct host_callback;
 typedef int sim_write_fn (SIM_DESC sd, SIM_ADDR mem,
 			  const unsigned char *buf, int length);
 struct bfd *sim_load_file (SIM_DESC sd, const char *myname,
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index a55f7dfb9927..2ad408139d83 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -24,6 +24,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sim-main.h"
 #include "sim-syscall.h"
 #include "sim-options.h"
+#include "sim/callback.h"
 #include "bfd.h"
 /* FIXME: get rid of targ-vals.h usage everywhere else.  */
 
diff --git a/sim/frv/traps.c b/sim/frv/traps.c
index d5cab2496226..91b424fc7e1e 100644
--- a/sim/frv/traps.c
+++ b/sim/frv/traps.c
@@ -28,6 +28,7 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cgen-engine.h"
 #include "cgen-par.h"
 #include "sim-fpu.h"
+#include "sim/callback.h"
 
 #include "bfd.h"
 #include "libiberty.h"
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 01e9766790c8..8b13326a0a9c 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -33,6 +33,7 @@ 
 #include "sys/stat.h"
 #include "sys/types.h"
 #include "sim-options.h"
+#include "sim/callback.h"
 
 #ifndef SIGTRAP
 # define SIGTRAP 5
diff --git a/sim/m68hc11/sim-main.h b/sim/m68hc11/sim-main.h
index 955c69fb38d4..18a7426011b0 100644
--- a/sim/m68hc11/sim-main.h
+++ b/sim/m68hc11/sim-main.h
@@ -28,7 +28,6 @@  along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "opcode/m68hc11.h"
 
-#include "sim/callback.h"
 #include "sim/sim.h"
 #include "opcode/m68hc11.h"
 #include "sim-types.h"