Subject: Patches to gcc-2.5.8 for NetBSD-current ...
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Andrew Cagney <cagney@highland.oz.au>
List: current-users
Date: 06/04/1994 21:43:55
Hi,

Below are minor patches that are needed to get GCC-2.5.8 to
compile on NetBSD-current.  (They have also been posted to
gnu.gcc.bug).

I note the patch to config/i386/xm-i386.h that defines bsd4_4 when GCC
is being compiled on a NetBSD-current machine.  NetBSD-current
encounters the same compilation problems as BSD4.4 (as it is now
close to a BSD 4.4 OS).  Any suggestions of a better way of
doing this (including where to put the patch) would be welcome.


			Andrew


*** /dev/null	Sat Jun  4 18:10:28 1994
--- README.NetBSD	Sat Jun  4 20:30:09 1994
***************
*** 0 ****
--- 1,51 ----
+ Some Brief notes on NetBSD (i386)
+ 
+ 
+ o	Some versions of NetBSD had a bug in /bin/sh (ASH)
+ 
+ 	You can test for the bug using:
+ 		/bin/sh -c 'false ; C= ; echo $?'
+ 	It should out put `0' not `1'.  The patch below (to Makefile.in
+ 	will get around the problem).  It would be better to get a
+ 	more up-to-date /bin/sh
+ 
+ 	*** 1.1	1994/06/03 20:40:14
+ 	--- Makefile.in	1994/06/03 20:41:23
+ 	***************
+ 	*** 1619,1630 ****
+ 	  stmp-fixproto: fixhdr.ready fixproto stmp-headers
+ 	  	@echo "Various warnings and error messages from fixproto are normal"
+ 	  	-if [ -d include ] ; then true; else mkdir include; fi
+ 	! 	if [ -f include/fixed ] ; then true; \
+ 	  	else \
+ 	  	  CPP="$(GCC_FOR_TARGET) -E"; export CPP; \
+ 	  	    ${srcdir}/fixproto include include $(SYSTEM_HEADER_DIR); \
+ 	  	  touch include/fixed; \
+ 	! 	fi
+ 	  	touch stmp-fixproto
+ 	  
+ 	  # Remake the info files.
+ 	--- 1619,1630 ----
+ 	  stmp-fixproto: fixhdr.ready fixproto stmp-headers
+ 	  	@echo "Various warnings and error messages from fixproto are normal"
+ 	  	-if [ -d include ] ; then true; else mkdir include; fi
+ 	! 	/bin/sh -c 'if [ -f include/fixed ] ; then true; \
+ 	  	else \
+ 	  	  CPP="$(GCC_FOR_TARGET) -E"; export CPP; \
+ 	  	    ${srcdir}/fixproto include include $(SYSTEM_HEADER_DIR); \
+ 	  	  touch include/fixed; \
+ 	! 	fi'
+ 	  	touch stmp-fixproto
+ 	  
+ 	  # Remake the info files.
+ 
+ 
+ 
+ o	The file:
+ 		config/i386/netbsd.h
+ 	has been set up so that the CPP_PREDEFINES are consistent with
+ 	the version GCC is being compiled on.  NetBSD-0.9 and NetBSD-current
+ 	define different symbols in CPP
+ 
+ 
+ 
*** 1.1	1994/06/02 00:16:07
--- configure	1994/06/02 01:15:09
***************
*** 392,397 ****
--- 392,404 ----
  # Next line turned off because both 386BSD and BSD/386 use GNU ld.
  #		use_collect2=yes
  		;;
+ 	i[34]86-*-netbsd*)
+ 		cpu_type=i386
+ 		tm_file=i386/netbsd.h
+ #		tmake_file=t-libc-ok
+ # Next line turned off because both 386BSD and BSD/386 use GNU ld.
+ #		use_collect2=yes
+ 		;;
  	i[34]86-*-mach*)
  		cpu_type=i386
  		tm_file=i386/mach.h
*** 1.1	1994/06/03 17:16:16
--- gstdarg.h	1994/06/03 17:17:52
***************
*** 136,148 ****
     But on BSD NET2 we must not test or define or undef it.
     (Note that the comments in NET 2's ansi.h
     are incorrect for _VA_LIST_--see stdio.h!)  */
! #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__)
  /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  #ifndef _VA_LIST
  /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
  #ifndef _VA_LIST_T_H
  #define _VA_LIST_T_H
! #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__))
  #define _VA_LIST_
  #endif
  #define _VA_LIST
--- 136,148 ----
     But on BSD NET2 we must not test or define or undef it.
     (Note that the comments in NET 2's ansi.h
     are incorrect for _VA_LIST_--see stdio.h!)  */
! #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__NetBSD__)
  /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  #ifndef _VA_LIST
  /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
  #ifndef _VA_LIST_T_H
  #define _VA_LIST_T_H
! #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__NetBSD__))
  #define _VA_LIST_
  #endif
  #define _VA_LIST
*** 1.1	1994/06/02 22:36:47
--- gstddef.h	1994/06/03 17:38:31
***************
*** 22,30 ****
  
  /* On 4.3bsd-net2, make sure ansi.h is included, so we have
     one less case to deal with in the following.  */
! #if defined (__BSD_NET2__) || defined (____386BSD____)
  #include <machine/ansi.h>
  #endif
  
  /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
      defined if the corresponding type is *not* defined.  */
--- 22,34 ----
  
  /* On 4.3bsd-net2, make sure ansi.h is included, so we have
     one less case to deal with in the following.  */
! #if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__NetBSD__)
  #include <machine/ansi.h>
+ #ifndef _ANSI_H_
+ #define _ANSI_H_ /* for NetBSD-current */
  #endif
+ #endif
+ 
  
  /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
      defined if the corresponding type is *not* defined.  */
*** 1.1	1994/06/02 23:22:30
--- gvarargs.h	1994/06/02 23:23:38
***************
*** 150,162 ****
  /* Michael Eriksson <mer@sics.se> at Thu Sep 30 11:00:57 1993:
     Sequent defines _VA_LIST_ in <machine/machtypes.h> to be the type to
     use for va_list (``typedef _VA_LIST_ va_list'') */
! #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__)
  /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  #ifndef _VA_LIST
  /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
  #ifndef _VA_LIST_T_H
  #define _VA_LIST_T_H
! #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__))
  #define _VA_LIST_
  #endif
  #define _VA_LIST
--- 150,162 ----
  /* Michael Eriksson <mer@sics.se> at Thu Sep 30 11:00:57 1993:
     Sequent defines _VA_LIST_ in <machine/machtypes.h> to be the type to
     use for va_list (``typedef _VA_LIST_ va_list'') */
! #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__NetBSD__)
  /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  #ifndef _VA_LIST
  /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
  #ifndef _VA_LIST_T_H
  #define _VA_LIST_T_H
! #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__NetBSD__))
  #define _VA_LIST_
  #endif
  #define _VA_LIST
*** 1.1	1994/06/05 00:15:05
--- config/i386/xm-i386.h	1994/06/05 00:16:10
***************
*** 36,41 ****
--- 36,46 ----
  #define SUCCESS_EXIT_CODE 0
  #define FATAL_EXIT_CODE 33
  
+ /* NetBSD-current is near enough to BSD-4.4 when compiling */
+ #if defined (__NetBSD__) && !defined (__386BSD__)
+ #define bsd4_4 1
+ #endif
+ 
  /* target machine dependencies.
     tm.h is a symbolic link to the actual target specific file.   */
  
*** /dev/null	Sat Jun  4 18:10:28 1994
--- config/i386/netbsd.h	Sat Jun  4 17:18:55 1994
***************
*** 0 ****
--- 1,186 ----
+ /* Configuration for an i386 running NetBSD as the target machine. 
+ 
+ 	$Id: tm.h,v 1.5 1993/12/06 09:49:15 cgd Exp $
+ */
+ 
+ 
+ /* This is tested by i386gas.h.  */
+ #define YES_UNDERSCORES
+ 
+ #include "i386/gstabs.h"
+ 
+ /* Get perform_* macros to build libgcc.a.  */
+ #include "i386/perform.h"
+ 
+ 
+ /* NOTE: Two cases considered
+  *          o Compiling on 0.9
+  *          o Compiling on current
+  *       Compiling on 0.9 for current wasn't considered
+  */
+ #undef CPP_PREDEFINES
+ #if defined (unix) && defined (i386) && defined (__BSD_NET2__) && defined (__NetBSD__) && defined (__386BSD__)
+ #define CPP_PREDEFINES "-Dunix -Di386 -D__BSD_NET2__ -D__NetBSD__ -D__386BSD__"
+ #else
+ #define CPP_PREDEFINES "-Di386 -D__NetBSD__ -Dunix"
+ #endif
+ 
+ /* Like the default, except no -lg.  */
+ #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+ 
+ #undef SIZE_TYPE
+ #define SIZE_TYPE "unsigned int"
+ 
+ #undef PTRDIFF_TYPE
+ #define PTRDIFF_TYPE "int"
+ 
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "short unsigned int"
+ 
+ #define WCHAR_UNSIGNED 1
+ 
+ #undef WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 16
+ 
+ /* NetBSD does have atexit.  */
+ 
+ #define HAVE_ATEXIT
+ 
+ /* Redefine this to use %eax instead of %edx.  */
+ #undef FUNCTION_PROFILER
+ #define FUNCTION_PROFILER(FILE, LABELNO)  \
+ {									\
+   if (flag_pic)								\
+     {									\
+       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n",		\
+ 	       LPREFIX, (LABELNO));					\
+       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");			\
+     }									\
+   else									\
+     {									\
+       fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO));	\
+       fprintf (FILE, "\tcall mcount\n");				\
+     }									\
+ }
+ 
+ /* There are conflicting reports about whether this system uses
+    a different assembler syntax.  wilson@cygnus.com says # is right.  */
+ #undef COMMENT_BEGIN
+ #define COMMENT_BEGIN "#"
+ 
+ #undef ASM_APP_ON
+ #define ASM_APP_ON "#APP\n"
+ 
+ #undef ASM_APP_OFF
+ #define ASM_APP_OFF "#NO_APP\n"
+ 
+ /* The following macros are stolen from i386v4.h */
+ /* These have to be defined to get PIC code correct */
+ 
+ /* This is how to output an element of a case-vector that is relative.
+    This is only used for PIC code.  See comments by the `casesi' insn in
+    i386.md for an explanation of the expression this outputs. */
+ 
+ #undef ASM_OUTPUT_ADDR_DIFF_ELT
+ #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
+   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
+ 
+ /* Indicate that jump tables go in the text section.  This is
+    necessary when compiling PIC code.  */
+ 
+ #define JUMP_TABLES_IN_TEXT_SECTION
+ 
+ /* 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
+ 
+ /*
+  * Some imports from svr4.h in support of shared libraries.
+  * Currently, we need the DECLARE_OBJECT_SIZE stuff.
+  */
+ 
+ /* Define the strings used for the special svr4 .type and .size directives.
+    These strings generally do not vary from one system running svr4 to
+    another, but if a given system (e.g. m88k running svr) needs to use
+    different pseudo-op names for these, they may be overridden in the
+    file which includes this one.  */
+ 
+ #define TYPE_ASM_OP	".type"
+ #define SIZE_ASM_OP	".size"
+ #define WEAK_ASM_OP	".weak"
+ 
+ /* The following macro defines the format used to output the second
+    operand of the .type assembler directive.  Different svr4 assemblers
+    expect various different forms for this operand.  The one given here
+    is just a default.  You may need to override it in your machine-
+    specific tm.h file (depending upon the particulars of your assembler).  */
+ 
+ #define TYPE_OPERAND_FMT	"@%s"
+ 
+ /* Write the extra assembler code needed to declare a function's result.
+    Most svr4 assemblers don't require any special declaration of the
+    result value, but there are exceptions.  */
+ 
+ #ifndef ASM_DECLARE_RESULT
+ #define ASM_DECLARE_RESULT(FILE, RESULT)
+ #endif
+ 
+ /* These macros generate the special .type and .size directives which
+    are used to set the corresponding fields of the linker symbol table
+    entries in an ELF object file under SVR4.  These macros also output
+    the starting labels for the relevant functions/objects.  */
+ 
+ /* Write the extra assembler code needed to declare a function properly.
+    Some svr4 assemblers need to also have something extra said about the
+    function's return value.  We allow for that here.  */
+ 
+ #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
+   do {									\
+     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
+     assemble_name (FILE, NAME);						\
+     putc (',', FILE);							\
+     fprintf (FILE, TYPE_OPERAND_FMT, "function");			\
+     putc ('\n', FILE);							\
+     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));			\
+     ASM_OUTPUT_LABEL(FILE, NAME);					\
+   } while (0)
+ 
+ /* Write the extra assembler code needed to declare an object properly.  */
+ 
+ #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
+   do {									\
+     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
+     assemble_name (FILE, NAME);						\
+     putc (',', FILE);							\
+     fprintf (FILE, TYPE_OPERAND_FMT, "object");				\
+     putc ('\n', FILE);							\
+     if (!flag_inhibit_size_directive)					\
+       {									\
+ 	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
+ 	assemble_name (FILE, NAME);					\
+ 	fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (decl)));	\
+       }									\
+     ASM_OUTPUT_LABEL(FILE, NAME);					\
+   } while (0)
+ 
+ /* This is how to declare the size of a function.  */
+ 
+ #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
+   do {									\
+     if (!flag_inhibit_size_directive)					\
+       {									\
+         char label[256];						\
+ 	static int labelno;						\
+ 	labelno++;							\
+ 	ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);		\
+ 	ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);		\
+ 	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
+ 	assemble_name (FILE, (FNAME));					\
+         fprintf (FILE, ",");						\
+ 	assemble_name (FILE, label);					\
+         fprintf (FILE, "-");						\
+ 	assemble_name (FILE, (FNAME));					\
+ 	putc ('\n', FILE);						\
+       }									\
+   } while (0)
+ 

------------------------------------------------------------------------------