tests: Fix broken tcg test compilation
PATCH v2 1/1 tests: Fix broken tcg test compilation
The first build error to be seen is that linux-test.c fails to include cutils.h:
linux-test.c:42:25: fatal error: qemu/cutils.h: No such file or directory
This is because toplevel include/ dir is not put onto compiler's command line. After that:
qemu.git/include/qemu/cutils.h:171:1: error: unknown type name ‘bool’
So we need to include "qemu/osdep.h" which will define bool type for us. However, osdep.h eventually includes glib.h from system, therefore we need to put GLIB_CFLAGS onto compiler's command line too.
Lastly, getrusage is used in linux-test.c. This function and a struct it uses are defined in sys/resource.h:
linux-test.c:247:5: warning: implicit declaration of function ‘getrusage’
---
diff to v1:
- Move include of osdep.h in linux-test.c at the beginning of the file as suggested by Eric in review
tests/tcg/Makefile | 6 +++--- tests/tcg/linux-test.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-)
tests/tcg/Makefile +3 -3
@@ -89,7 +89,7 @@ hello-i386: hello-i386.c strip $@ testthread: testthread.c - $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread + $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread # i386/x86_64 emulation test (test various opcodes) */ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
@@ -98,7 +98,7 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \ $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm test-i386-fprem: test-i386-fprem.c - $(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^ + $(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ test-x86_64: test-i386.c \ test-i386.h test-i386-shift.h test-i386-muldiv.h
@@ -106,7 +106,7 @@ test-x86_64: test-i386.c \ # generic Linux and CPU test linux-test: linux-test.c - $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm + $(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm # vm86 test runcom: runcom.c
tests/tcg/linux-test.c +4 -0
@@ -16,6 +16,9 @@* You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ + +#include "qemu/osdep.h" +#define _GNU_SOURCE#include <stdarg.h> #include <stdlib.h>
@@ -31,6 +34,7 @@#include <utime.h> #include <time.h> #include <sys/time.h> +#include <sys/resource.h> #include <sys/uio.h> #include <sys/socket.h> #include <netinet/in.h>
Signature · 1 line
2.8.4
Quoted 8 lines · Michal Privoznik
The first build error to be seen is that
linux-test.cfails to includecutils.h:linux-test.c:42:25: fatal error:
qemu/cutils.h: No such file or directoryThis is because toplevel
include/dir is not put onto compiler's command line. After that:
Quoted 6 lines
qemu.git/include/qemu/cutils.h:171:1: error: unknown type name ‘bool’So we need to include "
qemu/osdep.h" which will define bool type for us. However,osdep.heventually includesglib.hfrom system, therefore we need to putGLIB_CFLAGSonto compiler's command line too.
Why are we including qemu/cutils.h anyway? As far as I can see we don't use it for anything and removing the #include doesn't cause any problems...
thanks
-- PMM
Hi Michal,
Quoted 15 lines · Michal Privoznik
The first build error to be seen is that
linux-test.cfails to includecutils.h:linux-test.c:42:25: fatal error:
qemu/cutils.h: No such file or directoryThis is because toplevel
include/dir is not put onto compiler's command line. After that:
qemu.git/include/qemu/cutils.h:171:1: error: unknown type name ‘bool’So we need to include "
qemu/osdep.h" which will define bool type for us. However,osdep.heventually includesglib.hfrom system, therefore we need to putGLIB_CFLAGSonto compiler's command line too.
Quoted 5 lines
Lastly, getrusage is used in
linux-test.c. This function and a struct it uses are defined insys/resource.h:linux-test.c:247:5: warning: implicit declaration of function ‘getrusage’
I recently posted a patch series cleaning up tests/tcg. While doing that I fixed the build issues I came across.
Please see: https://www.mail-archive.com/[email protected]/msg393764.html
Thanks,
--
Pranith