foss-for-synopsys-dwc-arc-processors / qemu

QEMU port for ARCv2 Processors
Other
12 stars 9 forks source link

Compilation Issue #178

Closed jumpy4 closed 1 year ago

jumpy4 commented 1 year ago

Hi.

I'm trying to compile the program on Debian Sid (chroot environment), and I'm running into an error. Any help would be appreciated. This is the terminal output:

`FAILED: libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o 
cc -m32 -Ilibqemu-arc-softmmu.fa.p -I. -I.. -Itarget/arc -I../target/arc -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -isystem /home/fnn/Documents/arc/qemu-arc/qemu/linux-headers -isystem linux-headers -iquote . -iquote /home/fnn/Documents/arc/qemu-arc/qemu -iquote /home/fnn/Documents/arc/qemu-arc/qemu/include -iquote /home/fnn/Documents/arc/qemu-arc/qemu/disas/libvixl -iquote /home/fnn/Documents/arc/qemu-arc/qemu/tcg/i386 -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="arc-softmmu-config-target.h"' '-DCONFIG_DEVICES="arc-softmmu-config-devices.h"' -MD -MQ libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o -MF libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o.d -o libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o -c ../target/arc/arconnect.c
In file included from /home/fnn/Documents/arc/qemu-arc/qemu/include/qemu/osdep.h:37,
                 from ../target/arc/arconnect.c:20:
../target/arc/arconnect.c: In function 'arcon_status_read':
/home/fnn/Documents/arc/qemu-arc/qemu/include/qemu/compiler.h:76:36: error: static assertion failed: "not expecting: sizeof(*&(get_cpu_for_core(core_id)->env.arconnect.intrpt_status)) > ATOMIC_REG_SIZE"
   76 | #define QEMU_BUILD_BUG_MSG(x, msg) _Static_assert(!(x), msg)
      |                                    ^~~~~~~~~~~~~~
/home/fnn/Documents/arc/qemu-arc/qemu/include/qemu/compiler.h:78:30: note: in expansion of macro 'QEMU_BUILD_BUG_MSG'
   78 | #define QEMU_BUILD_BUG_ON(x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)
      |                              ^~~~~~~~~~~~~~~~~~
/home/fnn/Documents/arc/qemu-arc/qemu/include/qemu/atomic.h:134:5: note: in expansion of macro 'QEMU_BUILD_BUG_ON'
  134 |     QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \
      |     ^~~~~~~~~~~~~~~~~
../target/arc/arconnect.c:143:20: note: in expansion of macro 'qatomic_read'
  143 |     uint64_t ret = qatomic_read(&(get_cpu_for_core(core_id)->env.arconnect.intrpt_status));
      |                    ^~~~~~~~~~~~
In file included from ../target/arc/arconnect.c:21:
../target/arc/arconnect.c:145:13: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]
  145 |             "[ICI %d] Reading intrpt_status in core %d. (read: 0x%lx)\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146 |             cpu->core_id, core_id, ret);
      |                                    ~~~
      |                                    |
      |                                    uint64_t {aka long long unsigned int}
/home/fnn/Documents/arc/qemu-arc/qemu/include/qemu/log.h:120:22: note: in definition of macro 'qemu_log_mask'
  120 |             qemu_log(FMT, ## __VA_ARGS__);              \
      |                      ^~~
../target/arc/arconnect.c:145:68: note: format string is defined here
  145 |             "[ICI %d] Reading intrpt_status in core %d. (read: 0x%lx)\n",
      |                                                                  ~~^
      |                                                                    |
      |                                                                    long unsigned int
      |                                                                  %llx
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.
make: *** [Makefile:163: run-ninja] Error 1`
abrodkin commented 1 year ago

That happens because you're compiling for 32-bit host (I assume either you use 32-bit Debian version or have CFLAGS=-m32 ). Even though there's nothing wrong with that, I guess we rarely target 32-bit platforms ourselves. But we'll get it fixed with use of right types where appropriate. Unfortunately adding --disable-werror to QEMU's ./configure string doesn't help in that case (see below) so the only immediate work-around for now is to target 64-bit host, is that doable for you? If not, how gating is that QEMU building for 32-bit host for you?

cc -m32 -Ilibqemu-arc-softmmu.fa.p -I. -I.. -Itarget/arc -I../target/arc -I../capstone/include/capstone -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -std=gnu11 -O2 -g -isystem .../qemu/linux-headers -isystem linux-headers -iquote . -iquote .../qemu -iquote .../qemu/include -iquote .../qemu/disas/libvixl -iquote .../qemu/tcg/i386 -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong -m32 -fPIE -isystem../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="arc-softmmu-config-target.h"' '-DCONFIG_DEVICES="arc-softmmu-config-devices.h"' -MD -MQ libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o -MF libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o.d -o libqemu-arc-softmmu.fa.p/target_arc_arconnect.c.o -c ../target/arc/arconnect.c
In file included from .../qemu/include/qemu/osdep.h:37,
                 from ../target/arc/arconnect.c:20:
../target/arc/arconnect.c: In function ‘arcon_status_read’:
.../qemu/include/qemu/compiler.h:76:36: error: static assertion failed: "not expecting: sizeof(*&(get_cpu_for_core(core_id)->env.arconnect.intrpt_status)) > ATOMIC_REG_SIZE"
   76 | #define QEMU_BUILD_BUG_MSG(x, msg) _Static_assert(!(x), msg)
      |                                    ^~~~~~~~~~~~~~
.../qemu/include/qemu/compiler.h:78:30: note: in expansion of macro ‘QEMU_BUILD_BUG_MSG’
   78 | #define QEMU_BUILD_BUG_ON(x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)
      |                              ^~~~~~~~~~~~~~~~~~
.../qemu/include/qemu/atomic.h:134:5: note: in expansion of macro ‘QEMU_BUILD_BUG_ON’
  134 |     QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \
      |     ^~~~~~~~~~~~~~~~~
../target/arc/arconnect.c:143:20: note: in expansion of macro ‘qatomic_read’
  143 |     uint64_t ret = qatomic_read(&(get_cpu_for_core(core_id)->env.arconnect.intrpt_status));
      |                    ^~~~~~~~~~~~
...
ninja: build stopped: subcommand failed.
jumpy4 commented 1 year ago

Thanks. I tried doing it not in any special environment, and everything worked perfectly.