[gnu.g++.bug] installing g++.xtar

dl@G.OSWEGO.EDU (Doug Lea) (10/03/89)

The installation instructions for g++.xtar (2 Oct 89 version on
labrea) were less than complete.  Here are some tentative answers to
things that have come up in the past day or so.

0. Unlike it's advertised version number, this g++ is based on
gcc-1.36, which should be used to compile g++, and as the $(DIR)
(i.e., ../gcc) in the g++ Makefile.

1. You should `make' and install g++/gcc to replace gcc in your
$(bindir).

2. You should `make' ld++, and install it as $(libdir)/gcc-ld
This will cause ld++ to be used for C compiles as well, but that
is OK. 

3. Remember that you must *explicitly* link in -lg++ these days.  You
might want to make your life easier by installing the following little
shellscript as $(bindir)/g++

#!/bin/sh
gcc $* -lg++

Better might be to glance through the libg++ Makefile and/or the
g++.texinfo file, and hard-wire into the g++ script some of the
options you always need to use from those listed there.

4. g++ can put out .stabs that don't correspond to actual asm
labels. On the sparc, at least, this gives /bin/as problems. You
should use GNU as (gas), installed as $(bindir)/as and/or
$(libdir)/gcc-as.  I just placed the version of gas I've been
successfully using (which includes a few additional sparc opcodes than
the currently distributed version) as
labrea.stanford.edu:pub/gnu/gas.xtar.Z

5. libg++/g++-include/setjmp.h has been giving people problems.
The replacement below ought to fare better.

6. I don't know what is necessary for people who *need* to use `collect'.
See Dirk Grunwald's note about setting things up for the PMAX at least.

7. Also below is a g++/expr.c patch needed to handle some uses of
const functions that don't appear in anything released in libg++.

8. If any System 5 users encounter any problems at all with this libg++,
please let me know! (directly or via bug-lib-g++).

9. Michael and I will be at OOPSLA the rest of the week. `Official'
1.36 releases of g++ and libg++ should be out `soon' thereafter.
Thanks to everyone for helping to test things.

-Doug

------------------- libg++/g++-include/setjmp.h
#ifndef _setjmp_h
#pragma once

extern "C" {

#define  setjmp  C_header_setjmp
#define  longjmp C_header_longjmp

#include "/usr/include/setjmp.h"

#undef setjmp
#undef longjmp

#ifndef _setjmp_h
#define _setjmp_h 1
#endif

extern int setjmp(jmp_buf);
extern void longjmp(jmp_buf, int);

}

#endif

-------------------------------
arkesden% diff -c2 expr.c~ expr.c
*** expr.c~	Sun Sep 24 19:32:36 1989
--- expr.c	Mon Oct  2 07:49:32 1989
***************
*** 4816,4834 ****
        rtx note = 0;
  
!       /* Construct an "equal form" for the value
! 	 which mentions all the arguments in order
! 	 as well as the function name.  */
!       for (i = 0; i < num_actuals; i++)
! 	if (args[i].reg != 0 || is_const)
! 	  note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note);
!       note = gen_rtx (EXPR_LIST, VOIDmode, XEXP (DECL_RTL (fndecl), 0), note);
  
!       REG_NOTES (insn_last)
! 	= gen_rtx (EXPR_LIST, REG_EQUAL, note,
! 		   gen_rtx (INSN_LIST, REG_RETVAL, insn_first,
! 			    REG_NOTES (insn_last)));
!       REG_NOTES (insn_first)
! 	= gen_rtx (INSN_LIST, REG_LIBCALL, insn_last,
! 		   REG_NOTES (insn_first));
      }
  
--- 4816,4838 ----
        rtx note = 0;
  
!       if (GET_CODE (insn_first) == INSN
! 	  && GET_CODE (insn_last) == INSN)
! 	{
! 	  /* Construct an "equal form" for the value
! 	     which mentions all the arguments in order
! 	     as well as the function name.  */
! 	  for (i = 0; i < num_actuals; i++)
! 	    if (args[i].reg != 0 || is_const)
! 	      note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note);
! 	  note = gen_rtx (EXPR_LIST, VOIDmode, XEXP (DECL_RTL (fndecl), 0), note);
  
! 	  REG_NOTES (insn_last)
! 	    = gen_rtx (EXPR_LIST, REG_EQUAL, note,
! 		       gen_rtx (INSN_LIST, REG_RETVAL, insn_first,
! 				REG_NOTES (insn_last)));
! 	  REG_NOTES (insn_first)
! 	    = gen_rtx (INSN_LIST, REG_LIBCALL, insn_last,
! 		       REG_NOTES (insn_first));
! 	}
      }
  

schmidt@zola.ics.uci.edu (Doug Schmidt) (10/03/89)

I've now got the latest libg++ and g++ up and running successfully on
the Sun 4, Sun 3, and Sequent Symmetry.  If anyone has any baffling
problems you can send me a note.

Also, for your hacking enjoyment, here is some sample exception handling
code.  To compile this type

% g++ -fhandle-exceptions foo.cc

Then type

% a.out m; a.out l

The example is rather contrived, but it illustrates some basic
syntactic and semantics points.

Please note that this new exception handling feature is experimental
and subject to change.

Doug
----------------------------------------
#include <stdio.h>
#include <setjmp.h>

class Search
{
private:
  char *buf;

public:
  exception { char item;} NOT_FOUND;

  Search (char *s) { buf = s; printf ("search buffer = %s\n", s); }

  int operator () (char c)
    {
      int i;
      for (i = 0; buf[i]; i++)
        if (buf[i] == c)
          return i;
      raise NOT_FOUND (c);
    }

  ~Search () { printf ("I should get printed regardless...\n"); }
};

main (int argc, char **argv)
{
  if (argc != 2)
    {
      printf ("usage: %s letter\n", argv[0]);
      exit (1);
    }
  else
    {
      Search search ("jammer");

      try
        {
          printf ("item found in location %d!\n", search (*argv[1]));
        }
      except search_item
        {
          Search::NOT_FOUND
            {
              printf ("item %c not found...\n", search_item.item);
            }
        }
    }
}
--
schmidt@ics.uci.edu (ARPA) |   Per me si va nella citta' dolente.
office: (714) 856-4043     |   Per me si va nell'eterno dolore.
                           |   Per me si va tra la perduta gente.
                           |   Lasciate ogni speranza o voi ch'entrate.