qemu FTBFS with GCC 12

Bug #1988710 reported by Paride Legovini
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-12 (Ubuntu)
Confirmed
Medium
Unassigned
qemu (Ubuntu)
Fix Released
High
Christian Ehrhardt 

Bug Description

qemu 1:7.0+dfsg-7ubuntu1 FTBFS on Kinetic due to an extra warning emitted by gcc 12:

----------------

In function ‘ppc64_patch_handlers’,
    inlined from ‘cpu_970_init’ at /<<PKGBUILDDIR>>/roms/openbios/arch/ppc/qemu/init.c:433:5:
/<<PKGBUILDDIR>>/roms/openbios/arch/ppc/qemu/init.c:400:10: error: array subscript 0 is outside array bounds of ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=array-bounds]
  400 | *dsi = 0x48002002;
      | ~~~~~^~~~~~~~~~~~
/<<PKGBUILDDIR>>/roms/openbios/arch/ppc/qemu/init.c:403:10: error: array subscript 0 is outside array bounds of ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=array-bounds]
  403 | *isi = 0x48002202;
      | ~~~~~^~~~~~~~~~~~

[...]

cc1: all warnings being treated as errors
make[3]: *** [rules.mak:323: target/arch/ppc/qemu/init.o] Error 1

----------------

Test rebuild done in this PPA:

  https://launchpad.net/~paride/+archive/ubuntu/qemu-nochange

Full build log:

  https://launchpadlibrarian.net/621778341/buildlog_ubuntu-kinetic-amd64.qemu_1%3A7.0+dfsg-7ubuntu1~kineticppa1_BUILDING.txt.gz

Tags: fr-2662

Related branches

Paride Legovini (paride)
Changed in qemu (Ubuntu):
importance: Undecided → High
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hmm,
0x48002002 < 0xFFFFFFFF

Is that a false positive or am I looking at the wrong target for this warning.
There are various reports about this and so far most I found where different kinds of false positives.
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101977
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104657
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

If you consider this a false positive at the end of your check consider for now doing a wrapper with just this warning disabled on those two assignments:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
        code
#pragma GCC diagnostic pop

Revision history for this message
Paride Legovini (paride) wrote :

I agree it looks like a false positive, I'll try that pragma and comment back.

Revision history for this message
Paride Legovini (paride) wrote (last edit ):
Download full text (3.2 KiB)

I added those pragmas via a quilt patch, but I'm unsure if and how the patch should be submitted upstream. I was thinking about opening an openbios bug (as the patched code come from https://github.com/openbios/, brought into the qemu source tree as a git submodule), but apparently Debian can compile qemu 7.0+dfsg-7 with GCC 12, see:

https://buildd.debian.org/status/fetch.php?pkg=qemu&arch=amd64&ver=1%3A7.0%2Bdfsg-7%2Bb1&stamp=1660766914&raw=0

so I'm not sure we have a solid case for an upstream bug.

In any case I tried recompiling with those pragmas but qemu still ftbfs, with a different error this time. Again it only failed on amd64.

PPA: https://launchpad.net/~paride/+archive/ubuntu/qemu-lp1921664/+packages

Full amd64 build log: https://launchpadlibrarian.net/621847743/buildlog_ubuntu-kinetic-amd64.qemu_1%3A7.0+dfsg-7ubuntu2~ppa2_BUILDING.txt.gz

Log excerpt:

console.c: In function ‘do_console’:
console.c:130:12: internal compiler error: in emit_move_insn, at expr.cc:4010
  130 | vga[0] = 'H' + attr;
      | ~~~~~~~^~~~~~~~~~~~
0x137917b internal_error(char const*, ...)
 ???:0
0x5a9326 fancy_abort(char const*, int, char const*)
 ???:0
0xe0a692 alpha_split_const_mov(machine_mode, rtx_def**)
 ???:0
0xe0a801 alpha_expand_mov(machine_mode, rtx_def**)
 ???:0
0x112e2dd gen_movv4hi(rtx_def*, rtx_def*)
 ???:0
0x7eedeb emit_move_insn_1(rtx_def*, rtx_def*)
 ???:0
0x7ef1d7 emit_move_insn(rtx_def*, rtx_def*)
 ???:0
0xe0d016 alpha_expand_movmisalign(machine_mode, rtx_def**)
 ???:0
0x112e5aa gen_movmisalignv4hi(rtx_def*, rtx_def*)
 ???:0
0xa278fc expand_insn(insn_code, unsigned int, expand_operand*)
 ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
alpha-linux-gnu-gcc -Wa,-m21264 -Wa,--noexecstack -DSYSTEM_H='"sys-clipper.h"' -c -o console-low.o console-low.S
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o ps2port.o ps2port.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o pci.o pci.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o vgaio.o vgaio.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o vgatables.o vgatables.c
Preprocessed source stored into /tmp/cchX2bbT.out file, please attach this to your bugreport.
=== BEGIN GCC DUMP ===

[long dump]

=== END GCC DUMP ===
make[3]: *** [<builtin>: console.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/<<PKGBUILDDIR>>/b/qemu-palcode'
make[2]: *** [debian/rules:560: b/qemu-palcode/palcode-clipper] Error 2
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
make[1]: *** [debian/rules:657: i...

Read more...

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Since in the latter FTBFS the compiler crashes you might want to get Doko involved?

Revision history for this message
Paride Legovini (paride) wrote :

+1, I see you already subscribed him, thanks. I just retriggered the PPA build, let's see if crashes consistently:

https://launchpad.net/~paride/+archive/ubuntu/qemu-lp1921664/+build/24337146

Revision history for this message
Paride Legovini (paride) wrote :
Paride Legovini (paride)
tags: added: rls-kk-incoming
Revision history for this message
Paride Legovini (paride) wrote :

Added tags and tasks to get a triage round from Foundations.

summary: - FTBFS with GCC 12
+ qemu FTBFS with GCC 12
tags: added: fr-2662
Revision history for this message
Brian Murray (brian-murray) wrote :

During the Foundations team meeting schopin indicated he had fixed a similar issue in lxc so you might want to look at the changes in lxc version 1:5.0.0~git2209-g5a7b9ce67-0ubuntu3 and ubuntu2.

Revision history for this message
Paride Legovini (paride) wrote :

By looking at that diff [1] looks like it's meant to fix an array-bounds warning, which is the issue described in this bug's description. However we I managed to silence that warning in qemu by using the pragmas Christian suggested, but then the package FTBFS with a compiler crash which looks unrelated (see comment 3 of this bug).

[1] http://launchpadlibrarian.net/622217429/lxc_1%3A5.0.0~git2209-g5a7b9ce67-0ubuntu2_1%3A5.0.0~git2209-g5a7b9ce67-0ubuntu3.diff.gz

tags: added: foundations-todo
removed: rls-kk-incoming
Revision history for this message
Paride Legovini (paride) wrote :

The latest FTBFS is with gcc-12_12.2.0-1ubuntu1, I see that now we have 12.2.0-2ubuntu1 in the archive, and it has a bunch of fixes. I'm retrying a build with it.

Revision history for this message
Paride Legovini (paride) wrote :
Download full text (20.9 KiB)

Same compile crash, see:

https://launchpadlibrarian.net/623533933/buildlog_ubuntu-kinetic-amd64.qemu_1%3A7.0+dfsg-7ubuntu2~ppa2_BUILDING.txt.gz

Build environment shows: gcc-12_12.2.0-2ubuntu1

Excerpt:

[17/17] Generating bios.bin with a custom command
cp -al roms/qemu-palcode b/
/usr/bin/make -C /<<PKGBUILDDIR>>/b/qemu-palcode CROSS=alpha-linux-gnu-
make[3]: Entering directory '/<<PKGBUILDDIR>>/b/qemu-palcode'
alpha-linux-gnu-gcc -Wa,-m21264 -Wa,--noexecstack -DSYSTEM_H='"sys-clipper.h"' -c -o pal.o pal.S
alpha-linux-gnu-gcc -Wa,-m21264 -Wa,--noexecstack -DSYSTEM_H='"sys-clipper.h"' -c -o sys-clipper.o sys-clipper.S
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o init.o init.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o crb.o crb.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o uart.o uart.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o console.o console.c
during RTL pass: expand
console.c: In function ‘do_console’:
console.c:130:12: internal compiler error: in emit_move_insn, at expr.cc:4010
  130 | vga[0] = 'H' + attr;
      | ~~~~~~~^~~~~~~~~~~~
0x137917b internal_error(char const*, ...)
 ???:0
0x5a9326 fancy_abort(char const*, int, char const*)
 ???:0
alpha-linux-gnu-gcc -Wa,-m21264 -Wa,--noexecstack -DSYSTEM_H='"sys-clipper.h"' -c -o console-low.o console-low.S
0xe0a692 alpha_split_const_mov(machine_mode, rtx_def**)
 ???:0
0xe0a801 alpha_expand_mov(machine_mode, rtx_def**)
 ???:0
0x112e2dd gen_movv4hi(rtx_def*, rtx_def*)
 ???:0
0x7eedeb emit_move_insn_1(rtx_def*, rtx_def*)
 ???:0
0x7ef1d7 emit_move_insn(rtx_def*, rtx_def*)
 ???:0
0xe0d016 alpha_expand_movmisalign(machine_mode, rtx_def**)
 ???:0
0x112e5aa gen_movmisalignv4hi(rtx_def*, rtx_def*)
 ???:0
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o ps2port.o ps2port.c
0xa278fc expand_insn(insn_code, unsigned int, expand_operand*)
 ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o pci.o pci.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o vgaio.o vgaio.c
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-...

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

This is reproducible in sbuild and occurs in the cross build for hppa firmware.

Failing command:
$ alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o console.o console.c

But to reproduce this way easier you might run just:
$ git clone https://gitlab.com/qemu-project/qemu-palcode.git
$ apt install gcc-alpha-linux-gnu
$ make CROSS=alpha-linux-gnu-

Was there an upstream gcc bug filed that we could attach this to?

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Mitigation

I tried putting some less load on the register transfer and found that using "-O1" (down from 2) already would work around the issue. This does in no means make the issue go away, but it helps to service qemu until resolved.

Internally this is set statically and can be overwritten from d/rules to use -O1 instead.

--- a/debian/rules
+++ b/debian/rules
@@ -557,7 +557,7 @@ sysdata-components += qboot
 build-palcode-clipper: b/qemu-palcode/palcode-clipper
 b/qemu-palcode/palcode-clipper: | b
        cp -al roms/qemu-palcode b/
- ${MAKE} -C ${CURDIR}/b/qemu-palcode CROSS=${ALPHAEV67_CROSSPFX}
+ ${MAKE} -C ${CURDIR}/b/qemu-palcode CROSS=${ALPHAEV67_CROSSPFX} OPT=-O1
        ${ALPHAEV67_CROSSPFX}strip b/qemu-palcode/palcode-clipper
 install-palcode-clipper: b/qemu-palcode/palcode-clipper
        install -m 0644 $< ${sysdataidir}/palcode-clipper

This is already emulation of alpha code, the performance impact is tolerable to make it overall build again.

This worked locally already, currently building a test in PPA:
https://launchpad.net/~paelzer/+archive/ubuntu/lp-1988710-gcc-crash-qemu/+packages

Revision history for this message
In , Christian Ehrhardt  (paelzer) wrote :

Created attachment 53591
Full interim state generated with -freport-bug

Hi,
this was found as part of Ubuntu's build of qemu for the upcoming 22.10 release.
That already uses gcc 12.2. But gladly it can be reproduced much easier as it breaks in cross-building one of the firmware blobs.

Repro steps in Ubuntu 22.10:
$ git clone https://gitlab.com/qemu-project/qemu-palcode.git
$ cd qemu-palcode/
$ apt install gcc-alpha-linux-gnu
$ make CROSS=alpha-linux-gnu-
...

alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o console.o console.c
during RTL pass: expand
console.c: In function ‘do_console’:
console.c:130:12: internal compiler error: in emit_move_insn, at expr.cc:4010
  130 | vga[0] = 'H' + attr;
      | ~~~~~~~^~~~~~~~~~~~
0x137917b internal_error(char const*, ...)
 ???:0
0x5a9326 fancy_abort(char const*, int, char const*)
 ???:0
0xe0a692 alpha_split_const_mov(machine_mode, rtx_def**)
 ???:0
0xe0a801 alpha_expand_mov(machine_mode, rtx_def**)
 ???:0
0x112e2dd gen_movv4hi(rtx_def*, rtx_def*)
 ???:0
0x7eedeb emit_move_insn_1(rtx_def*, rtx_def*)
 ???:0
0x7ef1d7 emit_move_insn(rtx_def*, rtx_def*)
 ???:0
0xe0d016 alpha_expand_movmisalign(machine_mode, rtx_def**)
 ???:0
0x112e5aa gen_movmisalignv4hi(rtx_def*, rtx_def*)
 ???:0
0xa278fc expand_insn(insn_code, unsigned int, expand_operand*)
 ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
make: *** [<builtin>: console.o] Error 1

Note: Sadly I have no more recent e.g. gcc-snapshot of the cross toolchain to test.

The issue occurred on my laptop on the builders of Ubuntu, so I assume it is pretty generic.

Details about how GCC was built can be fetched from the Ubuntu build logs at https://launchpad.net/ubuntu/+source/gcc-12/12.2.0-2ubuntu1

I have tried to compare older builds using gcc on Jammy. The version 11.3.0-1ubuntu1~22.04 there works fine. So it seems to be a regression between that and 12.2.0-2ubuntu1.

Note: I have found that setting -O1 (instead of the -O2 default) will mitigate the issue.

Revision history for this message
In , Christian Ehrhardt  (paelzer) wrote :

I compared a few more cross-gcc's I could get hold of.
Thereby I can state this was already broken with 12.1.0 on Ubuntu 22.04 and Fedora 36.

Note: I'm only listing where the instructions for these differ

1. Fedora 36
gcc version 12.1.1 20220507 (Red Hat Cross 12.1.1-1) (GCC)

$ dnf install gcc-alpha-linux-gnu make git
...
alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o console.o console.c
during RTL pass: expand
console.c: In function ‘do_console’:
console.c:130:12: internal compiler error: in emit_move_insn, at expr.cc:4010
  130 | vga[0] = 'H' + attr;
      | ~~~~~~~^~~~~~~~~~~~
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <http://bugzilla.redhat.com/bugzilla/> for instructions.
Preprocessed source stored into /tmp/cchVNtxj.out file, please attach this to your bugreport.
make: *** [<builtin>: console.o] Error 1

2. Ubuntu 22.04 gcc-12
gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)

$ apt install gcc-12-alpha-linux-gnu
...
alpha-linux-gnu-gcc-12 -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67 -DSYSTEM_H='"sys-clipper.h"' -c -o console.o console.c
during RTL pass: expand
console.c: In function ‘do_console’:
console.c:130:12: internal compiler error: in emit_move_insn, at expr.cc:4010
  130 | vga[0] = 'H' + attr;
      | ~~~~~~~^~~~~~~~~~~~
0x13767bb internal_error(char const*, ...)
 ???:0
0x5a92b0 fancy_abort(char const*, int, char const*)
 ???:0
0xe09a32 alpha_split_const_mov(machine_mode, rtx_def**)
 ???:0
0xe09ba1 alpha_expand_mov(machine_mode, rtx_def**)
 ???:0
0x112c7fd gen_movv4hi(rtx_def*, rtx_def*)
 ???:0
0x7ee88b emit_move_insn_1(rtx_def*, rtx_def*)
 ???:0
0x7eec77 emit_move_insn(rtx_def*, rtx_def*)
 ???:0
0xe0c3b6 alpha_expand_movmisalign(machine_mode, rtx_def**)
 ???:0
0x112caca gen_movmisalignv4hi(rtx_def*, rtx_def*)
 ???:0
0xa272fc expand_insn(insn_code, unsigned int, expand_operand*)
 ???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
make: *** [<builtin>: console.o] Error 1

Revision history for this message
Paride Legovini (paride) wrote :

Thanks Christian. I couldn't find a relevant upstream GCC bug for this issue.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Since I have not found this issue in qemu, gcc nor palcode I have filed it for some more awareness than just this LP report.

- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106966
- https://github.com/qemu/qemu-palcode/issues/1

FYI I have in the meantime also recreated this in more release/versions:
- Bad: Kinetic - default cross gcc - gcc version 12.2.0 (Ubuntu 12.2.0-2ubuntu1)
- Bad: Jammy - cross gcc-12 - gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
- Bad: Fedora 36 - cross gcc - gcc version 12.1.1 20220507 (Red Hat Cross 12.1.1-1) (GCC)
- Good: Jammy - default cross gcc - gcc version 12.2.0 (Ubuntu 12.2.0-2ubuntu1)

Changed in qemu (Ubuntu):
status: New → In Progress
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

After this is good, next is:

/<<PKGBUILDDIR>>/roms/opensbi/lib/sbi/sbi_tlb.c: Assembler messages:
/<<PKGBUILDDIR>>/roms/opensbi/lib/sbi/sbi_tlb.c:190: Error: unrecognized opcode `fence.i', extension `zifencei' required
make[3]: *** [Makefile:431: /<<PKGBUILDDIR>>/b/opensbi/lib/sbi/sbi_tlb.o] Error 1

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

That is reproducible with the snapshot in qemu, but ok with latest branch from https://gitlab.com/qemu-project/opensbi.git

Fix:
https://gitlab.com/qemu-project/opensbi/-/commit/5d53b55aa77ffeefd4012445dfa6ad3535e1ff2c

MP and PPA updated for that.

Revision history for this message
In , Ubizjak (ubizjak) wrote :

(In reply to Christian Ehrhardt from comment #0)

> alpha-linux-gnu-gcc -O2 -g1 -Wall -fvisibility=hidden -fno-strict-aliasing
> -msmall-text -msmall-data -mno-fp-regs -mbuild-constants -mcpu=ev67

Just drop -mbuild-constants.

(There is a problem in alpha_emit_set_long_const which is not prepared to handle V4HImode target).

Revision history for this message
In , Christian Ehrhardt  (paelzer) wrote :

> Just drop -mbuild-constants.

Thanks for the hint Uroš, but I'm not sure if one can do that, this option is from [1]. I do not have the background on this, but it reads as there was a reason "Use -mbuild-constants to prevent the compiler using static data" to set this which seems more breaking than my current workaround (reduce -O2 to -O1).

[1]: https://github.com/qemu/qemu-palcode/commit/0830e72f0bce29bdf1de0d67ad503a9a8b99c968

tags: added: server-todo
Changed in qemu (Ubuntu):
assignee: nobody → Christian Ehrhardt  (paelzer)
Revision history for this message
In , Ubizjak (ubizjak) wrote :

(In reply to Christian Ehrhardt from comment #3)
> > Just drop -mbuild-constants.
>
> Thanks for the hint Uroš, but I'm not sure if one can do that, this option
> is from [1]. I do not have the background on this, but it reads as there was
> a reason "Use -mbuild-constants to prevent the compiler using static data"
> to set this which seems more breaking than my current workaround (reduce -O2
> to -O1).
>
> [1]:
> https://github.com/qemu/qemu-palcode/commit/
> 0830e72f0bce29bdf1de0d67ad503a9a8b99c968

-mbuild-constants is used here together with -msmall-data (which limits relocations to the small data area to 16 bits). -mbuild-constants option tries harder to construct 64-bit constants using arithmetic with immediates instead of loads from the small data area. So, if the linker does not error out with relocation overflow, it can be safely omitted.

The fix to the compiler is relatively straightforward, but I have no access to alpha system any more to properly test the fix (and I have no patience to run the testsuite on the simulator). The -mbuild-constant option is rarely used, and the proposed workaround should be safe.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qemu - 1:7.0+dfsg-7ubuntu2

---------------
qemu (1:7.0+dfsg-7ubuntu2) kinetic; urgency=medium

  [ Paride Legovini ]
  * d/rules: disable LTO on non-amd64 builds (LP: #1921664)
  * GCC-12 FTBFS (LP: #1988710)
    - d/p/u/lp1988710-silence-openbios-array-bounds-false-positive.patch.
      Silence -Warray-bounds false positive (treated as error)

  [ Christian Ehrhardt ]
  * More on GCC-12 FTBFS (LP 1988710)
    - d/rules: set -O1 for alpha firmware build
    - d/p/u/lp1988710-opensbi-Makefile-fix-build-with-binutils-2.38.patch:
      further FTBFS fixup

 -- Christian Ehrhardt <email address hidden> Mon, 19 Sep 2022 08:07:24 +0200

Changed in qemu (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
In , Christian Ehrhardt  (paelzer) wrote :

Thanks Uroš for the explanation.

I've tried and it does not bail out with a relocation overflow when dropping -mbuild-constants.

I've suggested to upstream to consider that change.
=> https://gitlab.com/qemu-project/qemu-palcode/-/merge_requests/1

Revision history for this message
In , Ubizjak (ubizjak) wrote :

Testcase:

void
do_console (unsigned short *vga)
{
  vga[0] = 'H';
  vga[1] = 'e';
  vga[2] = 'l';
  vga[3] = 'l';
  vga[4] = 'o';
}

cc1 -O2 -mbuild-constants:

during RTL pass: expand
pr106966.c: In function ‘do_console’:
pr106966.c:4:10: internal compiler error: in emit_move_insn, at expr.cc:4052
    4 | vga[0] = 'H';
      | ~~~~~~~^~~~~
0x5ed664 emit_move_insn(rtx_def*, rtx_def*)
        ../../git/gcc/gcc/expr.cc:4052
0x113a708 alpha_emit_set_long_const
        ../../git/gcc/gcc/config/alpha/alpha.cc:2090
0x113abfc alpha_split_const_mov(machine_mode, rtx_def**)
        ../../git/gcc/gcc/config/alpha/alpha.cc:2204
0x113ade7 alpha_expand_mov(machine_mode, rtx_def**)
        ../../git/gcc/gcc/config/alpha/alpha.cc:2250
0x15510a8 gen_movv4hi(rtx_def*, rtx_def*)
        ../../git/gcc/gcc/config/alpha/alpha.md:4463
...

(gdb) bt
#0 internal_error (gmsgid=gmsgid@entry=0x1a9cf85 "in %s, at %s:%d") at ../../git/gcc/gcc/diagnostic.cc:2107
#1 0x00000000007918d6 in fancy_abort (file=file@entry=0x1910cf9 "../../git/gcc/gcc/expr.cc", line=line@entry=4052,
    function=function@entry=0x1a23a78 "emit_move_insn") at ../../git/gcc/gcc/diagnostic.cc:2211
#2 0x00000000005ed665 in emit_move_insn (x=<optimized out>, y=<optimized out>) at ../../git/gcc/gcc/expr.cc:4052
#3 0x000000000113a709 in alpha_emit_set_long_const (target=0x7fffea2ef9f0, c1=7077888) at ../../git/gcc/gcc/config/alpha/alpha.cc:2090
#4 0x000000000113abfd in alpha_split_const_mov (mode=E_V4HImode, operands=0x7fffffffd5a0) at ../../git/gcc/gcc/config/alpha/alpha.cc:2204
#5 0x000000000113ade8 in alpha_expand_mov (mode=E_V4HImode, operands=0x7fffffffd5a0) at ../../git/gcc/gcc/config/alpha/alpha.cc:2250
#6 0x00000000015510a9 in gen_movv4hi (operand0=0x7fffea2ef9f0, operand1=0x7fffea29ebc0) at ../../git/gcc/gcc/config/alpha/alpha.md:4463

(gdb) f 3
#3 0x000000000113a709 in alpha_emit_set_long_const (target=0x7fffea2ef9f0, c1=7077888) at ../../git/gcc/gcc/config/alpha/alpha.cc:2090
2090 emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d3)));
(gdb) p debug_rtx (target)
(reg:V4HI 71)
$1 = void

Changed in gcc:
status: New → Confirmed
tags: removed: foundations-todo
Changed in gcc-12 (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Dominique Pellé (dominique-pelle) wrote :

Can gcc-12 be updated in Ubuntu-22.04?

Currently as of Feb 18 2023, gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0 is packaged in Ubuntu 22.04.

Upstream, gcc-12.2 was released on Aug 2022, so many months ago according to https://gcc.gnu.org/gcc-12/

I'm asking because I'm also observing crashes when building C++ projects with gcc-12.1 from Ubuntu-22.04 and gcc-12.2 fixes several of such bugs according to the list of bug fixes in gcc-12.2 at https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=RESOLVED&resolution=FIXED&target_milestone=12.2

tags: removed: server-todo
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gcc-12 (Ubuntu):
status: New → Confirmed
Revision history for this message
In , Ubizjak (ubizjak) wrote :

*** Bug 110597 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Ubizjak (ubizjak) wrote :

Created attachment 55504
Proposed patch.

Can someone please bootstrap and test the attached patch?

Revision history for this message
In , Matoro-gcc-bugzilla (matoro-gcc-bugzilla) wrote :

(In reply to Uroš Bizjak from comment #8)
> Created attachment 55504 [details]
> Proposed patch.
>
> Can someone please bootstrap and test the attached patch?

I can queue this up to test on real hardware. By bootstrap, do you mean with --enable-bootstrap, and by test do you mean a full testsuite run or just checking that it doesn't ICE on the reproducer here?

Revision history for this message
In , Ubizjak (ubizjak) wrote :

(In reply to matoro from comment #9)
> (In reply to Uroš Bizjak from comment #8)
> > Created attachment 55504 [details]
> > Proposed patch.
> >
> > Can someone please bootstrap and test the attached patch?
>
> I can queue this up to test on real hardware. By bootstrap, do you mean
> with --enable-bootstrap, and by test do you mean a full testsuite run or
> just checking that it doesn't ICE on the reproducer here?

I have already checked that it doesn't ICE with a crosscompiler. Regarding the bootstrap, please note that --enable-bootstrap is the default nowadays, so the option it is not needed to make a full build ("bootstrap"). Also, "make -j N -k check-gcc" should be enough to test the compiler, since other parts of the compiler never exercise -mbuild-constants (N in the command should be substituted with a number of processors to parallelize the testsuite run).

Revision history for this message
In , Matoro-gcc-bugzilla (matoro-gcc-bugzilla) wrote :

(In reply to Uroš Bizjak from comment #10)
> (In reply to matoro from comment #9)
> > (In reply to Uroš Bizjak from comment #8)
> > > Created attachment 55504 [details]
> > > Proposed patch.
> > >
> > > Can someone please bootstrap and test the attached patch?
> >
> > I can queue this up to test on real hardware. By bootstrap, do you mean
> > with --enable-bootstrap, and by test do you mean a full testsuite run or
> > just checking that it doesn't ICE on the reproducer here?
>
> I have already checked that it doesn't ICE with a crosscompiler. Regarding
> the bootstrap, please note that --enable-bootstrap is the default nowadays,
> so the option it is not needed to make a full build ("bootstrap"). Also,
> "make -j N -k check-gcc" should be enough to test the compiler, since other
> parts of the compiler never exercise -mbuild-constants (N in the command
> should be substituted with a number of processors to parallelize the
> testsuite run).

I was just checking because alpha hardware is quite antique, it's single-core so a full compile with bootstrap takes around ~72 hours. I don't know how long the test suite takes because I've never run it on this machine, but I would expect it to add a couple additional days to that. If that's fine I'll kick it off, just want to be clear on what exactly you'd like to see.

Revision history for this message
In , Doko-v (doko-v) wrote :

I'll apply the proposed patch for the next gcc-13 Debian upload, then reporting back test results.

Revision history for this message
In , Doko-v (doko-v) wrote :

search for "test-summary"
https://buildd.debian.org/status/logs.php?pkg=gcc-12&arch=alpha

12.3.0-5 is gcc-12 branch 20230630
12.3.0-6 is gcc-12 branch 20230707 with the proposed patch applied

comparing gcc summary (-5 to -6):

                === gcc Summary ===

# of expected passes 136199
# of unexpected failures 657
# of unexpected successes 16
# of expected failures 1112
# of unresolved testcases 8
# of unsupported tests 2539
/<<PKGBUILDDIR>>/build/gcc/xgcc version 12.3.0 (Debian 12.3.0-5)

                === gcc Summary ===

# of expected passes 136261
# of unexpected failures 652
# of unexpected successes 16
# of expected failures 1112
# of unresolved testcases 8
# of unsupported tests 2539
/<<PKGBUILDDIR>>/build/gcc/xgcc version 12.3.0 (Debian 12.3.0-6)

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The master branch has been updated by Uros Bizjak <email address hidden>:

https://gcc.gnu.org/g:337649c1660211db733c1ba34ae260b8c66a3578

commit r14-2503-g337649c1660211db733c1ba34ae260b8c66a3578
Author: Uros Bizjak <email address hidden>
Date: Thu Jul 13 18:32:15 2023 +0200

    alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]

            PR target/106966

    gcc/ChangeLog:

            * config/alpha/alpha.cc (alpha_emit_set_long_const):
            Always use DImode when constructing long const.

    gcc/testsuite/ChangeLog:

            * gcc.target/alpha/pr106966.c: New test.

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The releases/gcc-13 branch has been updated by Uros Bizjak <email address hidden>:

https://gcc.gnu.org/g:27e421319efcf47280339fbc17c263f36c92eee6

commit r13-7561-g27e421319efcf47280339fbc17c263f36c92eee6
Author: Uros Bizjak <email address hidden>
Date: Thu Jul 13 18:32:15 2023 +0200

    alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]

            PR target/106966

    gcc/ChangeLog:

            * config/alpha/alpha.cc (alpha_emit_set_long_const):
            Always use DImode when constructing long const.

    gcc/testsuite/ChangeLog:

            * gcc.target/alpha/pr106966.c: New test.

    (cherry picked from commit 337649c1660211db733c1ba34ae260b8c66a3578)

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The releases/gcc-12 branch has been updated by Uros Bizjak <email address hidden>:

https://gcc.gnu.org/g:4520e2dbc73262028ad556f732871565101ef615

commit r12-9770-g4520e2dbc73262028ad556f732871565101ef615
Author: Uros Bizjak <email address hidden>
Date: Thu Jul 13 18:32:15 2023 +0200

    alpha: Fix computation mode in alpha_emit_set_long_cost [PR106966]

            PR target/106966

    gcc/ChangeLog:

            * config/alpha/alpha.cc (alpha_emit_set_long_const):
            Always use DImode when constructing long const.

    gcc/testsuite/ChangeLog:

            * gcc.target/alpha/pr106966.c: New test.

    (cherry picked from commit 337649c1660211db733c1ba34ae260b8c66a3578)

Revision history for this message
In , Ubizjak (ubizjak) wrote :

Thanks for helping with tests!

Fixed for gcc-12.4+

Changed in gcc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.