[gnu.gcc.bug] GNU gcc 1.33 patches and X patches to build the Core X R3 with gcc

earle@SUN.COM (Greg Earle) (02/20/89)

	Try these patches to gcc 1.33; they're from RMS (thus blessed) and
they enabled me to build the core X R3 distribution with gcc 1.33 after they
were applied.  I didn't even need to use `-traditional'.  Actually, I should
qualify that; fonts/bdftosnf/fontutil.c uses `inline' as a local variable
name (Non `-traditional' gcc reserves `inline' as a keyword), and that name
needs to be changed; and fonts/bdftosnf/showsnf.c gets a self-induced abort()
somewhere (`gcc got fatal signal 6'); a workaround is to move a variable
declaration outside of a function.  Try the following patches for these 2
files (the patches for gcc are after them, strip them out and put in a
separate patch file):

Note that these patches only help the Core X distribution.  My first foray
into the contrib stuff (adding the PEX extension to the server, and building
the PEX extension demonstration clients) is meeting considerably more 
resistance.  2 files cause gcc to self-abort, a couple have code that gcc
complains about, and a couple of directories have code that tries to be
ANSI-ized (has `#if (__STDC__) && !(__HIGHC__)' and such), but still makes
gcc complain anyway.  It's a tough battle ...

Hope this helps,

	- Greg Earle
	  Sun Los Angeles - JPL on-site software support
	  poseur!earle@Sun.COM

------------------------------------------------------------------------------
Apply the following patch from your top level X directory, using `patch -c -p0':

*** fonts/bdftosnf/fontutil.c.orig	Fri Oct 14 10:33:27 1988
--- fonts/bdftosnf/fontutil.c	Thu Feb  9 04:57:45 1989
***************
*** 399,412 ****
  {
  	int	x, y;
  	int	dx, dy;
! 	unsigned char	*inline, *outline;
  	int	inwidth;
  
  	dx = pCI->metrics.leftSideBearing; 
  	dy = ascent - pCI->metrics.ascent;
  	bzero (newglyph, width * (ascent + descent));
! 	inline = oldglyphs + pCI->byteOffset;
! 	outline = newglyph + dy * width;
  	inwidth = GLWIDTHBYTESPADDED (pCI->metrics.characterWidth, glyphPad);
  	for (y = 0; y < pCI->metrics.ascent + pCI->metrics.descent; y++) {
  		for (x = 0;
--- 399,412 ----
  {
  	int	x, y;
  	int	dx, dy;
! 	unsigned char	*in_line, *out_line;
  	int	inwidth;
  
  	dx = pCI->metrics.leftSideBearing; 
  	dy = ascent - pCI->metrics.ascent;
  	bzero (newglyph, width * (ascent + descent));
! 	in_line = oldglyphs + pCI->byteOffset;
! 	out_line = newglyph + dy * width;
  	inwidth = GLWIDTHBYTESPADDED (pCI->metrics.characterWidth, glyphPad);
  	for (y = 0; y < pCI->metrics.ascent + pCI->metrics.descent; y++) {
  		for (x = 0;
***************
*** 413,423 ****
  		     x < pCI->metrics.rightSideBearing - pCI->metrics.leftSideBearing;
  		     x++)
  		{
! 			if (ISBITON (x, inline))
! 				SETBIT (x + dx, outline);
  		}
! 		inline += inwidth;
! 		outline += width;
  	}
  	pCI->metrics.leftSideBearing = 0;
  	pCI->metrics.rightSideBearing = pCI->metrics.characterWidth;
--- 413,423 ----
  		     x < pCI->metrics.rightSideBearing - pCI->metrics.leftSideBearing;
  		     x++)
  		{
! 			if (ISBITON (x, in_line))
! 				SETBIT (x + dx, out_line);
  		}
! 		in_line += inwidth;
! 		out_line += width;
  	}
  	pCI->metrics.leftSideBearing = 0;
  	pCI->metrics.rightSideBearing = pCI->metrics.characterWidth;
*** fonts/bdftosnf/showsnf.c.orig	Fri Oct 14 10:15:15 1988
--- fonts/bdftosnf/showsnf.c	Thu Feb  9 05:23:06 1989
***************
*** 81,86 ****
--- 81,90 ----
      exit (1);
  }
  
+ #if defined(__GNUC__) || defined(__STDC__)
+ int total;
+ #endif
+ 
  showfont(file, verbose)
  	char	*file;
  	int	verbose;
***************
*** 91,97 ****
--- 95,105 ----
  	FontInfoRec f;
  	int	fd, i, strings;
  	int bytesGlUsed;
+ #if defined(__GNUC__) || defined(__STDC__)
+ 	;
+ #else
  	int total;
+ #endif
  
  	if (stat(file, &st) < 0) {
  		fprintf(stderr, "can't stat %s\n", file);
------------------------------------------------------------------------------
Apply these patches to your gcc 1.33 source directory:

*** expmed.c.orig	Sat Jan 28 16:48:11 1989
--- expmed.c	Mon Feb  6 09:08:57 1989
***************
*** 193,206 ****
  	{
  	  if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
  	    {
- 	      /* Avoid making subreg of a subreg.  */
- 	      if (GET_CODE (value1) == SUBREG)
- 		value1 = copy_to_reg (value1);
  	      /* Optimization: Don't bother really extending VALUE
  		 if it has all the bits we will actually use.  */
! 	      value1 = gen_rtx (SUBREG, SImode, value1, 0);
! 	      if (GET_CODE (SUBREG_REG (value1)) != REG)
  		value1 = copy_to_reg (value1);
  	    }
  	  else if (!CONSTANT_P (value))
  	    /* Parse phase is supposed to make VALUE's data type
--- 193,205 ----
  	{
  	  if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize)
  	    {
  	      /* Optimization: Don't bother really extending VALUE
  		 if it has all the bits we will actually use.  */
! 
! 	      /* Avoid making subreg of a subreg.  */
! 	      if (GET_CODE (value1) != REG)
  		value1 = copy_to_reg (value1);
+ 	      value1 = gen_rtx (SUBREG, SImode, value1, 0);
  	    }
  	  else if (!CONSTANT_P (value))
  	    /* Parse phase is supposed to make VALUE's data type
*** integrate.c.orig	Mon Jan 16 13:05:38 1989
--- integrate.c	Tue Feb  7 12:48:13 1989
***************
*** 613,618 ****
--- 613,620 ----
  	{
  	  int size = int_size_in_bytes (TREE_TYPE (formal));
  	  copy = assign_stack_local (tmode, size);
+ 	  if (!memory_address_p (DECL_MODE (formal), XEXP (copy, 0)))
+ 	    copy = change_address (copy, VOIDmode, copy_rtx (XEXP (copy, 0)));
  	  store_expr (arg, copy, 0);
  	}
        else if (! TREE_READONLY (formal)
*** output-sparc.c.orig	Mon Jan 30 23:50:45 1989
--- output-sparc.c	Sat Feb  4 23:30:12 1989
***************
*** 1429,1434 ****
--- 1429,1435 ----
    int lucky1 = ((unsigned)REGNO (operands[1]) - 8) <= 1;
    int lucky2 = ((unsigned)REGNO (operands[2]) - 8) <= 1;
  
+   CC_STATUS_INIT;	/* this forgotten in virgin 1.33.  */
    if (lucky1)
      if (lucky2)
        output_asm_insn ("call .mul,2\n\tnop", operands);

thewalt@RITZ.CIVE.CMU.EDU (Chris Thewalt) (02/22/89)

In article <8902200730.AA14576@poseur.Sun.COM> earle@SUN.COM (Greg Earle) writes:
>
>	Try these patches to gcc 1.33; they're from RMS (thus blessed) and
>they enabled me to build the core X R3 distribution with gcc 1.33 after they
>were applied.  I didn't even need to use `-traditional'.  ...


I modified gcc 1.33 and X11 with your patches and I still can't compile the
core distribution. I am running a MicroVAX II, Ultrix 2.2, X11R3
with patches 1-7 installed and the PURDUE 2.0 and 2.1 enhancements
The examples in PROBLEMS 1 and 2 below actually occurred in many different
locations.

(this worked with gcc 1.31 and -traditional)

******* PROBLEM 1 *******
I can't compile the libraries without -traditional, for example, the
following macro in lib/X/XBackgnd.c, gets expanded as follows:

    GetReqExtra (ChangeWindowAttributes, 4, req);

------ gcc -E -traditional gives:
    	if ((dpy->bufptr + 12 +  4) > dpy->bufmax)	_XFlush(dpy);	 req = (xChangeWindowAttributesReq *)(dpy->last_req = dpy->bufptr);	 req->reqType =        2        ;	 req->length = (12 +  4)>>2;	dpy->bufptr += 12 +  4;	dpy->request++;

------ gcc -E gives (lots of errors about sz_):
     	if ((dpy->bufptr + sz_* req  +  4) > dpy->bufmax)	_XFlush(dpy);	 req = (xChangeWindowAttributesReq *)(dpy->last_req = dpy->bufptr);	 req->reqType =        2        ;	 req->length = (sz_* req  +  4)>>2;	dpy->bufptr += sz_* req  +  4;	dpy->request++ ;


******** PROBLEM 2 ********
There are problems in handling the asm statements from the PURDUE changes.
For example, in server/ddx/mfb/mfbgetsp.c line 118

	    getandputbits0(psrc, srcBit, w, pdst);

------- gcc -E gives:
	    { register unsigned int _tmpbits; asm ("extzv %1,%2,%3,%0" : "g" ( _tmpbits) : "g" (   srcBit), "g" (   w), "m" (*(char *)(psrc)));  asm ("insv %3,%1,%2,%0" : "m" (*(char *)(    pdst)) : "g" (   0), "g" (    w), "g" (_tmpbits)); };

which results in the errors:

mfbgetsp.c: In function mfbGetSpans:
mfbgetsp.c: output operand constraint lacks `='
mfbgetsp.c: output operand constraint lacks `='

I hope this helps,
			Chris
			thewalt@ce.cmu.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Christopher Robin Thewalt		These opinions are not necessarily
thewalt@ce.cmu.edu			shared by my employer...
Carnegie Mellon University
--