OK, so there are two issues. one is easy and we should commit Rin's binutils fix.. i've tested it also, and it seems entirely valid to me. Rin, please feel free to commit asap, and ask for pullups... or let me know and i'll do it? the GCC one, well, it's interesting. the test case from update #5 in GCC PR#105491 is fixed by porting the changes back into our GCC 10 but it seems that the original issue where gcc's sancov.c fails remains at least for me. (i'm not sure why the GCC PR claims the back port is hard, it is not 100% clean, but it is fairly simple. see below.) the update#5 test case also fails on other targets and is resolved with the back port. so there may be additional work, though it's not clear that the fix upstream fixes the real problem for us here? i'll try using Kalvis's GCC 12 patches in -current, see what happens there.
I've been looking at this some more over the last week and I'm
fairly sure that that the problem is not GCC's PR#105491 - it's
something else. The proximate cause seems to be that when
optimising (-O1 or higher) the cross-compiler has miscompiled a
function call in g++. This in turn prevents that g++ from
properly instantiating the intialiser for a template member. I
believe that this only happens for VAX; I haven't seen anything
like this on the other 2 architectures I've run a native build on
(i386 and macppc).
I have a test case (pt.ii) which demonstrates the problem. The
interesting parts of the assember output (in pt.ii.s), with
annotations, are
/* function call (5 arguments)
cp_finish_decl(l, 0, am->ad.e.ab.d, __null, au);
*/
movl *8(%r6),%r0
subl2 $4,%sp /* space for argument 5 */
movl %sp,%r1
movb 4(%r0),%r0
rotl $21,%r0,(%r1)
bicl2 $-8388609,(%r1) /* argument 5 */
pushl $0 /* argument 4 */
movl am,%r0
movzbl 4(%r0),%r0
movl %sp,%r1
rotl $30,%r0,(%r1)
bicl2 $-2,(%r1)
/* argument 3
but it overwrites argument 4
oops */
pushl $0 /* argument 2 */
pushl %r6 /* argument 1 */
calls $5,_Z14cp_finish_declP9tree_nodeS0_bS0_i
I'm not yet sure what the cause is, but I have noticed that the output from g++'s 'reload' pass isn't correct.
Compile like so (${CC} is the VAX cross-compiler)
cheers
${CC} \
-O2 \
-Wa,--fatal-warnings -Wall -Werror -Wno-error=stack-protector -Wno-format-diag \
-Wno-narrowing
-Wno-sign-compare
-Wno-stack-protector
-Wno-unused
-Wpointer-arith \
-fasynchronous-unwind-tables
-fno-exceptions \
-x c++ \
-o pt.ii.s \
-S pt.ii
kalvis
typedef struct tree_node *a; enum b {}; struct c { b a; struct { struct { unsigned : 1; unsigned : 1; unsigned d : 1; } ab; } e; }; struct f { struct g *h; }; struct tree_node { c ad; f i; }; void ae(); struct j { a k; }; struct g { struct { j ah; } e; }; void pop_nested_class(); void cp_finish_decl(a, a, bool, a, int); a am; void ap(a l) { ae(); int au(l->i.h->e.ah.k->ad.e.ab.d ? 1 << 8 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 : 0); cp_finish_decl(l, 0, am->ad.e.ab.d, __null, au); pop_nested_class(); }
#NO_APP .file "pt.ii" .text .align 1 .globl _Z2apP9tree_node .type _Z2apP9tree_node, @function _Z2apP9tree_node: .LFB0: .cfi_startproc .word 0x40 .cfi_offset 6, 20 .cfi_offset 15, 16 .cfi_offset 13, 12 .cfi_offset 12, 8 .cfi_def_cfa_register 13 subl2 $4,%sp movl 4(%ap),%r6 calls $0,_Z2aev movl *8(%r6),%r0 subl2 $4,%sp movl %sp,%r1 movb 4(%r0),%r0 rotl $21,%r0,(%r1) bicl2 $-8388609,(%r1) pushl $0 movl am,%r0 movzbl 4(%r0),%r0 movl %sp,%r1 rotl $30,%r0,(%r1) bicl2 $-2,(%r1) pushl $0 pushl %r6 calls $5,_Z14cp_finish_declP9tree_nodeS0_bS0_i calls $0,_Z16pop_nested_classv ret .cfi_endproc .LFE0: .size _Z2apP9tree_node, .-_Z2apP9tree_node .globl am .section .bss,"aw",@nobits .align 2 .type am, @object .size am, 4 am: .zero 4 .ident "GCC: (NetBSD nb2 20230710) 10.5.0"