tests/tcg: improve check for working cross compilers
PATCH 1/1 tests/tcg: improve check for working cross compilers
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.
--- tests/tcg/test_cc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/tcg/test_cc.c +5 -1
@@ -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 ) {
Signature · 1 line
2.55.0
Quoted 8 lines · Daniel P. Berrangé
When it finds a cross compiler, tests/tcg/meson.build tries building
test_cc.cto 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
Queued to testing/next, thanks.
<snip>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro