From: rfg@netcom.com (Ronald F. Guilmette)
Subject: SVR4/g++ fixes (was: More on gcc-2.2.2's failure to compile libg++-2.2)
Organization: Netcom - Online Communication Services  (408 241-9760 guest)
Distribution: gnu
Date: Sun, 16 Aug 1992 09:27:55 GMT

In article <9208050724.AA26091@ttank.ttank.com> karl@ttank.ttank.COM (Karl Bunch) writes:
>Seems it's because DBX_REGISTER_NUMBER calls abort() if it
>can't return a register number for what works out to be
>greater than 15...

That is correct, and the i386/svr4 definition of the DBX_REGISTER_NUMBER
macro was *intentionally* made that way to trap bogus stuff (i.e. pseudo
register numbers) being passed from the other parts of the compiler into
the debug-info generation routines (i.e. into dwarfout.c).  We want to
catch this if it ever happens, because that indicates that something is
seriously wrong elsewhere in the compiler.

The problem you ran into was actually due to the fact that the DWARF support
for inline functions (used heavily in C++) was not completed in time for the
2.2.2 release of the compiler(s).  This support has now been completed, and
it will be incorporated into the 2.3 release of the compiler(s).

For the time being, please use the following patches if you intend to try
to use the g++ compiler on SVR4 with the -g option.  These patches are
only work-arounds for the current problems with g++ and DWARF.  They are
only useful when applied to the most recent released version of the
compiler sources (i.e. version 2.2.2).

// Ron Guilmette


diff -prc2 2.2.2-/cp-decl.c 2.2.2+/cp-decl.c
*** 2.2.2-/cp-decl.c	Wed Jun 10 21:14:00 1992
--- 2.2.2+/cp-decl.c	Sun Jul 26 15:32:49 1992
*************** grokdeclarator (declarator, declspecs, d
*** 6216,6220 ****
    enum tree_code innermost_code = ERROR_MARK;
    int bitfield = 0;
!   int variable_size = 0;
    /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
       All FIELD_DECLs we build here have `init' put into their DECL_INITIAL.  */
--- 6216,6220 ----
    enum tree_code innermost_code = ERROR_MARK;
    int bitfield = 0;
!   int size_varies = 0;
    /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
       All FIELD_DECLs we build here have `init' put into their DECL_INITIAL.  */
*************** grokdeclarator (declarator, declspecs, d
*** 7086,7089 ****
--- 7086,7093 ----
  		  dont_grok_size:
  		    itype = build_binary_op (MINUS_EXPR, size, integer_one_node);
+ 		    /* Make sure the array size remains visibly nonconstant
+ 		       even if it is (eg) a const variable with known value.  */
+ 		    size_varies = 1;
+ 		    itype = variable_size (itype);
  		    itype = build_index_type (itype);
  		  }
diff -prc2 2.2.2-/dwarfout.c 2.2.2+/dwarfout.c
*** 2.2.2-/dwarfout.c	Sat May 30 22:08:49 1992
--- 2.2.2+/dwarfout.c	Sun Jul 26 15:42:38 1992
*************** output_mem_loc_descriptor (rtl)
*** 1303,1308 ****
  
  	ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
!         ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
! 				DBX_REGISTER_NUMBER (REGNO (rtl)));
  	break;
  
--- 1303,1311 ----
  
  	ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
! 	if (is_pseudo_reg (rtl))
!           ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) -1);
! 	else
!           ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
! 				  DBX_REGISTER_NUMBER (REGNO (rtl)));
  	break;
  
*************** output_loc_descriptor (rtl)
*** 1359,1364 ****
      case REG:
  	ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
!         ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
! 				DBX_REGISTER_NUMBER (REGNO (rtl)));
  	break;
  
--- 1362,1370 ----
      case REG:
  	ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
! 	if (is_pseudo_reg (rtl))
!           ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) -1);
! 	else
!           ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
! 				  DBX_REGISTER_NUMBER (REGNO (rtl)));
  	break;
  
*************** output_decl (decl, containing_scope)
*** 3819,3823 ****
  
  	  if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
! 	    arg_decls = TREE_CHAIN (arg_decls);
  
  	  {
--- 3825,3829 ----
  
  	  if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
! 	    arg_decls = arg_decls ? TREE_CHAIN (arg_decls) : NULL_TREE;
  
  	  {
*************** dwarfout_file_scope_decl (decl, set_fina
*** 4098,4107 ****
       don't carry their own sequence numbers with them!)  */
  
!   if (DECL_IGNORED_P (decl))
!     {
!       if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
! 	abort ();
!       return;
!     }
  
    switch (TREE_CODE (decl))
--- 4104,4109 ----
       don't carry their own sequence numbers with them!)  */
  
!   if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
!     return;
  
    switch (TREE_CODE (decl))

Newsgroups: gnu.gcc.bug