Subject: Re: egcs
To: None <skippy@macro.stanford.edu>
From: Kazuki Sakamoto <sakamoto@cec.co.jp>
List: port-powerpc
Date: 08/05/1998 20:19:48
In <Pine.A32.3.96.980804143751.26556F-100000@macro.stanford.edu>,
skippy@macro.stanford.edu wrote:

 > Did something break in egcs-1.0.3? I got egcs-1.0.3a today, and have tried
 > a few powerpc targets. They don't seem to work..
[...]
 > powerpc-netbsd, ppc-netbsd, and powerpc-elf-netbsd are all not ok too..
 > 
 > I looked through the configure files, and I don't see what I need to set.
 > :-(

I think that the following patch is necessary to use egcs-1.0.3a
for powerpc-netbsd.

Well, I made package for NetBSD/powerpc cross compile env.
ftp://www.cec.co.jp/usr/sakamoto/NetBSD/experiment/crossppc-1.1.tgz

requirement:
	binutils-2.9.1.tar.gz
	egcs-1.0.3a.tar.gz
	NetBSD source

usage:
	make OPTION install

	OPTION:
		TARGET_MACHINE=ofppc
			ofppc or macppc or bebox.
		ALLSRC=/usr/src
			path of NetBSD source tree
		TARGET_ROOT=/usr/tmp/root
			DESTDIR

	e.g.
		# make PREFIX=/opt/PPC TARGET_MACHINE=macppc \
		     ALLSRC=/usr/src.current \
		     TARGET_ROOT=/opt/PPC/root install

You can use "PREFIX/bin/ppc-make" script like "make" after the installation.

Kazuki Sakamoto
sakamoto@cec.co.jp

-----cut here-----
*** gcc/Makefile.in.orig	Fri Feb 20 04:14:38 1998
--- gcc/Makefile.in	Wed Jun 17 12:43:50 1998
***************
*** 1913,1922 ****
  # Files related to the fixproto script.
  
  deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
! 	CC="$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -I. -I$(srcdir) -Iinclude -I${SYSTEM_HEADER_DIR}"; \
  	  export CC; \
! 	  $(SHELL) $(srcdir)/scan-types.sh "$(srcdir)" >tmp-deduced.h
! 	mv tmp-deduced.h deduced.h
  
  gen-protos: gen-protos.o scan.o cppalloc.o $(HOST_LIBDEPS)
  	${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
--- 1913,1927 ----
  # Files related to the fixproto script.
  
  deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
! 	if [ -d $(SYSTEM_HEADER_DIR) ]; \
! 	then \
! 	  CC="$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -I. -I$(srcdir) -Iinclude -I${SYSTEM_HEADER_DIR}"; \
  	  export CC; \
! 	  $(SHELL) $(srcdir)/scan-types.sh "$(srcdir)" >tmp-deduced.h; \
! 	  mv tmp-deduced.h deduced.h; \
! 	else \
! 	  touch deduced.h; \
! 	fi
  
  gen-protos: gen-protos.o scan.o cppalloc.o $(HOST_LIBDEPS)
  	${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
*** gcc/configure.orig	Tue Feb 24 15:59:37 1998
--- gcc/configure	Tue Feb 24 15:28:15 1998
***************
*** 3988,3993 ****
--- 3988,4000 ----
  		fi
  		xmake_file=rs6000/x-sysv4
  		;;
+ 	powerpc-*-netbsd*)
+ 		tm_file=rs6000/netbsd.h
+ 		xm_file=rs6000/xm-netbsd.h
+ 		fixincludes=Makefile.in
+ 		tmake_file=t-libc-ok
+ 		xmake_file=x-netbsd
+ 		;;
  	powerpc-*-eabiaix*)
  		tm_file=rs6000/eabiaix.h
  		tmake_file="rs6000/t-ppcgas rs6000/t-ppccomm"
*** /dev/null	Tue Feb 24 15:49:12 1998
--- gcc/config/rs6000/netbsd.h	Tue Feb 24 15:28:34 1998
***************
*** 0 ****
--- 1,77 ----
+ #include <rs6000/sysv4.h>
+ 
+ /* Get generic NetBSD definitions.  */
+ 
+ #include <netbsd.h>
+ 
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fprintf (stderr, " (PowerPC NetBSD)");
+ 
+ /* Use bcopy etc. instead of memcpy etc. */
+ #undef	TARGET_MEM_FUNCTIONS
+ 
+ /* Names to predefine in the preprocessor for this target machine.  */
+ #undef	CPP_PREDEFINES
+ #define CPP_PREDEFINES "-D__powerpc__ -D__PPC__ -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(powerpc) -Amachine(powerpc)"
+ 
+ /* Make gcc agree with <machine/ansi.h> */
+ 
+ #undef SIZE_TYPE
+ #define SIZE_TYPE "unsigned int"
+ 
+ #undef PTRDIFF_TYPE
+ #define PTRDIFF_TYPE "int"
+ 
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "int"
+ 
+ #undef WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 32
+ 
+ /* Don't default to pcc-struct-return, because gcc is the only compiler, and
+    we want to retain compatibility with older gcc versions.  */
+ #define DEFAULT_PCC_STRUCT_RETURN 0
+ 
+ /* Until gcc uses fixed functions on procedure entry, -mmultiple is probably
+    more efficient due to smaller code and less cache thrashing.  */
+ #undef	CC1_SPEC
+ #define	CC1_SPEC	"-mmultiple"
+ 
+ /* We want a implemetation reserved symbol for the entry point! */
+ #undef	LINK_SPEC
+ #define	LINK_SPEC	"%{!nostdlib:%{!r*:%{!e*:-e _start}}} -dc -dp %{static:-Bstatic} %{assert*}"
+ 
+ /* Provide a STARTFILE_SPEC appropriate for NetBSD.  Here we add
+    the crtbegin.o file (see crtstuff.c) which provides part of the
+    support for getting C++ file-scope static object constructed
+    before entering `main'. */
+    
+ #undef	STARTFILE_SPEC
+ #define STARTFILE_SPEC \
+  "%{!shared: \
+      %{pg:gcrt0.o%s} \
+      %{!pg: \
+ 	%{p:gcrt0.o%s} \
+ 	%{!p:crt0.o%s}}} \
+    %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+ 
+ /* Provide a ENDFILE_SPEC appropriate for NetBSD.  Here we tack on
+    the file which provides part of the support for getting C++
+    file-scope static object deconstructed after exiting `main' */
+ 
+ #undef	ENDFILE_SPEC
+ #define ENDFILE_SPEC \
+   "%{!shared:crtend.o%s} %{shared:crtendS.o%s}"
+ 
+ #undef	FUNCTION_PROFILER
+ #define FUNCTION_PROFILER(FILE, LABELNO) \
+ {									\
+ 	fprintf (FILE, "\tmflr %s\n", reg_names[0]);			\
+ 	fprintf (FILE, "\tstw %s,4(%s)\n", reg_names[0], reg_names[1]);	\
+ /* XXX PIC?? */								\
+ 	fprintf (FILE, "\tbl _mcount\n");				\
+ 	fprintf (FILE, "\tlwz %s,4(%s)\n", reg_names[0], reg_names[1]);	\
+ 	fprintf (FILE, "\tmtlr %s\n", reg_names[0]);			\
+ }
+ 
+ #undef ASM_FINAL_SPEC
*** /dev/null	Tue Feb 24 15:49:12 1998
--- gcc/config/rs6000/xm-netbsd.h	Tue Feb 24 15:28:34 1998
***************
*** 0 ****
--- 1,9 ----
+ /* Configuration for GCC for PowerPC running NetBSD as host.  */
+ 
+ #include <rs6000/xm-rs6000.h>
+ 
+ /* NetBSD isn't SysV */
+ #undef	USG
+ 
+ /* Not needed on NetBSD (really?) */
+ #undef	COLLECT_EXPORT_LIST