Reputation: 1369
I'm trying to build qemu from sources, I use ./configure --enable-capstone --enable-tcg-plugin --target-list=x86_64-linux-user
to configure it before building using make.
This results in the following error:
ERROR: configure test passed without -Werror but failed with -Werror.
This is probably a bug in the configure script. The failing command
will be at the bottom of config.log.
You can run configure with --disable-werror to bypass this check.
This is the bottom of the config.log
file:
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:2:25: warning: null argument where non-null required (argument 1) [-Wnonnull]
2 | int main(void) { return sem_timedwait(0, 0); }
| ^~~~~~~~~~~~~
config-temp/qemu-conf.c:2:25: warning: null argument where non-null required (argument 2) [-Wnonnull]
cc -Werror -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wno-error=address-of-packed-member -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/include/capstone -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -Wl,-z,relro -Wl,-z,now -pie -m64 -g
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:2:25: error: null argument where non-null required (argument 1) [-Werror=nonnull]
2 | int main(void) { return sem_timedwait(0, 0); }
| ^~~~~~~~~~~~~
config-temp/qemu-conf.c:2:25: error: null argument where non-null required (argument 2) [-Werror=nonnull]
cc1: all warnings being treated as errors
~
~
I also tried to --disable-werror
, this configure
s well, but does not build. it gives the following errors while building:
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/syscall.c:256:16: error: static declaration of ‘gettid’ follows non-static declaration
256 | _syscall0(int, gettid)
| ^~~~~~
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/syscall.c:187:13: note: in definition of macro ‘_syscall0’
187 | static type name (void) \
| ^~~~
In file included from /usr/include/unistd.h:1170,
from /home/p/Desktop/qemu-plugins-tutorial/qemu/include/qemu/osdep.h:90,
from /home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/syscall.c:20:
/usr/include/x86_64-linux-gnu/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
34 | extern __pid_t gettid (void) __THROW;
| ^~~~~~
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/ioctls.h:224:9: error: ‘SIOCGSTAMP’ undeclared here (not in a function); did you mean ‘SIOCSRARP’?
224 | IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
| ^~~~~~~~~~
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/syscall.c:4756:23: note: in definition of macro ‘IOCTL’
4756 | { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
| ^~~
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/ioctls.h:225:9: error: ‘SIOCGSTAMPNS’ undeclared here (not in a function); did you mean ‘SIOCGSTAMP_OLD’?
225 | IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
| ^~~~~~~~~~~~
/home/p/Desktop/qemu-plugins-tutorial/qemu/linux-user/syscall.c:4756:23: note: in definition of macro ‘IOCTL’
4756 | { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
| ^~~
CC x86_64-linux-user/linux-user/strace.o
make[1]: *** [/home/p/Desktop/qemu-plugins-tutorial/qemu/rules.mak:69: linux-user/syscall.o] Error 1
make[1]: *** Waiting for unfinished jobs....
LINK qemu-img
make: *** [Makefile:484: subdir-x86_64-linux-user] Error 2
What would be a possible fix for this?
Upvotes: 0
Views: 1511
Reputation: 11383
The reason for this is that you're trying to build a pretty old version of QEMU against a more recent glibc. Occasionally glibc header changes cause errors in QEMU code that used to compile, and so QEMU is changed to avoid the problem. In this specific case, when glibc 2.29 (or thereabouts) added a gettid() function, this broke the bit of QEMU code that was defining its own function of that name. QEMU commit 71ba74f67eaca21b, from March 2019, is the upstream fix for that.
The simple fix though is: don't try to build really old QEMU: build the most recent version.
If you do have for some reason to build an old QEMU on a newer distro, you should be prepared to have to fix up or work around a few build errors of this form. A couple of techniques for making this easier:
Upvotes: 1