From: Daniel P. Berrangé <[email protected]>
When it finds a cross compiler, tests/tcg/meson.build tries
building test_cc.c to validate that the compiler works. This
includes "stdint.h" as a witness for working C library, however,
that is not a good choice as it can be provided by the toolchain
alone:
$ rpm -ql gcc-s390x-linux-gnu | grep /stdint.h
/usr/lib/gcc/s390x-linux-gnu/16/include/stdint.h
As a result, if you install the s390x GCC cross compiler, but
not any C library, meson decides to use the host compiler instead
of the container:
cc for aarch64-softmmu : aarch64-linux-gnu-gcc (from
'debian-all-test-cross' container)
cc for loongarch64-softmmu : loongarch64-unknown-linux-gnu-gcc (from
'debian-loongarch-cross' container)
cc for riscv64-softmmu : riscv64-linux-gnu-gcc (from
'debian-all-test-cross' container)
cc for s390x-softmmu : s390x-linux-gnu-gcc
cc for x86_64-softmmu : x86_64-linux-gnu-gcc (from
'debian-amd64-cross' container)
Eventually this results in failure to run 'make check':
[33/40] Generating tests/tcg/s390x-softmmu-hello with a custom command
FAILED: [code=1] tests/tcg/s390x-softmmu-hello.test
/usr/bin/s390x-linux-gnu-gcc
/home/berrange/src/virt/qemu/tests/tcg/multiarch/system/hello.c -o
tests/tcg/s390x-softmmu-hello.test -static -MMD -MF
tests/tcg/s390x-softmmu-hello.d -Wall -Werror -O0 -g -fno-strict-aliasing
-nostdlib -ffreestanding -Wa,--noexecstack -I
/home/berrange/src/virt/qemu/tests/tcg/s390x/system/../../minilib
/home/berrange/src/virt/qemu/tests/tcg/s390x/system/../../minilib/printf.c -I
/home/berrange/src/virt/qemu/include/hw/s390x/ipl -march=z13
../tests/tcg/s390x/system/../head64.S ../tests/tcg/s390x/system/../console.c
In file included from ../tests/tcg/s390x/system/../console.c:8:
../tests/tcg/s390x/system/../../../../pc-bios/s390-ccw/sclp.c:11:10: fatal
error: string.h: No such file or directory
11 | #include <string.h>
| ^~~~~~~~~~
compilation terminated.
Adding more include files to the test program ensures the
meson probe makes a better decision.
Fixes: e5d084d622b1 (tests/tcg/meson.build: check host cross cc is working)
Signed-off-by: Daniel P. Berrangé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
---
tests/tcg/test_cc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tests/tcg/test_cc.c b/tests/tcg/test_cc.c
index d3614a01fe6..fafee055b40 100644
--- a/tests/tcg/test_cc.c
+++ b/tests/tcg/test_cc.c
@@ -1,7 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* Include a standard header to make sure cross compiler provides them */
+/* Use some standard headers to ensure the cross compiler provides them */
#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
int main(void)
{
--
2.47.3