From: @relay.mod.uk (David Bilsby, LISZT: :bilsby%hermes.mod.uk)
Subject: (none)
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 12 Nov 1992 11:21:00 GMT

Dear gcc-bug people,

	I am having problem with version 2.3.1 of gcc when I try to compile position independent code. I recently obtained a copy of gcc 2.3.1 for the SUN SPARCstation IPX platform running SunOS 4.1.3, I'm working on because it did not exist and the cc compiler is terrible. After careful reading of the installation instructions I proceeded to compile it. The configureation options I used were :-

	configure --target=sparc-sun-sunos4.1 --prefix=/usr2/local

	After an hour or more of compilation and recompilation it had installed gcc without any error being produced. I produced a stage 3 compiler to check against the stage 2 compiler with :-

	make compare

and this found no differences.
	As I planned to use gcc mostly in ANSI mode I also ran the header file fixing script :-

	make install-fixincludes

This produced a fair number of include files in the /usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include directory.
	After setting the appropriate path /usr2/local/bin in my system path variable I proceeded to use the compiler and found it worked OK on several progr
ams. I then had cause to use it to compile a program (which is included at the end in gcc -E format) that would be a dynamically linked function. The program just consists of one function (no main).

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
===============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#ifndef lint
static char rcsid[] = "$Id: example.c,v 1.2 1992/04/22 20:05:14 jeffry Exp $";

#endif

/***********************************************************************
     * * *   ALL RIGHTS RESERVED   * * *

    Copyright 1992 Precision Visuals, Inc.

This media contains information which is proprietary to and a trade
secret of Precision Visuals, Inc. and its licensors.  It is not to be
disclosed to anyone outside of this organization.

    * * *   Restricted Rights Legend * * *

Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph (c) (1) (ii) of the Rights
in Technical Data and Computer Software clause at 252.227-7013.

Contractor: Precision Visuals, Inc. 6230 Lookout Rd., Boulder, CO 80301

***********************************************************************/



#include <stdio.h>

typedef struct complex {
   float r, i;
}  complex;


long WaveParams (argc, argp)
int argc;
char *argp[];
{
   char *b;
   short *s;
   long *l;
   float *f;
   double *d;
   complex *c;
   char **str;

   if (argc != 7) {
      fprintf (stderr, "wrong # of parameters\n");
      return (0);
   }

   b = ((char **) argp)[0];
   s = ((short **) argp)[1];
   l = ((long **) argp)[2];
   f = ((float **) argp)[3];
   d = ((double **) argp)[4];
   c = ((complex **) argp)[5];
   str = ((char ***) argp)[6];

   fprintf (stderr, "%d %d %ld %g %g <%g,%gi> '%s'\n",
     (int) b[0], (int) s[0], (long) l[0], f[0], d[0], c[0].r, c[0].i, str[0]);

   return (12345);
}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
===============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

	The program is for use with Precision Visuals PV-WAVE graphics package and the function WaveParams is called from PV-WAVE. The sources with PV-WAVE also provided several build files for this example, the Sun one is below :-

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
===============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

{filename build.sun4}

#!/bin/csh
#$Id: build.sun4,v 1.1 1992/03/05 11:49:52 javid Exp $
cc -c -pic example.c
ld -o example.so -assert pure-text example.o
unalias rm
rm -f example.o

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
===============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

	After checking the gcc manual for a 'pic' equivalent I found -fpic or -fPIC. I simply then hand compiled the program as:-

	gcc -c -fpic example.c

expecting it to work fine. Instead the following error message was generated :-

muffin% gcc -c -fpic example.c
gcc: Internal compiler error: program cc1 got fatal signal 6
muffin% 

I repeated the proceedure with -fPIC but the same error was generated.

	I have subsequently recompiled gcc from the begining and the new copy of gcc still produced this error. I have scanned through all the gcc info files for any anomilies about a SPARC and position independent code but could find no more than the comment abount the maximum offset of table of 8K for a SPARC chip.

	Can you help? I have tried to include as much information as possible in order to make your life easier.

Thanks for you time.

David. ("liszt::bilsby"@uk.mod.hermes)

The preprocessor output follows:-


| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

# 1 "example.c"

static char rcsid[] = "$Id: example.c,v 1.2 1992/04/22 20:05:14 jeffry Exp $";



 




















# 1 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdio.h" 1 3

# 1 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdarg.h" 1 3
 






























# 1 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/va-sparc.h" 1 3
 


 





 

typedef char * __gnuc_va_list;







 

# 79 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/va-sparc.h" 3


# 32 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdarg.h" 2 3

# 77 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdarg.h" 3






# 140 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdarg.h" 3





# 2 "/usr2/local/lib/gcc-lib/sparc-sun-sunos4.1/2.3.1/include/stdio.h" 2 3

 




extern	struct	_iobuf {
	int	_cnt;
	unsigned char *_ptr;
	unsigned char *_base;
	int	_bufsiz;
	short	_flag;
	char	_file;		 
} _iob[];








































extern struct _iobuf 	*fopen();
extern struct _iobuf 	*fdopen();
extern struct _iobuf 	*freopen();
extern struct _iobuf 	*popen();
extern struct _iobuf 	*tmpfile();
extern long	ftell();
extern char	*fgets();
extern char	*gets();
extern char	*sprintf();
extern char	*ctermid();
extern char	*cuserid();
extern char	*tempnam();
extern char	*tmpnam();






# 27 "example.c" 2


typedef struct complex {
   float r, i;
}  complex;


long WaveParams (argc, argp)
int argc;
char *argp[];
{
   char *b;
   short *s;
   long *l;
   float *f;
   double *d;
   complex *c;
   char **str;

   if (argc != 7) {
      fprintf ((&_iob[2]) , "wrong # of parameters\n");
      return (0);
   }

   b = ((char **) argp)[0];
   s = ((short **) argp)[1];
   l = ((long **) argp)[2];
   f = ((float **) argp)[3];
   d = ((double **) argp)[4];
   c = ((complex **) argp)[5];
   str = ((char ***) argp)[6];

   fprintf ((&_iob[2]) , "%d %d %ld %g %g <%g,%gi> '%s'\n",
     (int) b[0], (int) s[0], (long) l[0], f[0], d[0], c[0].r, c[0].i, str[0]);

   return (12345);
}

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 

END END END END END END END END END END END END END END END END END END END END