Port-sh3 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: HEADS UP: plan to switch many ports over to GCC 12 soon



Hi uwe@, thanks for hints!!

On 2024/07/01 14:38, Valery Ushakov wrote:
[trimmed the cc list down]

On Mon, Jul 01, 2024 at 09:59:54 +0900, Rin Okuyama wrote:

With in-tree GCC 12.4, kernel crashes just same as 12.3 :(

Even a single character is output to console. I tried to
drop some features from kernel config to reduce size
significantly, but it does not help. On the other hand,
same kernel works just fine if compiled by GCC 10.5.

Are binutils the same?  I'd first rule out section alignment/layout
issues (cf. netwinder changes to make netbsd-10 work again).

Yes, 2.39 for both. No significant difference for `readelf -a netbsd`.

I'd compile the kernel with gcc 10, then remove (stow away, really)
half the object files and compile with gcc 12.  If the result works,
repeat with the half of the remaining half.  If it doesn't - restore
the gcc10 objects and bisect them.  I had to this couple of times on
previous gcc uprqades.

I tried this way, then bisectioning did not work at all! I needed to
restore almost all files to ones compiled by GCC10.

I've found that GCC12 even miscompiles this one for -O1 and higher!

----
short
func(int i)
{

        switch (i) {
        case 0:
                return 0xdead;
        case 1:
                return 0xbeaf;
        default:
                return 1;
        }
}
----
00000000 <func>:
   0:   04 8b           bf      c <func+0xc>
   2:   43 60           mov     r4,r0
   4:   01 88           cmp/eq  #1,r0
   6:   04 89           bt      12 <func+0x12>
   8:   0b 00           rts
   a:   01 e0           mov     #1,r0
   c:   04 90           mov.w   18 <func+0x18>,r0       ! dead
   e:   0b 00           rts
  10:   09 00           nop
  12:   02 90           mov.w   1a <func+0x1a>,r0       ! beaf
  14:   0b 00           rts
  16:   09 00           nop
  18:   ad de           mov.l   2d0 <func+0x2d0>,r14
  1a:   af be           bsr     fffffd7c <func+0xfffffd7c>
----

Apparently, `tst r4,r4` is optimized out by mistake :(

This seems to be hacked around by this patch:

----
--- a/external/gpl3/gcc/dist/gcc/config/sh/sh_treg_combine.cc
+++ b/external/gpl3/gcc/dist/gcc/config/sh/sh_treg_combine.cc
@@ -1528,7 +1528,11 @@ sh_treg_combine::try_optimize_cbranch (rtx_insn *insn)
 bool
 sh_treg_combine::gate (function *)
 {
+#if 0
   return optimize > 0;
+#else
+  return false;
+#endif
 }

 unsigned int
----

With this hack, system boots into multiuser with DIAGNOSTIC, and now
it is running full ATF overnight without panic until now.

What I still haven't understood is why this causes the critical
problem for us with GCC 12.4. There are no significant changes b/w
10.5 and 12.4 (and 14.1) for gcc/config/sh. Also, it seems to
work for other Dreamcast community.

(There are one commit b/w 10.5 and 12.4 for sh_treg_combine.cc,
but reverting it does not change the situation.)

Anyway, I will commit the hack and report to upstream, if there's
no regression for ATF.

Sorry, I sitll haven't moved back most of my small machines from my
self-isolation lair, so my landisk is currently not here to test.

Never mind! Looking forward to your comeback to sh3 world :)

Thanks,
rin

-uwe



Home | Main Index | Thread Index | Old Index