[gnu.g++] Installation of G++ 1.36- on 386 running SYS V 3.0

jxw@h.gp.cs.cmu.edu (John Willis) (10/31/89)

The following changes were required to enable compilation of a partially
functional g++ version 1.36-, under System 5, rev 3, on a 386.  The 
resulting binary appears to work except for linkage.  Descriptions are 
probably more useful than diffs as there have been several trial releases 
on labrea.stanford in the last few weeks.

1) symbolic links are used in the maketest target of the Makefile.
   Since SVSV generally does not support ln -s, the -s should be a 
   define variable in the upper section of the Makefile.
2) toplev.c needs to include /usr/include/sys/fcntl.h to define
   O_RDONLY.
3) For SVID, the third argument to lseek should be SEEK_SET instead of
   L_SET and SEEK_END should replace L_XTND.
4) The file name cplus-typeck2.c exceeds SVID file name length limits.
   I suggest using something like cplus-type2.c and editing makefile
   accordingly.
5) In cplus_lex.c, SVID uses strrchar() instead of rindex()
6) GNU malloc was used to get around problems with the system malloc
   supplied by Microport, your results may vary with other ports.
7) When testing under target crt0+.o for i386gas+ in the Makefile, 
   config/ should be added to the path.

Libg++ also needed a few changes...
8) In libg++/src/File.cc the include of sys/file.h must be preceeded
   by sys/types.h
9) In libg++/g++-include/sys/file.h we must also include 
   //usr/include/sys/fcntl.h as in the SUN case.
10) In libg++/src/streambuf.cc the include of sys/file.h must be 
    preceeded by sys/types.h
11) In std.h, bzero(), bcopy(), bcmp(), and index() should not be
    defined as functions if they are later defined as macros in
    the USG case.
12) In regex.cc, only define bzero(), bcopy(), and bcmp() if USG 
    is defined and std.h is not included.
13) In std.h don't define index as a macro since it will mess up 
    overloaded uses of index() such as the String class.

Linking is still not happening properly.  Using COFF encapsulation
and newld, some symbols from libraries related to the two static
chains were not linked properly (___xyzzy__, ___CTOR_LIST_, and
___DTOR_LIST__).  Defining USE_COLLECT for gcc.c did not work 
since no path seemed to define linker_was_run before 
do_spec(collect_spec).  Obviously collect also needs to be built
and (manually) installed once g++ knows how to call it.  Has anyone
already tracked the problem down?

-John

BTW: g++, version 1.35.1, functions well on the 80386.  A Sun
3/260 also used to develop and test a large compiler written in
g++ takes almost twice as long to do the compile, and the
resulting binary is almost always slower on the SUN 3.  The
80386 port is worthwhile.

grunwald@foobar.colorado.edu (Dirk Grunwald) (10/31/89)

The patches for collect in gcc.c were applied to a new version.
The code in question should look like:

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

  /* Run ld to link all the compiler output files.  */

  if (error_count == 0)
    {
      int tmp = execution_count;
      value = do_spec (link_spec);
      if (value < 0)
	error_count = 1;
      linker_was_run = (tmp != execution_count);
    }

#ifdef USE_COLLECT
      /* C++: now collect all the requirements for
	 calling global constructors and destructors,
	 and write them to a file.  We will link this file
	 in when we run.  */
      if (linker_was_run && ! error_count)
	{
	  int tmp = execution_count;
	  value = do_spec (collect_spec);
	  if (value < 0)
	    error_count = 1;
	  linker_was_run &= (tmp != execution_count);
	}
#endif

  /* If options said don't run linker,
     complain about input files to be given to the linker.  */

  if (! linker_was_run && error_count == 0)
    for (i = 0; i < n_infiles; i++)
      if (explicit_link_files[i])
	error ("%s: linker input file unused since linking not done",
	       outfiles[i]);

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

Also, collect.c may need a litte finaggling. Here's the macros you'll
need to define, as they appear in tm-mips.h. The goal of using
these macros is to cut down the bullpoop in collect.c

/* Specify what to precede various sizes of constant with
   in the output file.  */

#define ASM_INT_OP ".word "

/*
 *	Additions for collect.c
 */
#undef	COFF			/* do I coff */
#define EXTENDED_COFF		/* terminal illness? */
#define NO_UNDERSCORES		/* is main called `main' or `_main' by nm? */
#define USE_COLLECT		/* use collect or shoot for ld alone? */