This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Solaris2 trunk failure w/C_alloca in gencodes


I don't think this patch was committed.  It works on irix6.5

> -----Original Message-----
> From:	Kaveh R. Ghazi [SMTP:ghazi@caip.rutgers.edu]
> Sent:	Monday, June 18, 2001 12:57 PM
> To:	dan@www.cgsoftware.com
> Cc:	Billinghurst, David (CRTS); gcc-bugs@gcc.gnu.org;
> gcc-patches@gcc.gnu.org; meissner@cygnus.com
> Subject:	Solaris2 trunk failure w/C_alloca in gencodes
> 
>  > 2001-06-16  Daniel Berlin  <dan@cgsoftware.com>
>  > 
>  >      * bitmap.h: Add dump_bitmap, bitmap_zero, bitmap_union_of_diffs,
>  >      bitmap_a_or_b, bitmap_a_and_b, bitmap_first_set_bit,
>  >      bitmap_last_set_bit. All for compatibility with sbitmap's.
>  > 
>  >      *bitmap.c (bitmap_zero): New function.
>  >      (bitmap_union_of_diffs): New function.
>  >      (bitmap_first_set_bit): New function.
>  >      (bitmap_last_set_bit): New function.
> 
> The above patch breaks the trunk on solaris2 (and probably others)
> when using cc for stage1.  (E.g. David noted it on irix6.5.)  Here's
> the failure:
> 
>  > cc -DIN_GCC -g -DHAVE_CONFIG_H -DGENERATOR_FILE -o gencodes \
>  >  gencodes.o rtl.o bitmap.o ggc-none.o gensupport.o hashtab.o
>  >  safe-ctype.o print-rtl.o errors.o ` case "obstack.o" in ?*) echo
>  >  obstack.o ;; esac ` ` case "" in ?*) echo ;; esac ` ` case "" in ?*)
>  >  echo ;; esac ` ` case "" in ?*) echo ;; esac `
>  > ild: (undefined symbol) C_alloca -- referenced in the text segment of
>  >      bitmap.o
>  > make.solaris2[2]: *** [gencodes] Error 5
> 
> There are two problems.
> 
> First, the patch uses alloca in bitmap.c.  Any file like bitmap.c
> which is used on both host and build platforms cannot use alloca since
> we don't link against libiberty for "build" programs to obtain
> C_alloca().  That's the cause of the failure above.
> 
> The second, more insidious, problem is this definition from bitmap.h:
> 
>  > /* Allocate a bitmap with alloca.  */
>  > #define BITMAP_ALLOCA()                                         \
>  >   bitmap_initialize ((bitmap) alloca (sizeof (bitmap_head)))
> 
> IIRC, passing alloca as an argument of a function is not guaranteed to
> work in all cases on all platforms, even when only using gcc.  Mixing
> in other stage1 compiler's alloca implementations is only worse.
> 
> (Side note: I wish gcc would warn whenever someone does this.  Maybe
> something for the "projects" list.)
> 
> Anyway, I don't think the definition of BITMAP_ALLOCA came from Dan's
> patch, but using it did.  We should change bitmap_union_of_diff() so
> that it doesn't use alloca, *and* we should change BITMAP_ALLOCA so
> that it doesn't pass alloca as a function argument.  Note Dan's usage
> of BITMAP_ALLOCA was the only one appearing in gcc sources at the
> moment.
> 
> 
> Here's an untested patch which does this.  Unfortunately solaris2
> doesn't bootstrap on the trunk for other reasons at the moment noted
> here: http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg00842.html
> 
> Also I'll be away for a week starting Monday, so I won't be able to
> test and/or checkin this patch until the following weekend at the
> earliest (if the other solaris2 problem is fixed by then.)  If someone
> else (Dan?) could spin this on something other than solaris2 and check
> it in when approved I'd appreciate it.
> 
> 		Thanks,
> 		--Kaveh
> 
> 
> 2001-06-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
> 
> 	* bitmap.c (bitmap_union_of_diff): Don't use BITMAP_ALLOCA.
> 
> 	* bitmap.h (BITMAP_ALLOCA): Don't pass alloca as an argument to a
> 	function.
> 
> diff -rup orig/egcs-CVS20010617/gcc/bitmap.c egcs-CVS20010617/gcc/bitmap.c
> --- orig/egcs-CVS20010617/gcc/bitmap.c	Sat Jun 16 16:30:14 2001
> +++ egcs-CVS20010617/gcc/bitmap.c	Sun Jun 17 22:11:56 2001
> @@ -687,9 +687,11 @@ bitmap_union_of_diff (dst, a, b, c)
>       bitmap c;
>  {
>    int changed = 0;
> -  bitmap temp = BITMAP_ALLOCA ();
> +  bitmap temp = BITMAP_XMALLOC ();
> +  
>    bitmap_operation (temp, b, c, BITMAP_AND_COMPL);
>    changed = bitmap_operation (dst, temp, a, BITMAP_IOR);
> +  BITMAP_XFREE (temp);
>    return changed;
>  }
>  
> diff -rup orig/egcs-CVS20010617/gcc/bitmap.h egcs-CVS20010617/gcc/bitmap.h
> --- orig/egcs-CVS20010617/gcc/bitmap.h	Sat Jun 16 16:30:14 2001
> +++ egcs-CVS20010617/gcc/bitmap.h	Sun Jun 17 22:09:50 2001
> @@ -119,10 +119,17 @@ extern int bitmap_last_set_bit PARAMS((b
>  #define BITMAP_OBSTACK_ALLOC(OBSTACK)				\
>    bitmap_initialize ((bitmap) obstack_alloc (OBSTACK, sizeof
> (bitmap_head)))
>  
> -/* Allocate a bitmap with alloca.  */
> -#define BITMAP_ALLOCA()						\
> -  bitmap_initialize ((bitmap) alloca (sizeof (bitmap_head)))
> -
> +/* Allocate a bitmap with alloca.  Note alloca cannot be passed as an
> +   argument to a function, so we set a temporary variable to the value
> +   returned by alloca and pass that variable to bitmap_initialize().
> +   PTR is then set to the value returned from bitmap_initialize() to
> +   avoid having it appear more than once in case it has side effects.  */
> +#define BITMAP_ALLOCA(PTR) \
> +do { \
> +  bitmap temp_bitmap_ = (bitmap) alloca (sizeof (bitmap_head)); \
> +  (PTR) = bitmap_initialize (temp_bitmap_); \
> +} while (0)
> +  
>  /* Allocate a bitmap with xmalloc.  */
>  #define BITMAP_XMALLOC()                                        \
>    bitmap_initialize ((bitmap) xmalloc (sizeof (bitmap_head)))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]