1The following patches are needed in order to build GNAT with EGCS.
2
3These patches were tested with egcs-980308 and gnat-3.10p on a mips-sgi-irix6.3
4system.  The gnat build succeeded as per the instructions in the gnat
5README.BUILD file for building one library, except that CFLAGS="-O -g" and
6GNATLIBCFLAGS="-O -g" were substituted for the recommended "-O2" so that the
7build could be debugged.  There was no attempt to run the resulting build
8against any testsuite or validation suite.
9
10--
11
12Developers Notes:
13
14Every use of sizetype in the Ada front end should be checked to see if perhaps
15it should be using bitsizetype instead.  The change to maybe_pad_type is just
16a hack to work around this problem, and may not be desirable in the long term.
17
18There are many places in the Ada front end where it calls operand_equal_p to
19see if two type sizes are the same.  operand_equal_p fails if the two
20arguments have different TYPE_MODEs.  sizetype and bitsizetype can have
21different TYPE_MODEs.  Thus this code can fail if one type size is based
22on sizetype, and the other is based on bitsizetype.  The change to
23maybe_pad_type fixes one very critical place where this happens.  There may
24be others.
25
26--
27
28Mon Mar 16 11:00:25 1998  Jim Wilson  <wilson@cygnus.com>
29
30	* a-gtran3.c (maybe_pad_type): Convert both size and orig_size to
31	sizetype if they have differing modes.
32	* a-misc.c (gnat_tree_code_type): Change from string to char array.
33	(init_lex): Delete realloc calls for tree_code_* globals.  Adjust
34	bcopy call for gnat_tree_code_type change.
35	* a-tree.def: Adjust for tree_code_* type changes.
36
37	* a-misc.c (init_lex): Rename to init_parse.
38
39diff -c ada/a-gtran3.c /home/brolley/comp/egcs/tmp/ada/a-gtran3.c
40*** ada/a-gtran3.c	Mon Mar 30 16:29:04 1998
41--- /home/brolley/comp/egcs/tmp/ada/a-gtran3.c	Thu Apr  2 17:16:15 1998
42***************
43*** 3329,3334 ****
44--- 3329,3341 ----
45       isn't changing.  Likewise, clear the alignment if it isn't being
46       changed.  Then return if we aren't doing anything.  */
47  
48+     if (size != 0
49+ 	&& TYPE_MODE (TREE_TYPE (size)) != TYPE_MODE (TREE_TYPE (orig_size)))
50+       {
51+ 	size = convert (sizetype, size);
52+ 	orig_size = convert (sizetype, orig_size);
53+       }
54+  
55    if (size != 0
56        && (operand_equal_p (size, orig_size, 0)
57  	  || (TREE_CODE (orig_size) == INTEGER_CST
58diff -c ada/a-misc.c /home/brolley/comp/egcs/tmp/ada/a-misc.c
59*** ada/a-misc.c	Mon Mar 30 16:29:05 1998
60--- /home/brolley/comp/egcs/tmp/ada/a-misc.c	Thu Apr  2 17:36:19 1998
61***************
62*** 70,77 ****
63  
64  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
65  
66! char *gnat_tree_code_type[] = {
67!   "x",
68  #include "a-tree.def"
69  };
70  #undef DEFTREECODE
71--- 70,77 ----
72  
73  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
74  
75! char gnat_tree_code_type[] = {
76!   'x',
77  #include "a-tree.def"
78  };
79  #undef DEFTREECODE
80***************
81*** 254,259 ****
82--- 254,268 ----
83  print_lang_statistics ()
84  {}
85  
86+ void
87+ lang_print_xnode (file, node, indent)
88+      FILE *file;
89+      tree node;
90+      int indent;
91+ {
92+ }
93+  
94+ 
95  /* integrate_decl_tree calls this function, but since we don't use the
96     DECL_LANG_SPECIFIC field, this is a no-op.  */
97  
98***************
99*** 603,622 ****
100     it, but it's where g++ does it.  */
101  
102  void
103! init_lex ()
104  {
105    lang_expand_expr = gnat_expand_expr;
106  
107-   tree_code_type
108-     = (char **) realloc (tree_code_type,
109- 			 sizeof (char *) * LAST_GNAT_TREE_CODE);
110-   tree_code_length
111-     = (int *) realloc (tree_code_length,
112- 		       sizeof (int) * LAST_GNAT_TREE_CODE);
113-   tree_code_name
114-     = (char **) realloc (tree_code_name,
115- 			 sizeof (char *) * LAST_GNAT_TREE_CODE);
116- 
117    bcopy ((char *) gnat_tree_code_type,
118  	 (char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
119  	 ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
120--- 612,622 ----
121     it, but it's where g++ does it.  */
122  
123  void
124! init_parse (filename)
125!      char *filename;
126  {
127    lang_expand_expr = gnat_expand_expr;
128  
129    bcopy ((char *) gnat_tree_code_type,
130  	 (char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
131  	 ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
132***************
133*** 629,636 ****
134  
135    bcopy ((char *) gnat_tree_code_name,
136  	 (char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
137! 	 ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
138! 	  * sizeof (char *)));
139  }
140  
141  /* Sets some debug flags for the parsed. It does nothing here.  */
142--- 629,640 ----
143  
144    bcopy ((char *) gnat_tree_code_name,
145  	 (char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
146! 	 LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE);
147! }
148! 
149! void
150! finish_parse ()
151! {
152  }
153  
154  /* Sets some debug flags for the parsed. It does nothing here.  */
155diff -c ada/a-tree.def /home/brolley/comp/egcs/tmp/ada/a-tree.def
156*** ada/a-tree.def	Mon Mar 30 16:29:09 1998
157--- /home/brolley/comp/egcs/tmp/ada/a-tree.def	Thu Apr  2 17:20:38 1998
158***************
159*** 31,69 ****
160     The only field used if TREE_COMPLEXITY, which contains the GNAT node
161     number.  */
162  
163! DEFTREECODE (TRANSFORM_EXPR, "transform_expr", "e", 0)
164  
165  /* Perform an unchecked conversion between the input and the output. 
166     if TREE_ADDRESSABLE is set, it means this is in an LHS; in that case,
167     we can only use techniques, such as pointer punning, that leave the
168     expression a "name".  */
169  
170! DEFTREECODE (UNCHECKED_CONVERT_EXPR, "unchecked_convert_expr", "1", 1)
171  
172  /* A type that is an unconstrained array itself.  This node is never passed
173     to GCC. TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE
174     is the type of a record containing the template and data.  */
175  
176! DEFTREECODE (UNCONSTRAINED_ARRAY_TYPE, "unconstrained_array_type", "t", 0)
177  
178  /* A reference to an unconstrained array.  This node only exists as an
179     intermediate node during the translation of a GNAT tree to a GCC tree;
180     it is never passed to GCC.  The only field used is operand 0, which
181     is the fat pointer object.  */
182  
183! DEFTREECODE (UNCONSTRAINED_ARRAY_REF, "unconstrained_array_ref", "r", 1)
184  
185  /* An expression that returns an RTL suitable for its type.  Operand 0
186     is an expression to be evaluated for side effects only.  */
187  
188! DEFTREECODE (NULL_EXPR, "null_expr", "e", 1)
189  
190  /* An expression that emits a USE for its single operand.  */
191  
192! DEFTREECODE (USE_EXPR, "use_expr", "e", 1)
193  
194  /* An expression that is treated as a conversion while generating code, but is
195     used to prevent infinite recursion when conversions of biased types are
196     involved.  */
197  
198! DEFTREECODE (GNAT_NOP_EXPR, "gnat_nop_expr", "1", 1)
199--- 31,69 ----
200     The only field used if TREE_COMPLEXITY, which contains the GNAT node
201     number.  */
202  
203! DEFTREECODE (TRANSFORM_EXPR, "transform_expr", 'e', 0)
204  
205  /* Perform an unchecked conversion between the input and the output. 
206     if TREE_ADDRESSABLE is set, it means this is in an LHS; in that case,
207     we can only use techniques, such as pointer punning, that leave the
208     expression a "name".  */
209  
210! DEFTREECODE (UNCHECKED_CONVERT_EXPR, "unchecked_convert_expr", '1', 1)
211  
212  /* A type that is an unconstrained array itself.  This node is never passed
213     to GCC. TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE
214     is the type of a record containing the template and data.  */
215  
216! DEFTREECODE (UNCONSTRAINED_ARRAY_TYPE, "unconstrained_array_type", 't', 0)
217  
218  /* A reference to an unconstrained array.  This node only exists as an
219     intermediate node during the translation of a GNAT tree to a GCC tree;
220     it is never passed to GCC.  The only field used is operand 0, which
221     is the fat pointer object.  */
222  
223! DEFTREECODE (UNCONSTRAINED_ARRAY_REF, "unconstrained_array_ref", 'r', 1)
224  
225  /* An expression that returns an RTL suitable for its type.  Operand 0
226     is an expression to be evaluated for side effects only.  */
227  
228! DEFTREECODE (NULL_EXPR, "null_expr", 'e', 1)
229  
230  /* An expression that emits a USE for its single operand.  */
231  
232! DEFTREECODE (USE_EXPR, "use_expr", 'e', 1)
233  
234  /* An expression that is treated as a conversion while generating code, but is
235     used to prevent infinite recursion when conversions of biased types are
236     involved.  */
237  
238! DEFTREECODE (GNAT_NOP_EXPR, "gnat_nop_expr", '1', 1)
239
240
241This patch from Fred Fish to GNAT may make building simpler.  We haven't
242tested it.
243
244> I put a very short blurb in the faq.  GNAT is complicated enough that
245> we should probably write a whole page on how to build/install it.
246
247You may want to use some or all of these patches:
248
249	* Make-lang.in (gnattools): Depends upon GCC_PARTS.
250	(ada.start.encap): Depends upon gnattools.
251	(ada.rest.encap): Depends upon gnatlib.
252	* Makefile.in (../stamp-gnatlib1): Since we are still in the rts
253	subdir when the rule runs, we need to touch ../../stamp-gnatlib1.
254	(../stamp-gnatlib1): Don't unconditionally remove the rts directory,
255	create it if one does not exist.
256	(gnatlib): Remove superflous leading blank char at *-*-pe line.
257	* a-init.c: Define NULL if not yet defined.
258
259Index: Make-lang.in
260===================================================================
261RCS file: /cvsroot/gg/egcs/gcc/ada/Make-lang.in,v
262retrieving revision 1.1.1.1
263retrieving revision 1.3
264diff -c -r1.1.1.1 -r1.3
265*** Make-lang.in	1997/10/17 06:19:09	1.1.1.1
266--- Make-lang.in	1998/03/17 14:26:14	1.3
267***************
268*** 100,106 ****
269  
270  # use host-gcc
271  # getopt*.o has to be built before CC=../xgcc
272! gnattools: getopt.o getopt1.o force
273  	$(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)\
274  	   CC="../xgcc -B../" GNATBIND="../gnatbind" \
275  	   gnatf gnatlink gnatkr gnatmake gnatcmd gnatprep \
276--- 100,107 ----
277  
278  # use host-gcc
279  # getopt*.o has to be built before CC=../xgcc
280! # GCC_PARTS has to be built before CC=../xgcc
281! gnattools: getopt.o getopt1.o $(GCC_PARTS) force
282  	$(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)\
283  	   CC="../xgcc -B../" GNATBIND="../gnatbind" \
284  	   gnatf gnatlink gnatkr gnatmake gnatcmd gnatprep \
285***************
286*** 163,170 ****
287  	-if [ -f gnatls$(exeext) ] ; then\
288  	  mv gnatls$(exeext)    gnatls-cross$(exeext); fi
289  
290! ada.start.encap:
291! ada.rest.encap:
292  ada.info:
293  ada.dvi:
294  
295--- 164,171 ----
296  	-if [ -f gnatls$(exeext) ] ; then\
297  	  mv gnatls$(exeext)    gnatls-cross$(exeext); fi
298  
299! ada.start.encap: gnattools
300! ada.rest.encap: gnatlib
301  ada.info:
302  ada.dvi:
303  
304Index: Makefile.in
305===================================================================
306RCS file: /cvsroot/gg/egcs/gcc/ada/Makefile.in,v
307retrieving revision 1.1.1.1
308retrieving revision 1.5
309diff -c -r1.1.1.1 -r1.5
310*** Makefile.in	1997/10/17 06:19:09	1.1.1.1
311--- Makefile.in	1998/02/19 14:16:34	1.5
312***************
313*** 798,806 ****
314     #  3. copy 3xyyy.ad[sb] -->-- i-yyy.ad[sb] 
315  
316  ../stamp-gnatlib1: Makefile ../stamp-gnatlib2
317! 	rm -rf rts
318! 	mkdir rts
319! 	chmod u+w rts
320  	(\
321  	   case $(target) in \
322  		sparc-sun-sunos4*) 	letter=u ;;\
323--- 800,806 ----
324     #  3. copy 3xyyy.ad[sb] -->-- i-yyy.ad[sb] 
325  
326  ../stamp-gnatlib1: Makefile ../stamp-gnatlib2
327! 	if [ -d rts ]; then true; else mkdir rts; chmod u+w rts; fi
328  	(\
329  	   case $(target) in \
330  		sparc-sun-sunos4*) 	letter=u ;;\
331***************
332*** 888,894 ****
333  		   done;; \
334  	   esac ; \
335  	   rm -f ../stamp-gnatlib ;  \
336! 	   touch ../stamp-gnatlib1)
337  
338  gnatlib-common: ../stamp-gnatlib1
339  	(subdir=`cd $(srcdir); pwd`; \
340--- 888,894 ----
341  		   done;; \
342  	   esac ; \
343  	   rm -f ../stamp-gnatlib ;  \
344! 	   touch ../../stamp-gnatlib1)
345  
346  gnatlib-common: ../stamp-gnatlib1
347  	(subdir=`cd $(srcdir); pwd`; \
348***************
349*** 923,929 ****
350  		mips-sni-*	       |\
351  		*-*-cygwin32*          |\
352  		*-*-mingw32*           |\
353!  		*-*-pe                 |\
354                  *)		       \
355                  \
356  		 $(MAKE)  CC="../../xgcc -B../../" \
357--- 923,929 ----
358  		mips-sni-*	       |\
359  		*-*-cygwin32*          |\
360  		*-*-mingw32*           |\
361! 		*-*-pe                 |\
362                  *)		       \
363                  \
364  		 $(MAKE)  CC="../../xgcc -B../../" \
365Index: a-init.c
366===================================================================
367RCS file: /cvsroot/gg/egcs/gcc/ada/a-init.c,v
368retrieving revision 1.1.1.1
369retrieving revision 1.2
370diff -c -r1.1.1.1 -r1.2
371*** a-init.c	1997/10/17 06:19:10	1.1.1.1
372--- a-init.c	1998/01/04 23:11:42	1.2
373***************
374*** 516,521 ****
375--- 516,525 ----
376    __gnat_raise (exception);
377  }
378  
379+ #ifndef NULL
380+ #define NULL 0
381+ #endif
382+ 
383  static void
384  __gnat_install_handler ()
385  {
386
387Wed Jun 24 15:06:09 1998  Dave Brolley  <brolley@cygnus.com>
388
389	* a-misc.c (lang_decode_option): New interface.
390	* a-misc.h (lang_decode_option): New interface.
391
392*** /home/brolley/tmp/a-misc.c	Wed Jun 24 15:01:22 1998
393--- ada/a-misc.c	Wed Jun 24 15:02:42 1998
394*************** init_gnat_args ()
395*** 162,170 ****
396     it returns 0. */
397  
398  int
399! lang_decode_option (p)
400!      char *p;
401  {
402    extern int  save_argc;
403    extern char **save_argv;
404  
405--- 162,172 ----
406     it returns 0. */
407  
408  int
409! lang_decode_option (argc, argv)
410!      int argc;
411!      char **argv;
412  {
413+   char *p = argv[0];
414    extern int  save_argc;
415    extern char **save_argv;
416  
417*** /home/brolley/tmp/a-misc.h	Wed Jun 24 15:01:22 1998
418--- ada/a-misc.h	Wed Jun 24 15:03:20 1998
419*************** enum gnat_tree_code {
420*** 63,69 ****
421     option decoding phase of GCC calls this routine on the flags that it cannot
422     decode. This routine returns 1 if it is successful, otherwise it
423     returns 0. */
424! extern int lang_decode_option	PROTO((char *));
425  
426  /* Perform all the initialization steps that are language-specific.  */
427  extern void lang_init		PROTO((void));
428--- 63,69 ----
429     option decoding phase of GCC calls this routine on the flags that it cannot
430     decode. This routine returns 1 if it is successful, otherwise it
431     returns 0. */
432! extern int lang_decode_option	PROTO((int, char **));
433  
434  /* Perform all the initialization steps that are language-specific.  */
435  extern void lang_init		PROTO((void));
436