From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
qemu-devel@nongnu.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: Re: [PATCH 2/9] tests/tcg: improve check for working cross compilers
Date: Mon, 14 Sep 2026 17:07:06 +0100 [thread overview]
Message-ID: <87a4pjddg5.fsf@draig.linaro.org> (raw)
In-Reply-To: <aqexk7afMhWLxf3w@redhat.com> ("Daniel P. Berrangé"'s message of "Mon, 14 Sep 2026 09:34:27 +0100")
Daniel P. Berrangé <berrange@redhat.com> writes:
(trimed cc list, add Ilya)
> On Sun, Sep 13, 2026 at 10:08:52PM -0700, Pierrick Bouvier wrote:
>> On 9/10/26 11:14 AM, Alex Bennée wrote:
>> > From: Daniel P. Berrangé <berrange@redhat.com>
>> >
>> > 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é <berrange@redhat.com>
>> > Message-ID: <20260910100120.2076092-1-berrange@redhat.com>
>> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> > ---
>> > 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)
>> > {
>>
>> Ideally, we should do separate tests for system vs user tests.
>> System ones are always compiled with -ffreestanding, while user ones should
>> provide a C library.
>>
>> From this standard:
>>
>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2338r3.html
>> ```
>> A freestanding C implementation is required to provide the entirety of the
>> following headers:
>>
>> <float.h>
>> <iso646.h>
>> <limits.h>
>> <stdalign.h>
>> <stdarg.h>
>> <stdbool.h>
>> <stddef.h>
>> <stdint.h>
>> <stdnoreturn.h>
>> Most of <string.h> is required (strdup, strndup, strcoll, strxfrm, and
>> strerror are excluded). This includes strtok, which requires global data.
>> ```
>>
>> Maybe for now we can just remove stdio.h from current patch, as it's not
>> supposed to be provided in a freestanding environment.
>
> A huge number of files under tests/tcg/ have a #include <stdio.h>
> currently.
They are all *-user mode tests though, which do need a proper libc.
>
> In the example build failure in the commit message, we have
>
> tests/tcg/s390x/system/../console.c
>
> which does
>
> #include "../../../pc-bios/s390-ccw/sclp.c"
>
> and sclp.c has
>
> #include "s390-ccw.h"
>
> and that header has:
>
> #include <stdbool.h>
> #include <stddef.h>
> #include <stdint.h>
> #include <stdio.h>
>
> hence the 4 headers I added to the meson check.
>
> So AFAICT, our code is expecting stdio.h to be provided in a
> -ffreestanding build. Have we got a more fundamental mistake
> wrt our use of -ffreestanding, such that it is relying on
> unintended functionality ?
They shouldn't - but s390x seems to be doing something funky here. Ilya
can you explain what s390x is trying to do here?
>
> With regards,
> Daniel
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-09-14 16:08 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 18:14 [PATCH 0/9] testing: various docker clean-ups post meson tcg conversion Alex Bennée
2026-09-10 18:14 ` [PATCH 1/9] scripts/meson-buildoptions.sh: update missing options Alex Bennée
2026-09-10 20:03 ` Fabiano Rosas
2026-09-10 22:17 ` Alex Bennée
2026-09-14 5:00 ` Pierrick Bouvier
2026-09-14 10:22 ` Paolo Bonzini
2026-09-10 18:14 ` [PATCH 2/9] tests/tcg: improve check for working cross compilers Alex Bennée
2026-09-14 5:08 ` Pierrick Bouvier
2026-09-14 8:34 ` Daniel P. Berrangé
2026-09-14 16:05 ` Pierrick Bouvier
2026-09-14 16:07 ` Alex Bennée [this message]
2026-09-14 23:55 ` Ilya Leoshkevich
2026-09-15 0:21 ` Pierrick Bouvier
2026-09-10 18:14 ` [PATCH 3/9] tests/tcg: prefix meson built docker tags with qemu/ Alex Bennée
2026-09-14 5:10 ` Pierrick Bouvier
2026-09-10 18:14 ` [PATCH 4/9] tests/tcg: use --add-current-user when building containers Alex Bennée
2026-09-14 5:15 ` Pierrick Bouvier
2026-09-14 7:27 ` Alex Bennée
2026-09-14 15:59 ` Pierrick Bouvier
2026-09-10 18:15 ` [PATCH 5/9] tests/docker: add container registry to configure and use Alex Bennée
2026-09-14 5:21 ` Pierrick Bouvier
2026-09-14 7:28 ` Alex Bennée
2026-09-14 16:15 ` Pierrick Bouvier
2026-09-14 16:18 ` Pierrick Bouvier
2026-09-15 17:10 ` Alex Bennée
2026-09-15 17:49 ` Pierrick Bouvier
2026-09-10 18:15 ` [PATCH 6/9] tests/docker: remove used _read_qemu_dockerfile Alex Bennée
2026-09-14 5:21 ` Pierrick Bouvier
2026-09-10 18:15 ` [PATCH 7/9] tests/docker: strip remaining caching logic from docker.py Alex Bennée
2026-09-14 5:22 ` Pierrick Bouvier
2026-09-10 18:15 ` [PATCH 8/9] tests/docker: add specific command to parser Alex Bennée
2026-09-14 5:22 ` Pierrick Bouvier
2026-09-10 18:15 ` [PATCH 9/9] tests/docker: swap --quiet for --verbose Alex Bennée
2026-09-12 8:46 ` [PATCH 0/9] testing: various docker clean-ups post meson tcg conversion Richard Henderson
2026-09-12 17:24 ` Alex Bennée
2026-09-12 10:52 ` Richard Henderson
2026-09-12 19:37 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a4pjddg5.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=iii@linux.ibm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox