Subject: port-vax/34783: gcc on -current vax is broken
To: None <port-vax-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <oster@cs.usask.ca>
List: netbsd-bugs
Date: 10/11/2006 15:00:00
>Number:         34783
>Category:       port-vax
>Synopsis:       gcc on -current vax is broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-vax-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 11 15:00:00 +0000 2006
>Originator:     oster@cs.usask.ca
>Release:        NetBSD 4.99.3
>Organization:
Sometimes.
>Environment:
System: NetBSD floyd 4.99.3 NetBSD 4.99.3 (GENERIC) #0: Mon Oct  9 12:44:02 CST 2006  oster@count:/u1/builds/build9/src/sys/arch/vax/compile/GENERIC vax
Architecture: vax
Machine: vax
>Description:
	'gcc -O' and 'gcc -O2' (and perhaps others) die with "internal compiler error: Segmentation fault". 

>How-To-Repeat:
	Cross-build a -current distribution for vax via i386.  Install.  Boot.
Attempt to build a native distribution with build.sh.  Watch that die trying
to build nbmake.  Investigate further.  Realize that the following test case 
is sufficient to show the problem:

oster@floyd-4> cat > hello.c
#include <stdio.h>
int main() { printf("Hello, world\n"); }
oster@floyd-5> gcc -o hello hello.c
oster@floyd-6> ./hello
Hello, world
oster@floyd-7> gcc -O -o hello hello.c
hello.c: In function 'main':
hello.c:2: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.NetBSD.org/Misc/send-pr.html> for instructions.
oster@floyd-8> gcc -O2 -o hello hello.c
hello.c: In function 'main':
hello.c:2: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.NetBSD.org/Misc/send-pr.html> for instructions.
oster@floyd-9> gcc -v
Using built-in specs.
Target: vax--netbsdelf
Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --disable-shared --build=i386-unknown-netbsdelf3.99.17 --host=vax--netbsdelf --target=vax--netbsdelf
Thread model: posix
gcc version 4.1.2 20060628 prerelease (NetBSD nb2 20060711)


A potentially relevant part of 'kdump' output of 'gcc -O -o hello hello.c'
is included here:

...
  8749      1 cc1      NAMI  "/usr/include/sys/null.h"
  8749      1 cc1      RET   open 4, 79/0x4f
  8749      1 cc1      CALL  __fstat30(4,0x306b20)
  8749      1 cc1      RET   __fstat30 0, 79/0x4f
  8749      1 cc1      CALL  read(4,0x309000,0x16a)
  8749      1 cc1      GIO   fd 4 read 362 bytes
       "/*      $NetBSD: null.h,v 1.7 2005/12/03 17:10:46 christos Exp $\
                */
        
        #ifndef _SYS_NULL_H_
        #define _SYS_NULL_H_
        #ifndef NULL
        #if !defined(__GNUG__) || __GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MIN\
        OR__ < 90)
        #if !defined(__cplusplus)
        #define NULL    (void *)0
        #else
        #define NULL    0
        #endif /* !__cplusplus */
        #else
        #define NULL    __null
        #endif
        #endif
        #endif /* _SYS_NULL_H_ */
       "
  8749      1 cc1      RET   read 362/0x16a, 3162288/0x3040b0
  8749      1 cc1      CALL  close(4)
  8749      1 cc1      RET   close 0, 362/0x16a
  8749      1 cc1      CALL  break(0x34e000)
  8749      1 cc1      RET   break 0, 12/0xc
  8749      1 cc1      PSIG  SIGSEGV caught handler=0xc7272 mask=(): code=SEGV_MAPERR, addr=0x1, trap=76)
  8749      1 cc1      CALL  __sigaction_sigtramp(SIGSEGV,0x7fffe864,0x7fffe84c,0x2829d0,3)
  8749      1 cc1      RET   __sigaction_sigtramp 0, 2147477580/0x7fffe84c
  8749      1 cc1      CALL  issetugid
  8749      1 cc1      RET   issetugid 0, 2147477504/0x7fffe800
  8749      1 cc1      CALL  issetugid
  8749      1 cc1      RET   issetugid 0, 67/0x43
...

Additional details and/or testing available on request...

>Fix:
	Please.