vivier / qemu-m68k

Other
41 stars 7 forks source link

qemu_system_reset_request declaration missmatch when compiling with -flto #43

Closed baryluk closed 5 years ago

baryluk commented 5 years ago

gcc 9.2.1

  LINK    m68k-softmmu/qemu-system-m68k
/home/user/qemu-m68k/target/m68k/op_helper.c:39:13: error: type of ‘qemu_system_reset_request’ does not match original declaration [-Werror=lto-type-mismatch]
   39 | extern void qemu_system_reset_request(void);
      |             ^
vl.c:1611:6: note: type mismatch in parameter 1
vl.c:1611:6: note: type ‘ShutdownCause’ should match type ‘void’
vl.c:1611:6: note: ‘qemu_system_reset_request’ was previously declared here
lto1: all warnings being treated as errors

For reference vlc.:1611:

void qemu_system_reset_request(ShutdownCause reason)
{
...
baryluk commented 5 years ago

Fixing redeclaration to extern void qemu_system_reset_request(Shutdowncause); and then in target/m68k/op_helper.c line , function m68k_interrupt_all calling it as qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);, resolves the issue. (One might need to include sysemu/runstate.h and/or qapi/qapi-types-run-state.h for it to fully work).

However, I would also recommend doing #include "sysemu/runstate.h" directly maybe in this op_helper.c file, and removing manual extern declaration to prevent similar issues in the future. This is what most other targets are doing, and these include files are very small, so extern doesn't bring any advantages.

vivier commented 5 years ago

Fixed now.