qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
@ 2025-02-27 14:13 Peter Maydell
  2025-02-27 16:35 ` Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Peter Maydell @ 2025-02-27 14:13 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Alex Bennée

GCC versions at least 12 through 15 incorrectly report a warning
about code in sha1.c:

tests/tcg/multiarch/sha1.c:161:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
  161 |             SHA1Transform(context->state, &data[i]);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is a piece of stock library code for doing SHA1 which we've
simply copied, rather than writing ourselves. The bug has been
reported to upstream GCC (about a different library's use of this
code):
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709

For our test case, since this isn't our original code and there isn't
actually a bug in it, suppress the incorrect warning rather than
trying to modify the code to work around the compiler issue.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2328
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/tcg/aarch64/Makefile.target   | 3 ++-
 tests/tcg/arm/Makefile.target       | 3 ++-
 tests/tcg/multiarch/Makefile.target | 8 ++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 9efe2f81adf..16ddcf4f883 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -83,7 +83,8 @@ test-aes: CFLAGS += -O -march=armv8-a+aes
 test-aes: test-aes-main.c.inc
 
 # Vector SHA1
-sha1-vector: CFLAGS=-O3
+# Work around compiler false-positive warning, as we do for the 'sha1' test
+sha1-vector: CFLAGS=-O3 -Wno-stringop-overread
 sha1-vector: sha1.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 run-sha1-vector: sha1-vector run-sha1
diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
index 99a953b6671..6189d7a0e24 100644
--- a/tests/tcg/arm/Makefile.target
+++ b/tests/tcg/arm/Makefile.target
@@ -61,7 +61,8 @@ endif
 ARM_TESTS += commpage
 
 # Vector SHA1
-sha1-vector: CFLAGS=-O3
+# Work around compiler false-positive warning, as we do for the 'sha1' test
+sha1-vector: CFLAGS=-O3 -Wno-stringop-overread
 sha1-vector: sha1.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 run-sha1-vector: sha1-vector run-sha1
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
index 688a6be203c..c769a7d69d9 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -45,6 +45,14 @@ vma-pthread: LDFLAGS+=-pthread
 sigreturn-sigmask: CFLAGS+=-pthread
 sigreturn-sigmask: LDFLAGS+=-pthread
 
+# GCC versions 12/13/14/15 at least incorrectly complain about
+# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
+# Since this is just a standard piece of library code we've borrowed for a
+# TCG test case, suppress the warning rather than trying to modify the
+# code to work around the compiler.
+sha1: CFLAGS+=-Wno-stringop-overread
+
 # The vma-pthread seems very sensitive on gitlab and we currently
 # don't know if its exposing a real bug or the test is flaky.
 ifneq ($(GITLAB_CI),)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-02-27 14:13 [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c Peter Maydell
@ 2025-02-27 16:35 ` Richard Henderson
  2025-02-27 22:23 ` Alex Bennée
  2025-03-04 11:56 ` Alex Bennée
  2 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-02-27 16:35 UTC (permalink / raw)
  To: qemu-devel

On 2/27/25 06:13, Peter Maydell wrote:
> GCC versions at least 12 through 15 incorrectly report a warning
> about code in sha1.c:
> 
> tests/tcg/multiarch/sha1.c:161:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
>    161 |             SHA1Transform(context->state, &data[i]);
>        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> This is a piece of stock library code for doing SHA1 which we've
> simply copied, rather than writing ourselves. The bug has been
> reported to upstream GCC (about a different library's use of this
> code):
>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
> 
> For our test case, since this isn't our original code and there isn't
> actually a bug in it, suppress the incorrect warning rather than
> trying to modify the code to work around the compiler issue.
> 
> Resolves:https://gitlab.com/qemu-project/qemu/-/issues/2328
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   tests/tcg/aarch64/Makefile.target   | 3 ++-
>   tests/tcg/arm/Makefile.target       | 3 ++-
>   tests/tcg/multiarch/Makefile.target | 8 ++++++++
>   3 files changed, 12 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-02-27 14:13 [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c Peter Maydell
  2025-02-27 16:35 ` Richard Henderson
@ 2025-02-27 22:23 ` Alex Bennée
  2025-03-04 11:56 ` Alex Bennée
  2 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2025-02-27 22:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel

Peter Maydell <peter.maydell@linaro.org> writes:

> GCC versions at least 12 through 15 incorrectly report a warning
> about code in sha1.c:
>
> tests/tcg/multiarch/sha1.c:161:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
>   161 |             SHA1Transform(context->state, &data[i]);
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This is a piece of stock library code for doing SHA1 which we've
> simply copied, rather than writing ourselves. The bug has been
> reported to upstream GCC (about a different library's use of this
> code):
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
>
> For our test case, since this isn't our original code and there isn't
> actually a bug in it, suppress the incorrect warning rather than
> trying to modify the code to work around the compiler issue.

Queued to maintainer/for-10.0-softfreeze, thanks.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-02-27 14:13 [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c Peter Maydell
  2025-02-27 16:35 ` Richard Henderson
  2025-02-27 22:23 ` Alex Bennée
@ 2025-03-04 11:56 ` Alex Bennée
  2025-03-04 12:51   ` Peter Maydell
  2 siblings, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2025-03-04 11:56 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Brian Cain

Peter Maydell <peter.maydell@linaro.org> writes:

> GCC versions at least 12 through 15 incorrectly report a warning
> about code in sha1.c:
>
> tests/tcg/multiarch/sha1.c:161:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
>   161 |             SHA1Transform(context->state, &data[i]);
>       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This is a piece of stock library code for doing SHA1 which we've
> simply copied, rather than writing ourselves. The bug has been
> reported to upstream GCC (about a different library's use of this
> code):
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
>
> For our test case, since this isn't our original code and there isn't
> actually a bug in it, suppress the incorrect warning rather than
> trying to modify the code to work around the compiler issue.
<snip>
> --- a/tests/tcg/multiarch/Makefile.target
> +++ b/tests/tcg/multiarch/Makefile.target
> @@ -45,6 +45,14 @@ vma-pthread: LDFLAGS+=-pthread
>  sigreturn-sigmask: CFLAGS+=-pthread
>  sigreturn-sigmask: LDFLAGS+=-pthread
>  
> +# GCC versions 12/13/14/15 at least incorrectly complain about
> +# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
> +# Since this is just a standard piece of library code we've borrowed for a
> +# TCG test case, suppress the warning rather than trying to modify the
> +# code to work around the compiler.
> +sha1: CFLAGS+=-Wno-stringop-overread
> +

Sadly this breaks the hexagon compiler:

  error: unknown warning option '-Wno-stringop-overread' [-Werror,-Wunknown-warning-option]
  Traceback (most recent call last):
    File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 683, in <module>
      sys.exit(main())
               ^^^^^^
    File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 679, in main
      return args.cmdobj.run(args, argv)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 657, in run
      return Docker().run(cmd, False, quiet=args.quiet,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 370, in run
      ret = self._do_check(["run", "--rm", "--label",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 247, in _do_check
      return subprocess.check_call(self._command + cmd, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['podman', 'run', '--rm', '--label', 'com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea', '--userns=keep-id', '-u', '1000', '-w', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user', '-v', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:rw', '-v', '/home/alex/lsrc/qemu.git:/home/alex/lsrc/qemu.git:ro,z', 'qemu/debian-hexagon-cross', 'hexagon-unknown-linux-musl-clang', '-Wno-incompatible-pointer-types', '-Wno-undefined-internal', '-fno-unroll-loops', '-fno-stack-protector', '-Wall', '-Werror', '-O0', '-g', '-fno-strict-aliasing', '-Wno-stringop-overread', '-mv73', '-O2', '-static', '/home/alex/lsrc/qemu.git/tests/tcg/multiarch/sha1.c', '-o', 'sha1', '-static']' returned non-zero exit status 1.
  filter=--filter=label=com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea
  make[1]: *** [Makefile:122: sha1] Error 1
  make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:52: build-tcg-tests-hexagon-linux-user] Error 2

Is it that new an option?

>  # The vma-pthread seems very sensitive on gitlab and we currently
>  # don't know if its exposing a real bug or the test is flaky.
>  ifneq ($(GITLAB_CI),)

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 11:56 ` Alex Bennée
@ 2025-03-04 12:51   ` Peter Maydell
  2025-03-04 13:44     ` Alex Bennée
  2025-03-05 14:56     ` Brian Cain
  0 siblings, 2 replies; 13+ messages in thread
From: Peter Maydell @ 2025-03-04 12:51 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-arm, qemu-devel, Brian Cain

On Tue, 4 Mar 2025 at 11:56, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
> > +# GCC versions 12/13/14/15 at least incorrectly complain about
> > +# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
> > +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
> > +# Since this is just a standard piece of library code we've borrowed for a
> > +# TCG test case, suppress the warning rather than trying to modify the
> > +# code to work around the compiler.
> > +sha1: CFLAGS+=-Wno-stringop-overread
> > +
>
> Sadly this breaks the hexagon compiler:
>
>   error: unknown warning option '-Wno-stringop-overread' [-Werror,-Wunknown-warning-option]
>   Traceback (most recent call last):
>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 683, in <module>
>       sys.exit(main())
>                ^^^^^^
>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 679, in main
>       return args.cmdobj.run(args, argv)
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 657, in run
>       return Docker().run(cmd, False, quiet=args.quiet,
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 370, in run
>       ret = self._do_check(["run", "--rm", "--label",
>             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 247, in _do_check
>       return subprocess.check_call(self._command + cmd, **kwargs)
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
>       raise CalledProcessError(retcode, cmd)
>   subprocess.CalledProcessError: Command '['podman', 'run', '--rm', '--label', 'com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea', '--userns=keep-id', '-u', '1000', '-w', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user', '-v', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:rw', '-v', '/home/alex/lsrc/qemu.git:/home/alex/lsrc/qemu.git:ro,z', 'qemu/debian-hexagon-cross', 'hexagon-unknown-linux-musl-clang', '-Wno-incompatible-pointer-types', '-Wno-undefined-internal', '-fno-unroll-loops', '-fno-stack-protector', '-Wall', '-Werror', '-O0', '-g', '-fno-strict-aliasing', '-Wno-stringop-overread', '-mv73', '-O2', '-static', '/home/alex/lsrc/qemu.git/tests/tcg/multiarch/sha1.c', '-o', 'sha1', '-static']' returned non-zero exit status 1.
>   filter=--filter=label=com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea
>   make[1]: *** [Makefile:122: sha1] Error 1
>   make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:52: build-tcg-tests-hexagon-linux-user] Error 2
>
> Is it that new an option?

I think it's new-ish (gcc 11?). On the other hand
-Wno-unknown-warning-option is quite old, and would suppress
this error. If we do
 CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread

does that work?

(Meson has cc.get_supported_arguments() that we can use to
filter out -Wfoo/-Wno-foo options that the compiler doesn't
support, but since this is built via a makefile rather than
by meson that's not conveniently accessible.)

-- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 12:51   ` Peter Maydell
@ 2025-03-04 13:44     ` Alex Bennée
  2025-03-04 13:53       ` Peter Maydell
  2025-03-05 14:56     ` Brian Cain
  1 sibling, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2025-03-04 13:44 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Brian Cain

Peter Maydell <peter.maydell@linaro.org> writes:

> On Tue, 4 Mar 2025 at 11:56, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>> > +# GCC versions 12/13/14/15 at least incorrectly complain about
>> > +# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
>> > +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
>> > +# Since this is just a standard piece of library code we've borrowed for a
>> > +# TCG test case, suppress the warning rather than trying to modify the
>> > +# code to work around the compiler.
>> > +sha1: CFLAGS+=-Wno-stringop-overread
>> > +
>>
>> Sadly this breaks the hexagon compiler:
>>
>>   error: unknown warning option '-Wno-stringop-overread' [-Werror,-Wunknown-warning-option]
>>   Traceback (most recent call last):
>>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 683, in <module>
>>       sys.exit(main())
>>                ^^^^^^
>>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 679, in main
>>       return args.cmdobj.run(args, argv)
>>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 657, in run
>>       return Docker().run(cmd, False, quiet=args.quiet,
>>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 370, in run
>>       ret = self._do_check(["run", "--rm", "--label",
>>             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>     File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 247, in _do_check
>>       return subprocess.check_call(self._command + cmd, **kwargs)
>>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>     File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
>>       raise CalledProcessError(retcode, cmd)
>>   subprocess.CalledProcessError: Command '['podman', 'run', '--rm', '--label', 'com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea', '--userns=keep-id', '-u', '1000', '-w', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user', '-v', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:rw', '-v', '/home/alex/lsrc/qemu.git:/home/alex/lsrc/qemu.git:ro,z', 'qemu/debian-hexagon-cross', 'hexagon-unknown-linux-musl-clang', '-Wno-incompatible-pointer-types', '-Wno-undefined-internal', '-fno-unroll-loops', '-fno-stack-protector', '-Wall', '-Werror', '-O0', '-g', '-fno-strict-aliasing', '-Wno-stringop-overread', '-mv73', '-O2', '-static', '/home/alex/lsrc/qemu.git/tests/tcg/multiarch/sha1.c', '-o', 'sha1', '-static']' returned non-zero exit status 1.
>>   filter=--filter=label=com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea
>>   make[1]: *** [Makefile:122: sha1] Error 1
>>   make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:52: build-tcg-tests-hexagon-linux-user] Error 2
>>
>> Is it that new an option?
>
> I think it's new-ish (gcc 11?). On the other hand
> -Wno-unknown-warning-option is quite old, and would suppress
> this error. If we do
>  CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
>
> does that work?

Yes, I did:

modified   tests/tcg/hexagon/Makefile.target
@@ -18,7 +18,7 @@
 # Hexagon doesn't support gdb, so skip the EXTRA_RUNS
 EXTRA_RUNS =
 
-CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
+CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal -Wno-unknown-warning-option
 CFLAGS += -fno-unroll-loops -fno-stack-protector


>
> (Meson has cc.get_supported_arguments() that we can use to
> filter out -Wfoo/-Wno-foo options that the compiler doesn't
> support, but since this is built via a makefile rather than
> by meson that's not conveniently accessible.)
>
> -- PMM

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 13:44     ` Alex Bennée
@ 2025-03-04 13:53       ` Peter Maydell
  2025-03-04 14:29         ` Alex Bennée
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Maydell @ 2025-03-04 13:53 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-arm, qemu-devel, Brian Cain

On Tue, 4 Mar 2025 at 13:44, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
> > I think it's new-ish (gcc 11?). On the other hand
> > -Wno-unknown-warning-option is quite old, and would suppress
> > this error. If we do
> >  CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
> >
> > does that work?
>
> Yes, I did:
>
> modified   tests/tcg/hexagon/Makefile.target
> @@ -18,7 +18,7 @@
>  # Hexagon doesn't support gdb, so skip the EXTRA_RUNS
>  EXTRA_RUNS =
>
> -CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
> +CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal -Wno-unknown-warning-option
>  CFLAGS += -fno-unroll-loops -fno-stack-protector

I think we should do this where we add -Wno-stringop-overread,
not just for the hexagon tests -- or are the tcg tests
guaranteed to be run with a fixed compiler from a container
regardless of the local dev environment?

-- PMm


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 13:53       ` Peter Maydell
@ 2025-03-04 14:29         ` Alex Bennée
  2025-03-04 14:36           ` Peter Maydell
  0 siblings, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2025-03-04 14:29 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Brian Cain

Peter Maydell <peter.maydell@linaro.org> writes:

> On Tue, 4 Mar 2025 at 13:44, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>> > I think it's new-ish (gcc 11?). On the other hand
>> > -Wno-unknown-warning-option is quite old, and would suppress
>> > this error. If we do
>> >  CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
>> >
>> > does that work?
>>
>> Yes, I did:
>>
>> modified   tests/tcg/hexagon/Makefile.target
>> @@ -18,7 +18,7 @@
>>  # Hexagon doesn't support gdb, so skip the EXTRA_RUNS
>>  EXTRA_RUNS =
>>
>> -CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
>> +CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal -Wno-unknown-warning-option
>>  CFLAGS += -fno-unroll-loops -fno-stack-protector
>
> I think we should do this where we add -Wno-stringop-overread,
> not just for the hexagon tests -- or are the tcg tests
> guaranteed to be run with a fixed compiler from a container
> regardless of the local dev environment?

I can move it, but hexagon is unusual in being clang based. However the
oldest compilers we use are 10.2 in the qemu/debian-legacy-test-cross
container.


>
> -- PMm

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 14:29         ` Alex Bennée
@ 2025-03-04 14:36           ` Peter Maydell
  2025-03-04 15:58             ` Alex Bennée
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Maydell @ 2025-03-04 14:36 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-arm, qemu-devel, Brian Cain

On Tue, 4 Mar 2025 at 14:29, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > On Tue, 4 Mar 2025 at 13:44, Alex Bennée <alex.bennee@linaro.org> wrote:
> >>
> >> Peter Maydell <peter.maydell@linaro.org> writes:
> >> > I think it's new-ish (gcc 11?). On the other hand
> >> > -Wno-unknown-warning-option is quite old, and would suppress
> >> > this error. If we do
> >> >  CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
> >> >
> >> > does that work?
> >>
> >> Yes, I did:
> >>
> >> modified   tests/tcg/hexagon/Makefile.target
> >> @@ -18,7 +18,7 @@
> >>  # Hexagon doesn't support gdb, so skip the EXTRA_RUNS
> >>  EXTRA_RUNS =
> >>
> >> -CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
> >> +CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal -Wno-unknown-warning-option
> >>  CFLAGS += -fno-unroll-loops -fno-stack-protector
> >
> > I think we should do this where we add -Wno-stringop-overread,
> > not just for the hexagon tests -- or are the tcg tests
> > guaranteed to be run with a fixed compiler from a container
> > regardless of the local dev environment?
>
> I can move it, but hexagon is unusual in being clang based. However the
> oldest compilers we use are 10.2 in the qemu/debian-legacy-test-cross
> container.

My question was more "do we only ever build this test with
a fixed set of compilers that we control, or are we instead
maybe sometimes using the user's clang/cc/gcc" ?
If the latter, we definitely need to associate the
"don't warn about unknown warnings" with the place we are
adding the option that's not known across all our supported
compilers. If the former, then putting it in the hexagon
specific file seems OK I guess.

-- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 14:36           ` Peter Maydell
@ 2025-03-04 15:58             ` Alex Bennée
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2025-03-04 15:58 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Brian Cain

Peter Maydell <peter.maydell@linaro.org> writes:

> On Tue, 4 Mar 2025 at 14:29, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>> > On Tue, 4 Mar 2025 at 13:44, Alex Bennée <alex.bennee@linaro.org> wrote:
>> >>
>> >> Peter Maydell <peter.maydell@linaro.org> writes:
>> >> > I think it's new-ish (gcc 11?). On the other hand
>> >> > -Wno-unknown-warning-option is quite old, and would suppress
>> >> > this error. If we do
>> >> >  CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
>> >> >
>> >> > does that work?
>> >>
>> >> Yes, I did:
>> >>
>> >> modified   tests/tcg/hexagon/Makefile.target
>> >> @@ -18,7 +18,7 @@
>> >>  # Hexagon doesn't support gdb, so skip the EXTRA_RUNS
>> >>  EXTRA_RUNS =
>> >>
>> >> -CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
>> >> +CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal -Wno-unknown-warning-option
>> >>  CFLAGS += -fno-unroll-loops -fno-stack-protector
>> >
>> > I think we should do this where we add -Wno-stringop-overread,
>> > not just for the hexagon tests -- or are the tcg tests
>> > guaranteed to be run with a fixed compiler from a container
>> > regardless of the local dev environment?
>>
>> I can move it, but hexagon is unusual in being clang based. However the
>> oldest compilers we use are 10.2 in the qemu/debian-legacy-test-cross
>> container.
>
> My question was more "do we only ever build this test with
> a fixed set of compilers that we control, or are we instead
> maybe sometimes using the user's clang/cc/gcc" ?

Its certainly possible - at least on a Debian system or with the
appropriate --cross-cc-$ARCH flags. I expect 99% of devs either have
Debian or Docker/Podman to fall back on.

> If the latter, we definitely need to associate the
> "don't warn about unknown warnings" with the place we are
> adding the option that's not known across all our supported
> compilers. If the former, then putting it in the hexagon
> specific file seems OK I guess.
>
> -- PMM

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-04 12:51   ` Peter Maydell
  2025-03-04 13:44     ` Alex Bennée
@ 2025-03-05 14:56     ` Brian Cain
  2025-03-05 16:52       ` Peter Maydell
  2025-03-05 16:56       ` Alex Bennée
  1 sibling, 2 replies; 13+ messages in thread
From: Brian Cain @ 2025-03-05 14:56 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée; +Cc: qemu-arm, qemu-devel


On 3/4/2025 6:51 AM, Peter Maydell wrote:
> On Tue, 4 Mar 2025 at 11:56, Alex Bennée <alex.bennee@linaro.org> wrote:
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>> +# GCC versions 12/13/14/15 at least incorrectly complain about
>>> +# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
>>> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
>>> +# Since this is just a standard piece of library code we've borrowed for a
>>> +# TCG test case, suppress the warning rather than trying to modify the
>>> +# code to work around the compiler.
>>> +sha1: CFLAGS+=-Wno-stringop-overread
>>> +
>> Sadly this breaks the hexagon compiler:
>>
>>    error: unknown warning option '-Wno-stringop-overread' [-Werror,-Wunknown-warning-option]
>>    Traceback (most recent call last):
>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 683, in <module>
>>        sys.exit(main())
>>                 ^^^^^^
>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 679, in main
>>        return args.cmdobj.run(args, argv)
>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 657, in run
>>        return Docker().run(cmd, False, quiet=args.quiet,
>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 370, in run
>>        ret = self._do_check(["run", "--rm", "--label",
>>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 247, in _do_check
>>        return subprocess.check_call(self._command + cmd, **kwargs)
>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>      File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
>>        raise CalledProcessError(retcode, cmd)
>>    subprocess.CalledProcessError: Command '['podman', 'run', '--rm', '--label', 'com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea', '--userns=keep-id', '-u', '1000', '-w', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user', '-v', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:rw', '-v', '/home/alex/lsrc/qemu.git:/home/alex/lsrc/qemu.git:ro,z', 'qemu/debian-hexagon-cross', 'hexagon-unknown-linux-musl-clang', '-Wno-incompatible-pointer-types', '-Wno-undefined-internal', '-fno-unroll-loops', '-fno-stack-protector', '-Wall', '-Werror', '-O0', '-g', '-fno-strict-aliasing', '-Wno-stringop-overread', '-mv73', '-O2', '-static', '/home/alex/lsrc/qemu.git/tests/tcg/multiarch/sha1.c', '-o', 'sha1', '-static']' returned non-zero exit status 1.
>>    filter=--filter=label=com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea
>>    make[1]: *** [Makefile:122: sha1] Error 1
>>    make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:52: build-tcg-tests-hexagon-linux-user] Error 2
>>
>> Is it that new an option?
> I think it's new-ish (gcc 11?). On the other hand


I was going to volunteer to update the toolchain used for hexagon to 
address this.  But unfortunately this warning is still not supported in 
clang 21.

https://github.com/llvm/llvm-project/issues/72455 sounds like it's not 
very likely to arrive any time soon.


So "-Wno-unknown-warning-option" does indeed seem like a good workaround.


> -Wno-unknown-warning-option is quite old, and would suppress
> this error. If we do
>   CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread
>
> does that work?
>
> (Meson has cc.get_supported_arguments() that we can use to
> filter out -Wfoo/-Wno-foo options that the compiler doesn't
> support, but since this is built via a makefile rather than
> by meson that's not conveniently accessible.)
>
> -- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-05 14:56     ` Brian Cain
@ 2025-03-05 16:52       ` Peter Maydell
  2025-03-05 16:56       ` Alex Bennée
  1 sibling, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2025-03-05 16:52 UTC (permalink / raw)
  To: Brian Cain; +Cc: Alex Bennée, qemu-arm, qemu-devel

On Wed, 5 Mar 2025 at 14:56, Brian Cain <brian.cain@oss.qualcomm.com> wrote:
> I was going to volunteer to update the toolchain used for hexagon to
> address this.  But unfortunately this warning is still not supported in
> clang 21.
>
> https://github.com/llvm/llvm-project/issues/72455 sounds like it's not
> very likely to arrive any time soon.
>
>
> So "-Wno-unknown-warning-option" does indeed seem like a good workaround.

I think the main problem with clang is that it doesn't default to
"don't complain about unknown warning options", whereas gcc does:

e104462:noble:qemu$ gcc -Wno-bang -o /tmp/hello /tmp/hello.c
e104462:noble:qemu$ clang -Wno-bang -o /tmp/hello /tmp/hello.c
warning: unknown warning option '-Wno-bang' [-Wunknown-warning-option]
1 warning generated.

-- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c
  2025-03-05 14:56     ` Brian Cain
  2025-03-05 16:52       ` Peter Maydell
@ 2025-03-05 16:56       ` Alex Bennée
  1 sibling, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2025-03-05 16:56 UTC (permalink / raw)
  To: Brian Cain; +Cc: Peter Maydell, qemu-arm, qemu-devel

Brian Cain <brian.cain@oss.qualcomm.com> writes:

> On 3/4/2025 6:51 AM, Peter Maydell wrote:
>> On Tue, 4 Mar 2025 at 11:56, Alex Bennée <alex.bennee@linaro.org> wrote:
>>> Peter Maydell <peter.maydell@linaro.org> writes:
>>>> +# GCC versions 12/13/14/15 at least incorrectly complain about
>>>> +# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
>>>> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
>>>> +# Since this is just a standard piece of library code we've borrowed for a
>>>> +# TCG test case, suppress the warning rather than trying to modify the
>>>> +# code to work around the compiler.
>>>> +sha1: CFLAGS+=-Wno-stringop-overread
>>>> +
>>> Sadly this breaks the hexagon compiler:
>>>
>>>    error: unknown warning option '-Wno-stringop-overread' [-Werror,-Wunknown-warning-option]
>>>    Traceback (most recent call last):
>>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 683, in <module>
>>>        sys.exit(main())
>>>                 ^^^^^^
>>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 679, in main
>>>        return args.cmdobj.run(args, argv)
>>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 657, in run
>>>        return Docker().run(cmd, False, quiet=args.quiet,
>>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 370, in run
>>>        ret = self._do_check(["run", "--rm", "--label",
>>>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>      File "/home/alex/lsrc/qemu.git/tests/docker/docker.py", line 247, in _do_check
>>>        return subprocess.check_call(self._command + cmd, **kwargs)
>>>               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>      File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
>>>        raise CalledProcessError(retcode, cmd)
>>>    subprocess.CalledProcessError: Command '['podman', 'run', '--rm', '--label', 'com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea', '--userns=keep-id', '-u', '1000', '-w', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user', '-v', '/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:/home/alex/lsrc/qemu.git/builds/all/tests/tcg/hexagon-linux-user:rw', '-v', '/home/alex/lsrc/qemu.git:/home/alex/lsrc/qemu.git:ro,z', 'qemu/debian-hexagon-cross', 'hexagon-unknown-linux-musl-clang', '-Wno-incompatible-pointer-types', '-Wno-undefined-internal', '-fno-unroll-loops', '-fno-stack-protector', '-Wall', '-Werror', '-O0', '-g', '-fno-strict-aliasing', '-Wno-stringop-overread', '-mv73', '-O2', '-static', '/home/alex/lsrc/qemu.git/tests/tcg/multiarch/sha1.c', '-o', 'sha1', '-static']' returned non-zero exit status 1.
>>>    filter=--filter=label=com.qemu.instance.uuid=5bbb7b6ed2ea4377b9b6d646859ec4ea
>>>    make[1]: *** [Makefile:122: sha1] Error 1
>>>    make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:52: build-tcg-tests-hexagon-linux-user] Error 2
>>>
>>> Is it that new an option?
>> I think it's new-ish (gcc 11?). On the other hand
>
>
> I was going to volunteer to update the toolchain used for hexagon to
> address this.  But unfortunately this warning is still not supported
> in clang 21.
>
> https://github.com/llvm/llvm-project/issues/72455 sounds like it's not
> very likely to arrive any time soon.
>
>
> So "-Wno-unknown-warning-option" does indeed seem like a good workaround.
>
>
>> -Wno-unknown-warning-option is quite old, and would suppress
>> this error. If we do
>>   CFLAGS+=-Wno-unknown-warning-option -Wno-stringop-overread

Workaround is fine for the time being then.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-03-05 16:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 14:13 [PATCH] tests/tcg: Suppress compiler false-positive warning on sha1.c Peter Maydell
2025-02-27 16:35 ` Richard Henderson
2025-02-27 22:23 ` Alex Bennée
2025-03-04 11:56 ` Alex Bennée
2025-03-04 12:51   ` Peter Maydell
2025-03-04 13:44     ` Alex Bennée
2025-03-04 13:53       ` Peter Maydell
2025-03-04 14:29         ` Alex Bennée
2025-03-04 14:36           ` Peter Maydell
2025-03-04 15:58             ` Alex Bennée
2025-03-05 14:56     ` Brian Cain
2025-03-05 16:52       ` Peter Maydell
2025-03-05 16:56       ` Alex Bennée

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).