Subject: Re: getting gcc-2.95.2 working
To: Andrew Cagney <ac131313@cygnus.com>
From: Brad Chapman <chapmanb@arches.uga.edu>
List: port-macppc
Date: 07/08/2001 08:58:00
Andrew;
Thanks for getting back with me on this problem. I've been working
with your suggestions over the last couple of days (and trying to get
some sort of understanding of the gcc build tree).

> I don't think your GCC should even be generating .toc sections. 
> From memory, the TOC was part of the PowerOpen (AIX) ABI and was
> omitted from the SVR4 ABI.

Aaah, thanks! That at least gives me some idea of which files to use
in the rs6000 directory (which helps me a lot more than the random
guessing I was doing previously :-).
 
> The attatched (against GCC current) is probably relevant.  It tweeks 
> things to build an SVR4 GCC/PPC (NetBSD/PPC uses the SVR4 ABI).

> *** config.gcc	2001/06/28 19:55:51	1.70
> --- config.gcc	2001/07/05 04:03:36
> *************** powerpc-*-linux*)
> *** 2644,2649 ****
> --- 2644,2655 ----
>   		thread_file='posix'
>   	fi
>   	;;
> + powerpc-*-netbsd*)
> + 	xm_defines=POSIX
> + 	tm_file="${tm_file} svr4.h rs6000/sysv4.h"
> + 	tmake_file="rs6000/t-ppcgas rs6000/t-ppccomm"
> + 	extra_headers=ppc-asm.h
> + 	;;
>   powerpc-wrs-vxworks*)
>           cpu_type=rs6000
>   	xm_defines=POSIX

This patch is a great start. When I applied it against the gcc-2.95.2
in the ports (ie. just added a new patch), it bombs out fairly early
for me with a bunch of undefined symbols in gcc-2.95.2/gcc/cccp.c:

************
  -c `echo /usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/cccp.c | sed 's,^\./,,'`
In file included from tm.h:8,
                 from /usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/rs6000/xm-sysv4.h:41,
                 from config.h:8,
                 from /usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/cccp.c:21:
/usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/svr4.h:218: warning: `ASM_FILE_END' redefined
/usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/rs6000/rs6000.h:2497: warning: this is the location of the previous definition
In file included from tm.h:8,
                 from /usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/rs6000/xm-sysv4.h:41,
                 from config.h:8,
                 from /usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/cccp.c:21:
/usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/svr4.h:380: warning: `ASM_OUTPUT_EXTERNAL_LIBCALL' redefined
/usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/rs6000/rs6000.h:2799: warning: this is the location of the previous definition
/usr/pkgsrc/lang/gcc/work/gcc-2.95.2/gcc/config/svr4.h:490: warning:
`READONLY_DATA_SECTION' redefined
[...]
***************

Using your tips about svr4, I came up with the following configure
which seems to work (fixes the assembler errors I was getting, and
doesn't give any redefined symbols):

*** ../gcc-2.95.2/gcc/configure.orig    Sun Jul  8 08:17:36 2001
--- ../gcc-2.95.2/gcc/configure Sun Jul  8 08:23:38 2001
***************
*** 5068,5073 ****
--- 5068,5081 ----
        powerpc-*-openbsd*)
                tmake_file="${tmake_file} rs6000/t-rs6000 rs6000/t-openbsd"
                ;;
+         powerpc-*-netbsd*)
+                 xm_defines=POSIX
+                 tm_file=rs6000/sysv4.h
+                 xm_file=rs6000/xm-sysv4.h
+                 xmake_file=rs6000/x-sysv4
+                 tmake_file="rs6000/t-ppcgas rs6000/t-ppccomm"
+                 extra_headers=ppc-asm.h
+                 ;;
        powerpc-*-beos*)
                cpu_type=rs6000
                tm_file=rs6000/beos.h


Using this, I can get to the point where you are at. This a huge 
improvement over where I was at previously!

> Using this patch, current GCC can at least configure and build 
> (.../configure ; gmake all-gdb).  It barfs while trying to cross compile 
> some of the libraries vis:
[...]
> /home/scratch/EGCS/gcc/libiberty/strerror.c:466: conflicting types for 
> `sys_errlist'
> /usr/include/errno.h:57: previous declaration of `sys_errlist'
> gmake[1]: *** [strerror.o] Error 1
> gmake[1]: Leaving directory 
> `/home/scratch/EGCS/native/powerpc-apple-netbsd1.5W/libiberty'
> gmake: *** [all-target-libiberty] Error 2

I'm seeing this same error, which you diagnose as:

> The compile barf was caused by a misconfigured multi-lib tree - it had 
> incorrectly guessed that the host didn't have sys_errlist[].
> 
> That in turn was caused by the just compiled GCC not having -D__ELF__ in 
> its list of definitions :-/

This does sound right to me; from the configure during the tests:

[...]
checking for sys_errlist... no
checking for sys_nerr... no
checking for sys_siglist... no
[...]

and looking at the code, the offending problems are inside a 
#ifndef HAVE_SYS_ERRLIST.

But I'm not sure about a fix; I guess we need to add -D__ELF__ to the 
list of definitions, but I have zero clue how to do that.

Any thoughts or suggestions from anyone? 

Thanks again for the help Andrew, I really appreciate it!

Brad