public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* enable-build-with-cxx bootstrap compare broken by r149964
@ 2009-08-15 18:11 Jerry Quinn
  2009-08-17 21:51 ` Jason Merrill
  2009-08-27 12:53 ` Jason Merrill
  0 siblings, 2 replies; 34+ messages in thread
From: Jerry Quinn @ 2009-08-15 18:11 UTC (permalink / raw)
  To: gcc; +Cc: Pedro Lamarão

Hi, folks,

Building with --enable-build-with-cxx fails to bootstrap as follows:

Comparing stages 2 and 3
warning: gcc/cc1plus-checksum.o differs
warning: gcc/cc1-checksum.o differs
Bootstrap comparison failure!
x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/eh_alloc.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/vec.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/eh_globals.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/guard.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/mt_allocator.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/locale.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/pool_allocator.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/basic_file.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/system_error.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/locale_init.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/debug.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/mt_allocator.o
differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/locale.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/pool_allocator.o
differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/basic_file.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/system_error.o
differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/locale_init.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/debug.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/.libs/atomic.o differs
x86_64-unknown-linux-gnu/32/libstdc++-v3/src/atomic.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/eh_alloc.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/vec.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/eh_globals.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/mt_allocator.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/locale.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/pool_allocator.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/basic_file.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/system_error.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/locale_init.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/debug.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/mt_allocator.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/locale.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/pool_allocator.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/basic_file.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/system_error.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/locale_init.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/debug.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/future.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/atomic.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/future.o differs
x86_64-unknown-linux-gnu/libstdc++-v3/src/atomic.o differs
make[2]: *** [compare] Error 1
make[2]: Leaving directory `/home/jlquinn/gcc/dev/build/trunk-cxx'
make[1]: *** [stage3-bubble] Error 2
make[1]: Leaving directory `/home/jlquinn/gcc/dev/build/trunk-cxx'
make: *** [all] Error 2
jlquinn@cerberus:~/gcc/dev/build/trunk-cxx$ 



After bisecting the svn repository, I tracked the problem down to
r149964:

XXXXXXXXXXXXXXX Try C++ bootstrap here FAIL
------------------------------------------------------------------------
r149964 | jason | 2009-07-22 19:03:22 -0400 (Wed, 22 Jul 2009) | 8 lines

        * mangle.c (mangle_type_string_for_rtti): Rename to be clearer.
        (needs_fake_anon): New.
        (write_name): Check it.
        (write_nested_name): Add a fake anonymous namespace scope if
true.
        * name-lookup.c (get_anonymous_namespace_name): No longer
static.
        * rtti.c, cp-tree.h: Adjust.

        * libsupc++/typeinfo (__GXX_MERGED_TYPEINFO_NAMES): Default to
0.



XXXXXXXXXXXXXXX Try C++ bootstrap here  SUCCESS
------------------------------------------------------------------------
r149962 | vmakarov | 2009-07-22 18:00:17 -0400 (Wed, 22 Jul 2009) | 22
lines

2009-07-22  Vladimir Makarov  <vmakarov@redhat.com>

PR target/37488
* ira-lives.c (bb_has_abnormal_call_pred): New function.
(process_bb_node_lives): Use it.





Can someone take a look at this please?

I came across this while trying to solve why enable-build-with-cxx
didn't build on Fedora 11. (I have a patch, but I was waiting to track
this down first).  Having checked in some of the configure patches for
it, I thought I should isolate the actual broken checkin to make sure it
wasn't me :-)


Thanks,
Jerry




^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-15 18:11 enable-build-with-cxx bootstrap compare broken by r149964 Jerry Quinn
@ 2009-08-17 21:51 ` Jason Merrill
  2009-08-18  9:33   ` Jerry Quinn
  2009-08-27 12:53 ` Jason Merrill
  1 sibling, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-08-17 21:51 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: gcc, Pedro Lamarão

On 08/15/2009 10:12 AM, Jerry Quinn wrote:
> Bootstrap comparison failure!
 >[...]
>          (write_nested_name): Add a fake anonymous namespace scope if
> true.

What I assume is going on here is that use of anonymous namespaces can 
break bitwise comparison, because get_file_function_name uses a random 
number if it doesn't know a non-weak symbol to use in the name.

One thing that would help would be to defer all mangling, or at least 
all mangling that depends on the anonymous namespace name, until end of 
file so that first_global_object_name is usually set.

I'm not sure why GCC sources would need to mangle function-local 
structs, though.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-17 21:51 ` Jason Merrill
@ 2009-08-18  9:33   ` Jerry Quinn
  2009-08-18 19:50     ` Richard Henderson
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-18  9:33 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc, Pedro Lamarão

On Mon, 2009-08-17 at 16:16 -0400, Jason Merrill wrote:
> On 08/15/2009 10:12 AM, Jerry Quinn wrote:
> > Bootstrap comparison failure!
>  >[...]
> >          (write_nested_name): Add a fake anonymous namespace scope if
> > true.
> 
> What I assume is going on here is that use of anonymous namespaces can 
> break bitwise comparison, because get_file_function_name uses a random 
> number if it doesn't know a non-weak symbol to use in the name.
> 
> One thing that would help would be to defer all mangling, or at least 
> all mangling that depends on the anonymous namespace name, until end of 
> file so that first_global_object_name is usually set.
> 
> I'm not sure why GCC sources would need to mangle function-local 
> structs, though.

I'm not sure if the following is relevant, but I found it in
cp/mangle.c:

/* Since we now use strcmp to compare typeinfos on all targets because
of
   the RTLD_LOCAL problem, we need to munge the typeinfo name used for
   local classes of static functions to fix g++.dg/abi/local1.C.  We do
   that by pretending that the function is in an anonymous namespace.
*/

static bool
needs_fake_anon (const_tree decl)


Jery


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-18  9:33   ` Jerry Quinn
@ 2009-08-18 19:50     ` Richard Henderson
  2009-08-19  2:57       ` Jason Merrill
  2009-08-20  8:48       ` Jerry Quinn
  0 siblings, 2 replies; 34+ messages in thread
From: Richard Henderson @ 2009-08-18 19:50 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Jason Merrill, gcc, Pedro Lamarão

On 08/17/2009 07:40 PM, Jerry Quinn wrote:
> On Mon, 2009-08-17 at 16:16 -0400, Jason Merrill wrote:
>> I'm not sure why GCC sources would need to mangle function-local
>> structs, though.
>
> I'm not sure if the following is relevant, but I found it in
> cp/mangle.c:
>
> /* Since we now use strcmp to compare typeinfos on all targets because
> of
>     the RTLD_LOCAL problem, we need to munge the typeinfo name used for
>     local classes of static functions to fix g++.dg/abi/local1.C.  We do
>     that by pretending that the function is in an anonymous namespace.
> */
>
> static bool
> needs_fake_anon (const_tree decl)

Would it be helpful to reserve a leading character (say, "*") that means 
that strcmp should not apply, but rather pointer identity?  Thus a class 
foo that is intended to be local, as opposed to forced local via 
RTLD_LOCAL, can just use "*foo" and not have to bother with mangling?


r~

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-18 19:50     ` Richard Henderson
@ 2009-08-19  2:57       ` Jason Merrill
  2009-08-20  8:48       ` Jerry Quinn
  1 sibling, 0 replies; 34+ messages in thread
From: Jason Merrill @ 2009-08-19  2:57 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jerry Quinn, gcc, Pedro Lamarão

On 08/18/2009 11:43 AM, Richard Henderson wrote:
> Would it be helpful to reserve a leading character (say, "*") that means
> that strcmp should not apply, but rather pointer identity? Thus a class
> foo that is intended to be local, as opposed to forced local via
> RTLD_LOCAL, can just use "*foo" and not have to bother with mangling?

Interesting idea.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-18 19:50     ` Richard Henderson
  2009-08-19  2:57       ` Jason Merrill
@ 2009-08-20  8:48       ` Jerry Quinn
  2009-08-20 12:33         ` Dave Korn
  1 sibling, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-20  8:48 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jason Merrill, gcc, Pedro Lamarão

On Tue, 2009-08-18 at 08:43 -0700, Richard Henderson wrote:
> On 08/17/2009 07:40 PM, Jerry Quinn wrote:
> > On Mon, 2009-08-17 at 16:16 -0400, Jason Merrill wrote:
> >> I'm not sure why GCC sources would need to mangle function-local
> >> structs, though.
> >
> Would it be helpful to reserve a leading character (say, "*") that means 
> that strcmp should not apply, but rather pointer identity?  Thus a class 
> foo that is intended to be local, as opposed to forced local via 
> RTLD_LOCAL, can just use "*foo" and not have to bother with mangling?

I took a (very naive) swing at implementing this.  I made the change in
my copy of r149964 to avoid the possibility of other issues interfering.
Apparently my change is too naive, because the assembler doesn't like a
name with '*' in it.  Are there any chars that can pass muster with
assemblers but not be a valid namespace identifier?

The patch I tried is below.

Thanks,
Jerry


libtool: compile:  /home/jlquinn/gcc/dev/build/trunk/./gcc/xgcc
-shared-libgcc -B/home/jlquinn/gcc/dev/build/trunk/./gcc -nostdinc++
-L/home/jlquinn/gcc/dev/build/trunk/x86_64-unknown-linux-gnu/libstdc
++-v3/src
-L/home/jlquinn/gcc/dev/build/trunk/x86_64-unknown-linux-gnu/libstdc
++-v3/src/.libs -B/usr/local/x86_64-unknown-linux-gnu/bin/
-B/usr/local/x86_64-unknown-linux-gnu/lib/
-isystem /usr/local/x86_64-unknown-linux-gnu/include
-isystem /usr/local/x86_64-unknown-linux-gnu/sys-include
-I/home/jlquinn/gcc/dev/gcc-in-cxx/libstdc++-v3/../gcc
-I/home/jlquinn/gcc/dev/build/trunk/x86_64-unknown-linux-gnu/libstdc
++-v3/include/x86_64-unknown-linux-gnu
-I/home/jlquinn/gcc/dev/build/trunk/x86_64-unknown-linux-gnu/libstdc
++-v3/include -I/home/jlquinn/gcc/dev/gcc-in-cxx/libstdc++-v3/libsupc++
-fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual
-fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g
-O2 -D_GNU_SOURCE -c ../../../../../gcc-in-cxx/libstdc++-v3/libsupc
++/eh_alloc.cc  -fPIC -DPIC -o eh_alloc.o
/tmp/ccbRNQMb.s: Assembler messages:
/tmp/ccbRNQMb.s:1384: Error: unrecognized symbol type ""
/tmp/ccbRNQMb.s:1384: Error: junk at end of line, first unrecognized
character is `*'
/tmp/ccbRNQMb.s:1385: Error: expected comma after name `_ZN12' in .size
directive
/tmp/ccbRNQMb.s:1386: Error: invalid character '*' in mnemonic
make[5]: *** [eh_alloc.lo] Error 1



Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 149964)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -69,7 +69,8 @@
     {
       /* The anonymous namespace has to have a unique name
 	 if typeinfo objects are being compared by name.  */
-      anonymous_namespace_name = get_file_function_name ("N");
+      //      anonymous_namespace_name = get_file_function_name ("N");
+      anonymous_namespace_name = get_identifier ("*cxx_anon_ns");
     }
   return anonymous_namespace_name;
 }
Index: libstdc++-v3/libsupc++/tinfo2.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo2.cc	(revision 149964)
+++ libstdc++-v3/libsupc++/tinfo2.cc	(working copy)
@@ -37,7 +37,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
 #else
-  return __builtin_strcmp (name (), arg.name ()) < 0;
+  return (name ()[0] == '*' && arg.name()[0] == '*')
+    ? name () < arg.name ()
+    :  __builtin_strcmp (name (), arg.name ()) < 0;
 #endif
 }
 
Index: libstdc++-v3/libsupc++/typeinfo
===================================================================
--- libstdc++-v3/libsupc++/typeinfo	(revision 149964)
+++ libstdc++-v3/libsupc++/typeinfo	(working copy)
@@ -110,12 +110,15 @@
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
     bool before(const type_info& __arg) const
-    { return __builtin_strcmp (__name, __arg.__name) < 0; }
+    { return (__name[0] == '*' && __arg.__name[0] == '*')
+	? __name < __arg.__name
+	: __builtin_strcmp (__name, __arg.__name) < 0; }
 
     bool operator==(const type_info& __arg) const
     {
       return ((__name == __arg.__name)
-	      || __builtin_strcmp (__name, __arg.__name) == 0);
+	      || (__name[0] != '*' && __arg.__name[0] != '*' &&
+		  __builtin_strcmp (__name, __arg.__name) == 0));
     }
   #else
     // On some targets we can rely on type_info's NTBS being unique,
Index: libstdc++-v3/libsupc++/tinfo.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo.cc	(revision 149964)
+++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
@@ -41,7 +41,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
 #else
-  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
0);
+  return (&arg == this)
+    || (name ()[0] != '*' && arg.name ()[0] != '*'
+	&& (__builtin_strcmp (name (), arg.name ()) == 0));
 #endif
 }
 




^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20  8:48       ` Jerry Quinn
@ 2009-08-20 12:33         ` Dave Korn
  2009-08-20 13:28           ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Dave Korn @ 2009-08-20 12:33 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

Jerry Quinn wrote:
> On Tue, 2009-08-18 at 08:43 -0700, Richard Henderson wrote:
>> On 08/17/2009 07:40 PM, Jerry Quinn wrote:
>>> On Mon, 2009-08-17 at 16:16 -0400, Jason Merrill wrote:
>>>> I'm not sure why GCC sources would need to mangle function-local
>>>> structs, though.
>> Would it be helpful to reserve a leading character (say, "*") that means 
>> that strcmp should not apply, but rather pointer identity?  Thus a class 
>> foo that is intended to be local, as opposed to forced local via 
>> RTLD_LOCAL, can just use "*foo" and not have to bother with mangling?
> 
> I took a (very naive) swing at implementing this.  I made the change in
> my copy of r149964 to avoid the possibility of other issues interfering.
> Apparently my change is too naive, because the assembler doesn't like a
> name with '*' in it.  Are there any chars that can pass muster with
> assemblers but not be a valid namespace identifier?

  Don't you just want to arrange things so that the asterisk ends up in the
typeinfo name string but not in the asm name?

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 12:33         ` Dave Korn
@ 2009-08-20 13:28           ` Jerry Quinn
  2009-08-20 13:37             ` Dave Korn
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-20 13:28 UTC (permalink / raw)
  To: Dave Korn; +Cc: Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

On Thu, 2009-08-20 at 11:12 +0100, Dave Korn wrote:
> Jerry Quinn wrote:
> > On Tue, 2009-08-18 at 08:43 -0700, Richard Henderson wrote:
> >> On 08/17/2009 07:40 PM, Jerry Quinn wrote:
> >>> On Mon, 2009-08-17 at 16:16 -0400, Jason Merrill wrote:
> >>>> I'm not sure why GCC sources would need to mangle function-local
> >>>> structs, though.
> >> Would it be helpful to reserve a leading character (say, "*") that means 
> >> that strcmp should not apply, but rather pointer identity?  Thus a class 
> >> foo that is intended to be local, as opposed to forced local via 
> >> RTLD_LOCAL, can just use "*foo" and not have to bother with mangling?
> > 
> > I took a (very naive) swing at implementing this.  I made the change in
> > my copy of r149964 to avoid the possibility of other issues interfering.
> > Apparently my change is too naive, because the assembler doesn't like a
> > name with '*' in it.  Are there any chars that can pass muster with
> > assemblers but not be a valid namespace identifier?
> 
>   Don't you just want to arrange things so that the asterisk ends up in the
> typeinfo name string but not in the asm name?

Well, it WAS a very naive attack on the problem :-)

Where can I look to set the typeinfo name without setting the asm name?

Thanks,
Jerry


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 13:28           ` Jerry Quinn
@ 2009-08-20 13:37             ` Dave Korn
  2009-08-20 14:09               ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Dave Korn @ 2009-08-20 13:37 UTC (permalink / raw)
  To: Jerry Quinn
  Cc: Dave Korn, Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

Jerry Quinn wrote:
> On Thu, 2009-08-20 at 11:12 +0100, Dave Korn wrote:
>> Jerry Quinn wrote:

>>> Apparently my change is too naive, because the assembler doesn't like a
>>> name with '*' in it.  Are there any chars that can pass muster with
>>> assemblers but not be a valid namespace identifier?
>>   Don't you just want to arrange things so that the asterisk ends up in the
>> typeinfo name string but not in the asm name?
> 
> Well, it WAS a very naive attack on the problem :-)
> 
> Where can I look to set the typeinfo name without setting the asm name?

  I think you want to just modify the NTBS name, rather than the internal
identifier used to refer to it.  Take a look at tinfo_base_init() in
gcc/cp/rtti.c, and how it calls tinfo_name.

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 13:37             ` Dave Korn
@ 2009-08-20 14:09               ` Jerry Quinn
  2009-08-20 16:51                 ` Dave Korn
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-20 14:09 UTC (permalink / raw)
  To: Dave Korn; +Cc: Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

On Thu, 2009-08-20 at 14:05 +0100, Dave Korn wrote:
> Jerry Quinn wrote:
> > On Thu, 2009-08-20 at 11:12 +0100, Dave Korn wrote:
> >> Jerry Quinn wrote:
> 
> >>> Apparently my change is too naive, because the assembler doesn't like a
> >>> name with '*' in it.  Are there any chars that can pass muster with
> >>> assemblers but not be a valid namespace identifier?
> >>   Don't you just want to arrange things so that the asterisk ends up in the
> >> typeinfo name string but not in the asm name?
> > 
> > Well, it WAS a very naive attack on the problem :-)
> > 
> > Where can I look to set the typeinfo name without setting the asm name?
> 
>   I think you want to just modify the NTBS name, rather than the internal
> identifier used to refer to it.  Take a look at tinfo_base_init() in
> gcc/cp/rtti.c, and how it calls tinfo_name.

OK, I'm now confused.  How does this dovetail with anonymous
namespaces?  

Richard's suggestion was to avoid mangling the name at all and relying
on pointers being different to distinguish between the anonymous
namespaces in different translation units.

If I understand correctly, the main thing we want is for libstdc++ to
consider two typeinfos the same if they are the same type in the same
file's anonymous namespace, but different if they have the same name but
came from different files.

I'm unclear how the symbols in the asm get turned into typeinfos, and
thus how the transform needs to be done.

Jerry


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 14:09               ` Jerry Quinn
@ 2009-08-20 16:51                 ` Dave Korn
  2009-08-20 19:26                   ` Dave Korn
  2009-08-21 23:01                   ` Jerry Quinn
  0 siblings, 2 replies; 34+ messages in thread
From: Dave Korn @ 2009-08-20 16:51 UTC (permalink / raw)
  To: Jerry Quinn
  Cc: Dave Korn, Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

Jerry Quinn wrote:
> 
> OK, I'm now confused.  How does this dovetail with anonymous
> namespaces?  

  We're talking about typeinfo strings.  The namespace is part of the typeinfo
name string (the so-called NTBS name), and it's the random number in the
anonymous namespace name used for these local definitions that is varying
between stages 2 and 3 and causing the bootstrap comparison failure, if I've
been following the thread correctly.

> Richard's suggestion was to avoid mangling the name at all and relying
> on pointers being different to distinguish between the anonymous
> namespaces in different translation units.

  Yep, and to put an asterisk at the start of the NTBS name to indicate that
it can only be used for pointer comparison.

> If I understand correctly, the main thing we want is for libstdc++ to
> consider two typeinfos the same if they are the same type in the same
> file's anonymous namespace, but different if they have the same name but
> came from different files.

  Yep, that's the idea.

> I'm unclear how the symbols in the asm get turned into typeinfos, and
> thus how the transform needs to be done.

  It's the other way round.  The typeinfo names and structs are constructed
based on the C++ decl tree structs for the type in question, and then assigned
an asm name according to the cxx-abi rules.

  Your patch puts the asterisk into the namespace identifier decl, so it ends
up in both the rtti NTBS name string, and also in the generated asm name for
the objects.  What I think you need to do is use an identifier for the
anonymous namespace without an asterisk, but prefix the asterisk when
generating the corresponding NTBS name string; then your changes to the name
comparison routines in libsupc++ should work, but the typeinfo name string
won't have any funny chars in it.

  You might also need to take steps to ensure that the typeinfo gets emitted
as non-COMDAT with local symbols, so that each object does indeed end up with
its own separate copy.

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 16:51                 ` Dave Korn
@ 2009-08-20 19:26                   ` Dave Korn
  2009-08-21 23:01                   ` Jerry Quinn
  1 sibling, 0 replies; 34+ messages in thread
From: Dave Korn @ 2009-08-20 19:26 UTC (permalink / raw)
  To: Dave Korn
  Cc: Jerry Quinn, Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

Dave Korn wrote:
> What I think you need to do is use an identifier for the
> anonymous namespace without an asterisk, but prefix the asterisk when
> generating the corresponding NTBS name string; then your changes to the name
> comparison routines in libsupc++ should work, but the typeinfo name string
> won't have any funny chars in it.

  Bah, that was confusing of me.  I meant to say that the asm label for the
typeinfo name string won't have any funny chars in it; the name string itself
will of course still contain the asterisk.  Sorry.

    cheers,
      DaveK


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-20 16:51                 ` Dave Korn
  2009-08-20 19:26                   ` Dave Korn
@ 2009-08-21 23:01                   ` Jerry Quinn
  2009-08-21 23:15                     ` Richard Henderson
  1 sibling, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-21 23:01 UTC (permalink / raw)
  To: Dave Korn; +Cc: Richard Henderson, Jason Merrill, gcc, Pedro Lamarão

On Thu, 2009-08-20 at 15:22 +0100, Dave Korn wrote:
>   Your patch puts the asterisk into the namespace identifier decl, so it ends
> up in both the rtti NTBS name string, and also in the generated asm name for
> the objects.  What I think you need to do is use an identifier for the
> anonymous namespace without an asterisk, but prefix the asterisk when
> generating the corresponding NTBS name string; then your changes to the name
> comparison routines in libsupc++ should work, but the typeinfo name string
> won't have any funny chars in it.

OK, I've gotten almost this far and can bootstrap (the asterisk is
actually not the very first char and I have to figure that out).
However, in the referenced test case, both typeinfos are apparently
merged, thus returning the same pointer for their name strings, so
pointer comparison still wouldn't work.

Therefore, I guess I'll need to do the following:

>   You might also need to take steps to ensure that the typeinfo gets emitted
> as non-COMDAT with local symbols, so that each object does indeed end up with
> its own separate copy.

Where should I look to do this?

Thanks,
Jerry


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-21 23:01                   ` Jerry Quinn
@ 2009-08-21 23:15                     ` Richard Henderson
  2009-08-22 16:33                       ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Richard Henderson @ 2009-08-21 23:15 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Dave Korn, Jason Merrill, gcc, Pedro Lamarão

On 08/21/2009 02:37 PM, Jerry Quinn wrote:
> OK, I've gotten almost this far and can bootstrap (the asterisk is
> actually not the very first char and I have to figure that out).
> However, in the referenced test case, both typeinfos are apparently
> merged, thus returning the same pointer for their name strings, so
> pointer comparison still wouldn't work.
>
> Therefore, I guess I'll need to do the following:
>
>>    You might also need to take steps to ensure that the typeinfo gets emitted
>> as non-COMDAT with local symbols, so that each object does indeed end up with
>> its own separate copy.
>
> Where should I look to do this?

First thing you should do is make sure you're emitting a VAR_DECL
with the string contents, rather than a STRING_CST constant.  The
later will be merged within an object file within the compiler.

Second, make sure the VAR_DECL for the typeinfo is no DECL_ONE_ONLY.
That flag sets up COMDAT sections, which will be merged by the linker.


r~

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-21 23:15                     ` Richard Henderson
@ 2009-08-22 16:33                       ` Jerry Quinn
  0 siblings, 0 replies; 34+ messages in thread
From: Jerry Quinn @ 2009-08-22 16:33 UTC (permalink / raw)
  To: Richard Henderson
  Cc: Dave Korn, Jason Merrill, gcc, Pedro Lamarão, gcc-patches

On Fri, 2009-08-21 at 15:25 -0700, Richard Henderson wrote:
> On 08/21/2009 02:37 PM, Jerry Quinn wrote:
> > OK, I've gotten almost this far and can bootstrap (the asterisk is
> > actually not the very first char and I have to figure that out).
> > However, in the referenced test case, both typeinfos are apparently
> > merged, thus returning the same pointer for their name strings, so
> > pointer comparison still wouldn't work.
> >
> > Therefore, I guess I'll need to do the following:
> >
> >>    You might also need to take steps to ensure that the typeinfo gets emitted
> >> as non-COMDAT with local symbols, so that each object does indeed end up with
> >> its own separate copy.
> >
> > Where should I look to do this?
> 
> First thing you should do is make sure you're emitting a VAR_DECL
> with the string contents, rather than a STRING_CST constant.  The
> later will be merged within an object file within the compiler.
> 
> Second, make sure the VAR_DECL for the typeinfo is no DECL_ONE_ONLY.
> That flag sets up COMDAT sections, which will be merged by the linker.

It looks like I"ve got a working patch now.  It bootstraps and has no
reqressions from make check, nor from make check in the libstdc++
directory.

Any thoughts?

Jerry


2009-08-22  Jerry Quinn  <jlquinn@optonline.net>

	* name-lookup.c (get_anonymous_namespace_name): Use fixed
	namespace "cxx_anon_ns".
	* mangle.c (write_nested_name): Insert '*' to mark fake anonymous
	namespace.
	(get_mangled_string_length): New function.
	(mangle_type_string_for_rtti): Put '*' at start of mangled namestring.
	* rtti.c (tinfo_base_init): Disable DECL_COMDAT for fake
	anonymous namespaces.

2009-08-22  Jerry Quinn  <jlquinn@optonline.net>

	* libsupc++/tinfo.cc (typeinfo::operator==): Compare names
	starting with '*' by pointer.
	* libsupc++/tinfo2.cc (typeinfo::before): Same.
	* libsupc++/typeinfo (typeinfo::operator==): Same.
	* libsupc++/typeinfo (typeinfo::before): Same.


Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 151008)
+++ gcc/cp/rtti.c	(working copy)
@@ -862,9 +862,12 @@
     DECL_TINFO_P (name_decl) = 1;
     set_linkage_according_to_type (target, name_decl);
     import_export_decl (name_decl);
+    /* Disable DECL_COMDAT if we have an anonymous namspace here. */
+    if (TREE_STRING_POINTER (name_string)[0] == '*')
+      DECL_COMDAT (name_decl) = 0;
     DECL_INITIAL (name_decl) = name_string;
     mark_used (name_decl);
     pushdecl_top_level_and_finish (name_decl, name_string);
 2009-08-21  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/41131
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 151008)
+++ gcc/cp/mangle.c	(working copy)
@@ -935,8 +935,14 @@
       /* No, just use <prefix>  */
       write_prefix (DECL_CONTEXT (decl));
       if (needs_fake_anon (decl))
-	/* Pretend this static function is in an anonymous namespace.  */
-	write_source_name (get_anonymous_namespace_name ());
+	{
+	  /* Add a * to mark fake anonymous namespaces in typeinfos as
+	     compare-by-pointer.  This * is used to put another one at the
+	     front when done building the string. */
+	  write_char ('*');
+	  /* Pretend this static function is in an anonymous namespace.  */
+	  write_source_name (get_anonymous_namespace_name ());
+	}
       write_unqualified_name (decl);
     }
   write_char ('E');
@@ -2755,6 +2761,14 @@
   name_base = obstack_alloc (&name_obstack, 0);
 }
 
+/*  Returns the length of the mangled string array.  */
+
+static inline int
+get_mangled_string_length (void)
+{
+  return obstack_object_size (mangle_obstack);
+}
+
 /* Done with mangling. If WARN is true, and the name of G.entity will
    be mangled differently in a future version of the ABI, issue a
    warning.  */
@@ -2851,13 +2865,20 @@
 mangle_type_string_for_rtti (const tree type)
 {
   const char *result;
+  int result_len;
 
   start_mangling (type);
   /* Mangle in a fake anonymous namespace if necessary.  */
   fake_anon_scope = true;
+  /* Place marker to be removed if not dealing with a nested name.  */
+  write_char('*');
   write_type (type);
   fake_anon_scope = false;
+  result_len = get_mangled_string_length ();
   result = finish_mangling (/*warn=*/false);
+  /* Remove the marker if not needed.  */
+  if (!strchr(result + 1, '*'))
+    result++;
   if (DEBUG_MANGLE)
     fprintf (stderr, "mangle_type_string = '%s'\n\n", result);
   return result;
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 151008)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -69,7 +69,7 @@
     {
       /* The anonymous namespace has to have a unique name
 	 if typeinfo objects are being compared by name.  */
-      anonymous_namespace_name = get_file_function_name ("N");
+      anonymous_namespace_name = get_identifier ("cxx_anon_ns");
     }
   return anonymous_namespace_name;
 }
Index: libstdc++-v3/libsupc++/tinfo2.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo2.cc	(revision 151008)
+++ libstdc++-v3/libsupc++/tinfo2.cc	(working copy)
@@ -37,7 +37,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
 #else
-  return __builtin_strcmp (name (), arg.name ()) < 0;
+  return (name ()[0] == '*' && arg.name()[0] == '*')
+    ? name () < arg.name ()
+    :  __builtin_strcmp (name (), arg.name ()) < 0;
 #endif
 }
 
Index: libstdc++-v3/libsupc++/typeinfo
===================================================================
--- libstdc++-v3/libsupc++/typeinfo	(revision 151008)
+++ libstdc++-v3/libsupc++/typeinfo	(working copy)
@@ -110,12 +110,15 @@
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
     bool before(const type_info& __arg) const
-    { return __builtin_strcmp (__name, __arg.__name) < 0; }
+    { return (__name[0] == '*' && __arg.__name[0] == '*')
+	? __name < __arg.__name
+	: __builtin_strcmp (__name, __arg.__name) < 0; }
 
     bool operator==(const type_info& __arg) const
     {
       return ((__name == __arg.__name)
-	      || __builtin_strcmp (__name, __arg.__name) == 0);
+	      || (__name[0] != '*' && __arg.__name[0] != '*' &&
+		  __builtin_strcmp (__name, __arg.__name) == 0));
     }
   #else
     // On some targets we can rely on type_info's NTBS being unique,
Index: libstdc++-v3/libsupc++/tinfo.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo.cc	(revision 151008)
+++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
@@ -41,7 +41,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
 #else
-  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
0);
+  return (&arg == this)
+    || (name ()[0] != '*' && arg.name ()[0] != '*'
+	&& (__builtin_strcmp (name (), arg.name ()) == 0));
 #endif
 }
 




^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-15 18:11 enable-build-with-cxx bootstrap compare broken by r149964 Jerry Quinn
  2009-08-17 21:51 ` Jason Merrill
@ 2009-08-27 12:53 ` Jason Merrill
  2009-08-31 16:07   ` Jerry Quinn
  2009-09-03 23:20   ` Alexandre Oliva
  1 sibling, 2 replies; 34+ messages in thread
From: Jason Merrill @ 2009-08-27 12:53 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: gcc, Pedro Lamarão

On 08/15/2009 10:12 AM, Jerry Quinn wrote:
> Building with --enable-build-with-cxx fails to bootstrap as follows:
>
> Comparing stages 2 and 3
> warning: gcc/cc1plus-checksum.o differs
> warning: gcc/cc1-checksum.o differs
> Bootstrap comparison failure!
> x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/eh_alloc.o differs
 >...

Do you know why r149964 makes a difference?  The only objects that are 
listed as differing here are from libstdc++, and changing 
needs_fake_anon to abort rather than return true doesn't cause any 
problems building libstdc++.  We used anonymous namespaces in the 
library before this...

I tried doing the bootstrap myself, but build-with-cxx doesn't currently 
work with glibc 2.10.  I guess I could try on a box with an older 
install, but haven't yet.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-27 12:53 ` Jason Merrill
@ 2009-08-31 16:07   ` Jerry Quinn
  2009-09-14 15:54     ` Jason Merrill
  2009-09-03 23:20   ` Alexandre Oliva
  1 sibling, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-08-31 16:07 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc, Pedro Lamarão

On Thu, 2009-08-27 at 00:24 -0400, Jason Merrill wrote:
> On 08/15/2009 10:12 AM, Jerry Quinn wrote:
> > Building with --enable-build-with-cxx fails to bootstrap as follows:
> >
> > Comparing stages 2 and 3
> > warning: gcc/cc1plus-checksum.o differs
> > warning: gcc/cc1-checksum.o differs
> > Bootstrap comparison failure!
> > x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/eh_alloc.o differs
>  >...
> 
> Do you know why r149964 makes a difference?  The only objects that are 
> listed as differing here are from libstdc++, and changing 
> needs_fake_anon to abort rather than return true doesn't cause any 
> problems building libstdc++.  We used anonymous namespaces in the 
> library before this...

I don't know.  I didn't try to debug, I only did the bootstraps
narrowing down the offending patch.

> I tried doing the bootstrap myself, but build-with-cxx doesn't currently 
> work with glibc 2.10.  I guess I could try on a box with an older 
> install, but haven't yet.

The following patch solved bootstrapping for Pedro on Fedora 11.  It's
got the new glibc.  Tackling that issue is what got me onto this one to
begin with.  I was holding off on submitting it because I wouldn't be
able to claim that the patch bootstrapped successfully against the head
of the trunk.

Jerry


Index: gcc/configure
===================================================================
--- gcc/configure	(revision 149964)
+++ gcc/configure	(working copy)
@@ -10650,8 +10650,9 @@
 
 
 
+
 for ac_func in times clock kill getrlimit setrlimit atoll atoq \
-	sysconf strsignal getrusage nl_langinfo \
+	sysconf strsignal getrusage nl_langinfo basename \
 	gettimeofday mbstowcs wcswidth mmap mincore setlocale \
 	clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked
fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked
fputc_unlocked fputs_unlocked   fread_unlocked fwrite_unlocked
getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked
 do
@@ -12673,11 +12674,10 @@
 
 
 
-
 for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \
 	strsignal strstr strverscmp \
 	errno snprintf vsnprintf vasprintf malloc realloc calloc \
-	free basename getopt clock getpagesize clearerr_unlocked feof_unlocked
ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked
fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked
fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked
putchar_unlocked putc_unlocked
+	free getopt clock getpagesize clearerr_unlocked feof_unlocked
ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked
fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked
fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked
putchar_unlocked putc_unlocked
 do
   ac_tr_decl=`echo "HAVE_DECL_$ac_func" | $as_tr_cpp`
 echo "$as_me:$LINENO: checking whether $ac_func is declared" >&5
Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 149964)
+++ gcc/config.in	(working copy)
@@ -321,6 +321,12 @@
 #endif
 
 
+/* Define if your assembler supports LWSYNC instructions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_LWSYNC
+#endif
+
+
 /* Define if your assembler supports mfcr field. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_MFCRF
@@ -351,23 +357,18 @@
 #endif
 
 
-/* Define if your assembler supports popcntb instruction. */
+/* Define if your assembler supports popcntb field. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_POPCNTB
 #endif
 
 
-/* Define if your assembler supports popcntd instruction. */
+/* Define if your assembler supports POPCNTD instructions. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_POPCNTD
 #endif
 
-/* Define if your assembler supports lwsync instruction. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_AS_LWSYNC
-#endif
 
-
 /* Define if your assembler supports .register. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_REGISTER_PSEUDO_OP
@@ -430,6 +431,12 @@
 #endif
 
 
+/* Define to 1 if you have the `basename' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_BASENAME
+#endif
+
+
 /* Define to 1 if you have the `clearerr_unlocked' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_CLEARERR_UNLOCKED
@@ -480,13 +487,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'basename', otherwise
define to
-   0. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_BASENAME
-#endif
-
-
 /* Define to 1 if we found a declaration for 'calloc', otherwise define
to 0.
    */
 #ifndef USED_FOR_TARGET
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 149964)
+++ gcc/configure.ac	(working copy)
@@ -1016,7 +1016,7 @@
   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
   putchar_unlocked putc_unlocked)
 AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoll atoq \
-	sysconf strsignal getrusage nl_langinfo \
+	sysconf strsignal getrusage nl_langinfo basename \
 	gettimeofday mbstowcs wcswidth mmap mincore setlocale \
 	gcc_UNLOCKED_FUNCS)
 
@@ -1068,7 +1068,7 @@
 gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \
 	strsignal strstr strverscmp \
 	errno snprintf vsnprintf vasprintf malloc realloc calloc \
-	free basename getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[
+	free getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[
 #include "ansidecl.h"
 #include "system.h"])
 
Index: include/libiberty.h
===================================================================
--- include/libiberty.h	(revision 149964)
+++ include/libiberty.h	(working copy)
@@ -100,7 +100,7 @@
    declaration without arguments.  If it is 0, we checked and failed
    to find the declaration so provide a fully prototyped one.  If it
    is 1, we found it so don't provide any declaration at all.  */
-#if !HAVE_DECL_BASENAME
+#if !HAVE_BASENAME
 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined
(__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined
(__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) ||
defined (HAVE_DECL_BASENAME)
 extern char *basename (const char *);
 #else
Index: libcpp/configure
===================================================================
--- libcpp/configure	(revision 149964)
+++ libcpp/configure	(working copy)
@@ -4330,7 +4330,109 @@
 
 done
 
+
+for ac_func in basename
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares
$ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+else
    ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4730,8 +4832,110 @@
 
 done
 
+
+for ac_func in basename
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares
$ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
 fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
 
+fi
+done
+
+fi
+
 # Checks for typedefs, structures, and compiler characteristics.
 echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
@@ -6341,76 +6545,6 @@
 
 
 fi
-echo "$as_me:$LINENO: checking whether basename is declared" >&5
-echo $ECHO_N "checking whether basename is declared... $ECHO_C" >&6
-if test "${ac_cv_have_decl_basename+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-#ifndef basename
-  char *p = (char *) basename;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_have_decl_basename=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_have_decl_basename=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl_basename" >&5
-echo "${ECHO_T}$ac_cv_have_decl_basename" >&6
-if test $ac_cv_have_decl_basename = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME 1
-_ACEOF
-
-
-else
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME 0
-_ACEOF
-
-
-fi
 echo "$as_me:$LINENO: checking whether errno is declared" >&5
 echo $ECHO_N "checking whether errno is declared... $ECHO_C" >&6
 if test "${ac_cv_have_decl_errno+set}" = set; then
Index: libcpp/configure.ac
===================================================================
--- libcpp/configure.ac	(revision 149964)
+++ libcpp/configure.ac	(working copy)
@@ -59,10 +59,12 @@
    AC_LANG(C)
    AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
 	stdlib.h strings.h string.h sys/file.h unistd.h)
+   AC_CHECK_FUNCS(basename)
 else
    AC_LANG(C++)
    AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
 	stdlib.h strings.h string.h sys/file.h unistd.h)
+   AC_CHECK_FUNCS(basename)
 fi
 
 # Checks for typedefs, structures, and compiler characteristics.
@@ -81,7 +83,7 @@
   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
   putchar_unlocked putc_unlocked)
 AC_CHECK_FUNCS(libcpp_UNLOCKED_FUNCS)
-AC_CHECK_DECLS(m4_split(m4_normalize(abort asprintf basename errno
getopt \
+AC_CHECK_DECLS(m4_split(m4_normalize(abort asprintf errno getopt \
   libcpp_UNLOCKED_FUNCS vasprintf)))
 
 # Checks for library functions.
Index: libcpp/config.in
===================================================================
--- libcpp/config.in	(revision 149964)
+++ libcpp/config.in	(working copy)
@@ -22,6 +22,9 @@
    */
 #undef HAVE_ALLOCA_H
 
+/* Define to 1 if you have the `basename' function. */
+#undef HAVE_BASENAME
+
 /* Define to 1 if you have the `clearerr_unlocked' function. */
 #undef HAVE_CLEARERR_UNLOCKED
 
@@ -33,10 +36,6 @@
    don't. */
 #undef HAVE_DECL_ASPRINTF
 
-/* Define to 1 if you have the declaration of `basename', and to 0 if
you
-   don't. */
-#undef HAVE_DECL_BASENAME
-
 /* Define to 1 if you have the declaration of `clearerr_unlocked', and
to 0 if
    you don't. */
 #undef HAVE_DECL_CLEARERR_UNLOCKED


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-27 12:53 ` Jason Merrill
  2009-08-31 16:07   ` Jerry Quinn
@ 2009-09-03 23:20   ` Alexandre Oliva
  1 sibling, 0 replies; 34+ messages in thread
From: Alexandre Oliva @ 2009-09-03 23:20 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jerry Quinn, gcc, Pedro Lamarão

On Aug 27, 2009, Jason Merrill <jason@redhat.com> wrote:

> On 08/15/2009 10:12 AM, Jerry Quinn wrote:
>> Building with --enable-build-with-cxx fails to bootstrap as follows:
>> 
>> x86_64-unknown-linux-gnu/32/libstdc++-v3/libsupc++/eh_alloc.o differs
>> ...

> Do you know why r149964 makes a difference?

No idea if it's related, but I started getting -fcompare-debug failures
a while ago, and eventually I tracked it down to -frandom-seed -derived
mangled symbol names.

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-08-31 16:07   ` Jerry Quinn
@ 2009-09-14 15:54     ` Jason Merrill
  2009-09-21 17:06       ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-09-14 15:54 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: gcc, Pedro Lamarão

On 08/31/2009 12:57 AM, Jerry Quinn wrote:
> On Thu, 2009-08-27 at 00:24 -0400, Jason Merrill wrote:
>> Do you know why r149964 makes a difference?

I understand now.  The patch changed the anonymous namespace name to use 
get_file_function_name in all cases, where previously we were using the 
same name in all translation units.  This was necessary to avoid 
treating types in the anonymous namespace in two different translation 
units as equivalent for typeinfo comparison.

Your patch deals with the fake anonymous namespace inserted for 
mangling, but doesn't deal with real anonymous namespaces, which will be 
incorrectly treated as identical with your patch.

I think the way to go with this is to revert the compiler bits of 
r149964, not mess with mangle.c at all, and insert the initial * if the 
typeinfo name won't have TREE_PUBLIC set, since that's precisely the 
property we want to mirror in comparison.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-14 15:54     ` Jason Merrill
@ 2009-09-21 17:06       ` Jason Merrill
  2009-09-21 18:43         ` Jerry Quinn
  2009-09-22 11:04         ` Jerry Quinn
  0 siblings, 2 replies; 34+ messages in thread
From: Jason Merrill @ 2009-09-21 17:06 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: GCC

On 09/14/2009 11:54 AM, Jason Merrill wrote:
> I think the way to go with this is to revert the compiler bits of
> r149964, not mess with mangle.c at all, and insert the initial * if the
> typeinfo name won't have TREE_PUBLIC set, since that's precisely the
> property we want to mirror in comparison.

Thoughts?  Another concern I have is that adding an initial * breaks 
simple demangling of type_info::name(), so I'd like to find another way 
of marking it for pointer comparison.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-21 17:06       ` Jason Merrill
@ 2009-09-21 18:43         ` Jerry Quinn
  2009-09-21 19:27           ` Jason Merrill
  2009-09-22 11:04         ` Jerry Quinn
  1 sibling, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-09-21 18:43 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC

On Mon, 2009-09-21 at 13:06 -0400, Jason Merrill wrote:
> On 09/14/2009 11:54 AM, Jason Merrill wrote:
> > I think the way to go with this is to revert the compiler bits of
> > r149964, not mess with mangle.c at all, and insert the initial * if the
> > typeinfo name won't have TREE_PUBLIC set, since that's precisely the
> > property we want to mirror in comparison.
> 
> Thoughts?  Another concern I have is that adding an initial * breaks 
> simple demangling of type_info::name(), so I'd like to find another way 
> of marking it for pointer comparison.

Sorry, it took me a while to get back to this.  I started an
implementation following the path you described above and am trying it
now.

Another approach could be to use 2 different names for anonymous
namespaces that should and should not be compared by pointer.  I don't
like the speed implications, but it might work.

Jerry



^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-21 18:43         ` Jerry Quinn
@ 2009-09-21 19:27           ` Jason Merrill
  0 siblings, 0 replies; 34+ messages in thread
From: Jason Merrill @ 2009-09-21 19:27 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: GCC

On 09/21/2009 02:43 PM, Jerry Quinn wrote:
> Another approach could be to use 2 different names for anonymous
> namespaces that should and should not be compared by pointer.  I don't
> like the speed implications, but it might work.

Any type that involves the anonymous namespace should be compared by 
pointer; I'm not sure where the two different names would be.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-21 17:06       ` Jason Merrill
  2009-09-21 18:43         ` Jerry Quinn
@ 2009-09-22 11:04         ` Jerry Quinn
  2009-09-22 13:40           ` Jason Merrill
  1 sibling, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-09-22 11:04 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC

On Mon, 2009-09-21 at 13:06 -0400, Jason Merrill wrote:
> On 09/14/2009 11:54 AM, Jason Merrill wrote:
> > I think the way to go with this is to revert the compiler bits of
> > r149964, not mess with mangle.c at all, and insert the initial * if the
> > typeinfo name won't have TREE_PUBLIC set, since that's precisely the
> > property we want to mirror in comparison.
> 
> Thoughts?  Another concern I have is that adding an initial * breaks 
> simple demangling of type_info::name(), so I'd like to find another way 
> of marking it for pointer comparison.

What if we have type_info::name() be smart?  I.e.

const char* name() { return name[0] == '*' ? name + 1 : name; }

Then the * can still be a flag indicating compare by pointer.

Jerry


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-22 11:04         ` Jerry Quinn
@ 2009-09-22 13:40           ` Jason Merrill
  2009-09-23 13:23             ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-09-22 13:40 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: GCC

On 09/22/2009 07:04 AM, Jerry Quinn wrote:
> On Mon, 2009-09-21 at 13:06 -0400, Jason Merrill wrote:
>> On 09/14/2009 11:54 AM, Jason Merrill wrote:
>>> I think the way to go with this is to revert the compiler bits of
>>> r149964, not mess with mangle.c at all, and insert the initial * if the
>>> typeinfo name won't have TREE_PUBLIC set, since that's precisely the
>>> property we want to mirror in comparison.
>>
>> Thoughts?  Another concern I have is that adding an initial * breaks
>> simple demangling of type_info::name(), so I'd like to find another way
>> of marking it for pointer comparison.
>
> What if we have type_info::name() be smart?  I.e.
>
> const char* name() { return name[0] == '*' ? name + 1 : name; }
>
> Then the * can still be a flag indicating compare by pointer.

I like it.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-22 13:40           ` Jason Merrill
@ 2009-09-23 13:23             ` Jerry Quinn
  2009-09-23 15:05               ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-09-23 13:23 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC

On Tue, 2009-09-22 at 09:40 -0400, Jason Merrill wrote:
> On 09/22/2009 07:04 AM, Jerry Quinn wrote:
> > On Mon, 2009-09-21 at 13:06 -0400, Jason Merrill wrote:
> >> On 09/14/2009 11:54 AM, Jason Merrill wrote:
> >>> I think the way to go with this is to revert the compiler bits of
> >>> r149964, not mess with mangle.c at all, and insert the initial * if the
> >>> typeinfo name won't have TREE_PUBLIC set, since that's precisely the
> >>> property we want to mirror in comparison.
> >>
> >> Thoughts?  Another concern I have is that adding an initial * breaks
> >> simple demangling of type_info::name(), so I'd like to find another way
> >> of marking it for pointer comparison.
> >
> > What if we have type_info::name() be smart?  I.e.
> >
> > const char* name() { return name[0] == '*' ? name + 1 : name; }
> >
> > Then the * can still be a flag indicating compare by pointer.
> 
> I like it.

I'm trying the following in cp/rtti.c, but I get a segfault compiling 
testsuite/g++.dg/debug/dwarf2/pr41063.C

Removing the TREE_PUBLIC code fixes the segfault, so it's definitely
related.  I also tried using an arbitrary string for name_string, but I
get the same segfault.  It seems like something is expecting the name to
be exactly in synch with the decl.

I'm not really sure how everything fits together here.  Am I missing
something obvious?

tinfo_base_init (tinfo_s *ti, tree target)
{
  tree init = NULL_TREE;
  tree name_decl;
  tree vtable_ptr;

  {
    tree name_name;

    /* Generate the NTBS array variable.  */
    tree name_type = build_cplus_array_type
		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
		     NULL_TREE);
    tree name_string = tinfo_name (target);

    /* Determine the name of the variable -- and remember with which
       type it is associated.  */
    name_name = mangle_typeinfo_string_for_type (target);
    TREE_TYPE (name_name) = target;

    name_decl = build_lang_decl (VAR_DECL, name_name, name_type);
    SET_DECL_ASSEMBLER_NAME (name_decl, name_name);
    DECL_ARTIFICIAL (name_decl) = 1;
    DECL_IGNORED_P (name_decl) = 1;
    TREE_READONLY (name_decl) = 1;
    TREE_STATIC (name_decl) = 1;
    DECL_EXTERNAL (name_decl) = 0;
    DECL_TINFO_P (name_decl) = 1;
    set_linkage_according_to_type (target, name_decl);
    import_export_decl (name_decl);
    if (!TREE_PUBLIC (name_decl))
      {
    	/* Inject '*' at start of name to force pointer comparison.  */
    	int len = TREE_STRING_LENGTH (name_string);
    	char* buf = (char*) XNEWVEC (char, len + 1);
    	buf[0] = '*';
    	memcpy (buf + 1, TREE_STRING_POINTER (name_string), len);
    	name_string = build_string (len + 1, buf);
    	XDELETEVEC (buf);
      }
    DECL_INITIAL (name_decl) = name_string;
    mark_used (name_decl);
    pushdecl_top_level_and_finish (name_decl, name_string);
  }


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-23 13:23             ` Jerry Quinn
@ 2009-09-23 15:05               ` Jason Merrill
  2009-10-24  4:53                 ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-09-23 15:05 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: GCC

On 09/23/2009 09:22 AM, Jerry Quinn wrote:
> I'm not really sure how everything fits together here.  Am I missing
> something obvious?

I notice that you're missing the fix_string_type that tinfo_name does. 
But I'd rather not duplicate the code that creates the STRING_CST; 
better to delay the call to tinfo_name and add the * there.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-09-23 15:05               ` Jason Merrill
@ 2009-10-24  4:53                 ` Jerry Quinn
  2009-10-26 13:54                   ` Jakub Jelinek
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-10-24  4:53 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC, gcc-patches

On Wed, 2009-09-23 at 11:05 -0400, Jason Merrill wrote:
> On 09/23/2009 09:22 AM, Jerry Quinn wrote:
> > I'm not really sure how everything fits together here.  Am I missing
> > something obvious?
> 
> I notice that you're missing the fix_string_type that tinfo_name does. 
> But I'd rather not duplicate the code that creates the STRING_CST; 
> better to delay the call to tinfo_name and add the * there.
> 
> Jason

Hi, Jason,

Sorry, it took me a while to get back to this.

Here's the latest patch I have updated to today's tree.  It fixes
bootstrap, but there are a number of testsuite failures.  They all
appear to plugin test failures similar to below.  I don't know if this
is related to my patch or is caused by some other issue when building
with --enable-build-with-cxx.

PR 40923 is about the bootstrap problem, and I've attached the patch
there as well.

Jerry


Executing on build: gcc -g
-O2 /home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite/g
++.dg/plugin/dumb_plugin.c -I.
-I/home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite
-I/home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite/../../gcc
-I/home/jlquinn/gcc/dev/build/trunk-cxx/gcc/testsuite/g++/../../../gcc
-I/home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite/../../include
-I/home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite/../../libcpp/include
-DIN_GCC -fPIC -shared -o dumb_plugin.so    (timeout = 300)
set_ld_library_path_env_vars:
ld_library_path=.:/home/jlquinn/gcc/dev/build/trunk-cxx/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs:/home/jlquinn/gcc/dev/build/trunk-cxx/x86_64-unknown-linux-gnu/./libstdc++-v3/src/.libs:/home/jlquinn/gcc/dev/build/trunk-cxx/gcc:/home/jlquinn/gcc/dev/build/trunk-cxx/gcc/32
Executing on host: /home/jlquinn/gcc/dev/build/trunk-cxx/gcc/testsuite/g
++/../../g++ -B/home/jlquinn/gcc/dev/build/trunk-cxx/gcc/testsuite/g
++/../../ /home/jlquinn/gcc/dev/gcc-in-cxx/gcc/testsuite/g
++.dg/plugin/dumb-plugin-test-1.C  -nostdinc++
-I/home/jlquinn/gcc/dev/build/trunk-cxx/x86_64-unknown-linux-gnu/libstdc
++-v3/include/x86_64-unknown-linux-gnu
-I/home/jlquinn/gcc/dev/build/trunk-cxx/x86_64-unknown-linux-gnu/libstdc
++-v3/include -I/home/jlquinn/gcc/dev/gcc-in-cxx/libstdc++-v3/libsupc++
-I/home/jlquinn/gcc/dev/gcc-in-cxx/libstdc++-v3/include/backward
-I/home/jlquinn/gcc/dev/gcc-in-cxx/libstdc++-v3/testsuite/util
-fmessage-length=0 -fplugin=./dumb_plugin.so -O
-fplugin-arg-dumb_plugin-ref-pass-name=ccp
-fplugin-arg-dumb_plugin-ref-pass-instance-num=1  -S  -o
dumb-plugin-test-1.s    (timeout = 300)
cc1plus: error: Cannot load plugin ./dumb_plugin.so
./dumb_plugin.so: undefined symbol: tree_check_failed
compiler exited with status 1
output is:
cc1plus: error: Cannot load plugin ./dumb_plugin.so
./dumb_plugin.so: undefined symbol: tree_check_failed

FAIL: g++.dg/plugin/dumb-plugin-test-1.C -fplugin=./dumb_plugin.so
(test for warnings, line 10)


Patch below:


Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 153489)
+++ gcc/cp/rtti.c	(working copy)
@@ -102,7 +102,7 @@
 static GTY (()) VEC(tinfo_s,gc) *tinfo_descs;
 
 static tree ifnonnull (tree, tree);
-static tree tinfo_name (tree);
+static tree tinfo_name (tree, bool);
 static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t);
 static tree throw_bad_cast (void);
 static tree throw_bad_typeid (void);
@@ -349,16 +349,31 @@
   return exp;
 }
 
-/* Generate the NTBS name of a type.  */
+/* Generate the NTBS name of a type.  If MARK_PRIVATE, put a '*' in
front so that
+   comparisons will be done by pointer rather than string comparison.
*/
 static tree
-tinfo_name (tree type)
+tinfo_name (tree type, bool mark_private)
 {
   const char *name;
+  int length;
   tree name_string;
 
-  name = mangle_type_string_for_rtti (type);
-  name_string = fix_string_type (build_string (strlen (name) + 1,
name));
-  return name_string;
+  name = mangle_type_string (type);
+  length = strlen (name);
+
+  if (mark_private)
+    {
+      /* Inject '*' at beginning of name to force pointer comparison.
*/
+      char* buf = (char*) XNEWVEC (char, length + 1);
+      buf[0] = '*';
+      memcpy (buf + 1, name, length);
+      name_string = build_string (length + 1, buf);
+      XDELETEVEC (buf);
+    }
+  else
+    name_string = build_string (length + 1, name);
+
+  return fix_string_type (name_string);
 }
 
 /* Return a VAR_DECL for the internal ABI defined type_info object for
@@ -839,13 +854,13 @@
   tree vtable_ptr;
 
   {
-    tree name_name;
+    tree name_name, name_string;
 
     /* Generate the NTBS array variable.  */
     tree name_type = build_cplus_array_type
 		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
 		     NULL_TREE);
-    tree name_string = tinfo_name (target);
+    //    tree name_string = tinfo_name (target);
 
     /* Determine the name of the variable -- and remember with which
        type it is associated.  */
@@ -862,6 +877,7 @@
     DECL_TINFO_P (name_decl) = 1;
     set_linkage_according_to_type (target, name_decl);
     import_export_decl (name_decl);
+    name_string = tinfo_name (target, !TREE_PUBLIC (name_decl));
     DECL_INITIAL (name_decl) = name_string;
     mark_used (name_decl);
     pushdecl_top_level_and_finish (name_decl, name_string);
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 153489)
+++ gcc/cp/mangle.c	(working copy)
@@ -105,10 +105,6 @@
 
 static GTY (()) globals G;
 
-/* Whether or not to pretend that a static function is in an anonymous
-   namespace.  */
-static bool fake_anon_scope;
-
 /* The obstack on which we build mangled names.  */
 static struct obstack *mangle_obstack;
 
@@ -734,20 +730,6 @@
     }
 }
 
-/* Since we now use strcmp to compare typeinfos on all targets because
of
-   the RTLD_LOCAL problem, we need to munge the typeinfo name used for
-   local classes of static functions to fix g++.dg/abi/local1.C.  We do
-   that by pretending that the function is in an anonymous namespace.
*/
-
-static bool
-needs_fake_anon (const_tree decl)
-{
-  /* Pretend there's an anonymous namespace right around a static
-     function if we're mangling for RTTI.  */
-  return (fake_anon_scope && !TREE_PUBLIC (decl)
-	  && TREE_CODE (decl) == FUNCTION_DECL);
-}
-
 /* Lambdas can have a bit more context for mangling, specifically
VAR_DECL
    or PARM_DECL context, which doesn't belong in DECL_CONTEXT.  */
 
@@ -791,18 +773,13 @@
 
   context = decl_mangling_context (decl);
 
-  gcc_assert (context != NULL_TREE);
-
-  /* If we need a fake anonymous namespace, force the nested name path.
*/
-  if (needs_fake_anon (decl) && context == global_namespace)
-    context = error_mark_node;
-
   /* A decl in :: or ::std scope is treated specially.  The former is
      mangled using <unscoped-name> or <unscoped-template-name>, the
      latter with a special substitution.  Also, a name that is
      directly in a local function scope is also mangled with
      <unscoped-name> rather than a full <nested-name>.  */
-  if (context == global_namespace
+  if (context == NULL
+      || context == global_namespace
       || DECL_NAMESPACE_STD_P (context)
       || (ignore_local_scope && TREE_CODE (context) == FUNCTION_DECL))
     {
@@ -820,9 +797,6 @@
     }
   else
     {
-      if (context == error_mark_node)
-	context = global_namespace;
-
       /* Handle local names, unless we asked not to (that is, invoked
 	 under <local-name>, to handle only the part of the name under
 	 the local scope).  */
@@ -835,10 +809,10 @@
 	     directly in that function's scope, either decl or one of
 	     its enclosing scopes.  */
 	  tree local_entity = decl;
-	  while (context != global_namespace)
+	  while (context != NULL && context != global_namespace)
 	    {
 	      /* Make sure we're always dealing with decls.  */
-	      if (TYPE_P (context))
+	      if (context != NULL && TYPE_P (context))
 		context = TYPE_NAME (context);
 	      /* Is this a function?  */
 	      if (TREE_CODE (context) == FUNCTION_DECL
@@ -883,6 +857,7 @@
       /* If not, it should be either in the global namespace, or
directly
 	 in a local function scope.  */
       gcc_assert (context == global_namespace
+		  || context != NULL
 		  || TREE_CODE (context) == FUNCTION_DECL);
 
       write_unqualified_name (decl);
@@ -954,9 +929,6 @@
     {
       /* No, just use <prefix>  */
       write_prefix (DECL_CONTEXT (decl));
-      if (needs_fake_anon (decl))
-	/* Pretend this static function is in an anonymous namespace.  */
-	write_source_name (get_anonymous_namespace_name ());
       write_unqualified_name (decl);
     }
   write_char ('E');
@@ -2921,10 +2893,6 @@
   name_base = obstack_alloc (&name_obstack, 0);
 }
 
-/* Done with mangling. If WARN is true, and the name of G.entity will
-   be mangled differently in a future version of the ABI, issue a
-   warning.  */
-
 static void
 finish_mangling_internal (const bool warn)
 {
@@ -3011,18 +2979,15 @@
   SET_DECL_ASSEMBLER_NAME (decl, id);
 }
 
-/* Generate the mangled representation of TYPE for the typeinfo name.
*/
+/* Generate the mangled representation of TYPE.  */
 
 const char *
-mangle_type_string_for_rtti (const tree type)
+mangle_type_string (const tree type)
 {
   const char *result;
 
   start_mangling (type);
-  /* Mangle in a fake anonymous namespace if necessary.  */
-  fake_anon_scope = true;
   write_type (type);
-  fake_anon_scope = false;
   result = finish_mangling (/*warn=*/false);
   if (DEBUG_MANGLE)
     fprintf (stderr, "mangle_type_string = '%s'\n\n", result);
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 153489)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -4507,7 +4507,6 @@
 extern tree perform_qualification_conversions	(tree, tree);
 
 /* in name-lookup.c */
-extern tree get_anonymous_namespace_name	(void);
 extern tree pushdecl				(tree);
 extern tree pushdecl_maybe_friend		(tree, bool);
 extern void maybe_push_cleanup_level		(tree);
@@ -5288,7 +5287,7 @@
 /* in mangle.c */
 extern void init_mangle				(void);
 extern void mangle_decl				(tree);
-extern const char *mangle_type_string_for_rtti	(tree);
+extern const char *mangle_type_string		(tree);
 extern tree mangle_typeinfo_for_type		(tree);
 extern tree mangle_typeinfo_string_for_type	(tree);
 extern tree mangle_vtbl_for_type		(tree);
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 153489)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -69,7 +69,12 @@
     {
       /* The anonymous namespace has to have a unique name
 	 if typeinfo objects are being compared by name.  */
-      anonymous_namespace_name = get_file_function_name ("N");
+      if (! flag_weak || ! SUPPORTS_ONE_ONLY)
+       anonymous_namespace_name = get_file_function_name ("N");
+      else
+       /* The demangler expects anonymous namespaces to be called
+          something starting with '_GLOBAL__N_'.  */
+       anonymous_namespace_name = get_identifier ("_GLOBAL__N_1");
     }
   return anonymous_namespace_name;
 }
Index: libstdc++-v3/libsupc++/tinfo2.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo2.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo2.cc	(working copy)
@@ -37,7 +37,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
 #else
-  return __builtin_strcmp (name (), arg.name ()) < 0;
+  return (name ()[0] == '*' && arg.name()[0] == '*')
+    ? name () < arg.name ()
+    :  __builtin_strcmp (name (), arg.name ()) < 0;
 #endif
 }
 
Index: libstdc++-v3/libsupc++/typeinfo
===================================================================
--- libstdc++-v3/libsupc++/typeinfo	(revision 153489)
+++ libstdc++-v3/libsupc++/typeinfo	(working copy)
@@ -94,7 +94,7 @@
     /** Returns an @e implementation-defined byte string; this is not
      *  portable between compilers!  */
     const char* name() const
-    { return __name; }
+    { return __name[0] == '*' ? __name + 1 : __name; }
 
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
     // In old abi, or when weak symbols are not supported, there can
@@ -110,12 +110,15 @@
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
     bool before(const type_info& __arg) const
-    { return __builtin_strcmp (__name, __arg.__name) < 0; }
+    { return (__name[0] == '*' && __arg.__name[0] == '*')
+	? __name < __arg.__name
+	: __builtin_strcmp (__name, __arg.__name) < 0; }
 
     bool operator==(const type_info& __arg) const
     {
       return ((__name == __arg.__name)
-	      || __builtin_strcmp (__name, __arg.__name) == 0);
+	      || (__name[0] != '*' && __arg.__name[0] != '*' &&
+		  __builtin_strcmp (__name, __arg.__name) == 0));
     }
   #else
     // On some targets we can rely on type_info's NTBS being unique,
Index: libstdc++-v3/libsupc++/tinfo.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
@@ -41,7 +41,9 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
 #else
-  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
0);
+  return (&arg == this)
+    || (name ()[0] != '*' && arg.name ()[0] != '*'
+	&& (__builtin_strcmp (name (), arg.name ()) == 0));
 #endif
 }
 


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-24  4:53                 ` Jerry Quinn
@ 2009-10-26 13:54                   ` Jakub Jelinek
  2009-10-26 14:06                     ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jakub Jelinek @ 2009-10-26 13:54 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Jason Merrill, GCC, gcc-patches

Hi!

Just some random comments:

On Sat, Oct 24, 2009 at 12:10:52AM -0400, Jerry Quinn wrote:
> +  if (mark_private)
> +    {
> +      /* Inject '*' at beginning of name to force pointer comparison.
> */
> +      char* buf = (char*) XNEWVEC (char, length + 1);
> +      buf[0] = '*';
> +      memcpy (buf + 1, name, length);
> +      name_string = build_string (length + 1, buf);
> +      XDELETEVEC (buf);

You could as well use XALLOCAVEC (char, length + 1) and remove
XDELETEVEC.  No need to cast the result of XNEWVEC or XALLOCAVEC to
char *.  And, the formatting is wrong, space goes after char, no space
between * and buf.

>      /* Generate the NTBS array variable.  */
>      tree name_type = build_cplus_array_type
>  		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
>  		     NULL_TREE);
> -    tree name_string = tinfo_name (target);
> +    //    tree name_string = tinfo_name (target);

This should be removed, rather than commented out.

> @@ -2921,10 +2893,6 @@
>    name_base = obstack_alloc (&name_obstack, 0);
>  }
>  
> -/* Done with mangling. If WARN is true, and the name of G.entity will
> -   be mangled differently in a future version of the ABI, issue a
> -   warning.  */
> -
>  static void
>  finish_mangling_internal (const bool warn)
>  {

Why are you removing the comment?

> @@ -3011,18 +2979,15 @@
>    SET_DECL_ASSEMBLER_NAME (decl, id);
>  }
>  
> -/* Generate the mangled representation of TYPE for the typeinfo name.
> */
> +/* Generate the mangled representation of TYPE.  */
>  
>  const char *
> -mangle_type_string_for_rtti (const tree type)
> +mangle_type_string (const tree type)

Why this change?

>      bool operator==(const type_info& __arg) const
>      {
>        return ((__name == __arg.__name)
> -	      || __builtin_strcmp (__name, __arg.__name) == 0);
> +	      || (__name[0] != '*' && __arg.__name[0] != '*' &&
> +		  __builtin_strcmp (__name, __arg.__name) == 0));

I see no point in both tests for * here, just __name[0] != '*'
should be enough (or __arg.__name[0] != '*').  If one string starts with *
and the other doesn't, strcmp will return non-0.

> --- libstdc++-v3/libsupc++/tinfo.cc	(revision 153489)
> +++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
> @@ -41,7 +41,9 @@
>  #if __GXX_MERGED_TYPEINFO_NAMES
>    return name () == arg.name ();
>  #else
> -  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
> 0);
> +  return (&arg == this)
> +    || (name ()[0] != '*' && arg.name ()[0] != '*'
> +	&& (__builtin_strcmp (name (), arg.name ()) == 0));
>  #endif
>  }

Likewise.

	Jakub

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-26 13:54                   ` Jakub Jelinek
@ 2009-10-26 14:06                     ` Jason Merrill
  2009-10-28 14:26                       ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-10-26 14:06 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jerry Quinn, GCC, gcc-patches

On 10/26/2009 07:14 AM, Jakub Jelinek wrote:
>> -/* Generate the mangled representation of TYPE for the typeinfo name.
>> */
>> +/* Generate the mangled representation of TYPE.  */
>>
>>   const char *
>> -mangle_type_string_for_rtti (const tree type)
>> +mangle_type_string (const tree type)
>
> Why this change?

This change is part of reverting my earlier fake namespace patch.

I agree with Jakub's other comments, though.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-26 14:06                     ` Jason Merrill
@ 2009-10-28 14:26                       ` Jerry Quinn
  2009-10-28 17:34                         ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-10-28 14:26 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jakub Jelinek, GCC, gcc-patches

On Mon, 2009-10-26 at 09:53 -0400, Jason Merrill wrote:
> On 10/26/2009 07:14 AM, Jakub Jelinek wrote:
> >> -/* Generate the mangled representation of TYPE for the typeinfo name.
> >> */
> >> +/* Generate the mangled representation of TYPE.  */
> >>
> >>   const char *
> >> -mangle_type_string_for_rtti (const tree type)
> >> +mangle_type_string (const tree type)
> >
> > Why this change?
> 
> This change is part of reverting my earlier fake namespace patch.
> 
> I agree with Jakub's other comments, though.
> 
> Jason

Here's the updated patch.


2009-10-28  Jerry Quinn  <jlquinn@optonline.net>

	* mangle.c (mangle_type_string_for_rtti): Revert r149964.
	(needs_fake_anon): Likewise.
	(write_name): Likewise.
	(write_nested_name): Likewise.
	* cp-tree.h (mangle_type_string_for_rtti): Likewise.
	(get_anonymous_namespace): Likewise.
	* name-lookup.c (get_anonymous_namespace_name): Likewise.
	* rtti.c (tinfo_name): Insert '*' in front of private names.
	(tinfo_base_init): Use it.

2009-10-28  Jerry Quinn  <jlquinn@optonline.net>

	* libsupc++/tinfo.cc (operator=(const type_info&)): Compare by
	pointer if name begins with '*'.
	* libsupc++/typeinfo (type_info::name()): Likewise.
	* libsupc++/tinfo2.cc (before):  Likewise.

Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 153489)
+++ gcc/cp/rtti.c	(working copy)
@@ -102,7 +102,7 @@
 static GTY (()) VEC(tinfo_s,gc) *tinfo_descs;
 
 static tree ifnonnull (tree, tree);
-static tree tinfo_name (tree);
+static tree tinfo_name (tree, bool);
 static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t);
 static tree throw_bad_cast (void);
 static tree throw_bad_typeid (void);
@@ -349,16 +349,30 @@
   return exp;
 }
 
-/* Generate the NTBS name of a type.  */
+/* Generate the NTBS name of a type.  If MARK_PRIVATE, put a '*' in
front so that
+   comparisons will be done by pointer rather than string comparison.
*/
 static tree
-tinfo_name (tree type)
+tinfo_name (tree type, bool mark_private)
 {
   const char *name;
+  int length;
   tree name_string;
 
-  name = mangle_type_string_for_rtti (type);
-  name_string = fix_string_type (build_string (strlen (name) + 1,
name));
-  return name_string;
+  name = mangle_type_string (type);
+  length = strlen (name);
+
+  if (mark_private)
+    {
+      /* Inject '*' at beginning of name to force pointer comparison.
*/
+      char* buf = (char*) XALLOCAVEC (char, length + 1);
+      buf[0] = '*';
+      memcpy (buf + 1, name, length);
+      name_string = build_string (length + 1, buf);
+    }
+  else
+    name_string = build_string (length + 1, name);
+
+  return fix_string_type (name_string);
 }
 
 /* Return a VAR_DECL for the internal ABI defined type_info object for
@@ -839,13 +853,12 @@
   tree vtable_ptr;
 
   {
-    tree name_name;
+    tree name_name, name_string;
 
     /* Generate the NTBS array variable.  */
     tree name_type = build_cplus_array_type
 		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
 		     NULL_TREE);
-    tree name_string = tinfo_name (target);
 
     /* Determine the name of the variable -- and remember with which
        type it is associated.  */
@@ -862,6 +875,7 @@
     DECL_TINFO_P (name_decl) = 1;
     set_linkage_according_to_type (target, name_decl);
     import_export_decl (name_decl);
+    name_string = tinfo_name (target, !TREE_PUBLIC (name_decl));
     DECL_INITIAL (name_decl) = name_string;
     mark_used (name_decl);
     pushdecl_top_level_and_finish (name_decl, name_string);
Index: gcc/cp/ChangeLog
===================================================================
--- gcc/cp/ChangeLog	(revision 153489)
+++ gcc/cp/ChangeLog	(working copy)
@@ -1,3 +1,15 @@
+2009-10-28  Jerry Quinn  <jlquinn@optonline.net>
+
+	* mangle.c (mangle_type_string_for_rtti): Revert r149964.
+	(needs_fake_anon): Likewise.
+	(write_name): Likewise.
+	(write_nested_name): Likewise.
+	* cp-tree.h (mangle_type_string_for_rtti): Likewise.
+	(get_anonymous_namespace): Likewise.
+	* name-lookup.c (get_anonymous_namespace_name): Likewise.
+	* rtti.c (tinfo_name): Insert '*' in front of private names.
+	(tinfo_base_init): Use it.
+
 2009-10-21  Jakub Jelinek  <jakub@redhat.com>
 
 	* mangle.c (finish_mangling_get_identifier): Use
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 153489)
+++ gcc/cp/mangle.c	(working copy)
@@ -105,10 +105,6 @@
 
 static GTY (()) globals G;
 
-/* Whether or not to pretend that a static function is in an anonymous
-   namespace.  */
-static bool fake_anon_scope;
-
 /* The obstack on which we build mangled names.  */
 static struct obstack *mangle_obstack;
 
@@ -734,20 +730,6 @@
     }
 }
 
-/* Since we now use strcmp to compare typeinfos on all targets because
of
-   the RTLD_LOCAL problem, we need to munge the typeinfo name used for
-   local classes of static functions to fix g++.dg/abi/local1.C.  We do
-   that by pretending that the function is in an anonymous namespace.
*/
-
-static bool
-needs_fake_anon (const_tree decl)
-{
-  /* Pretend there's an anonymous namespace right around a static
-     function if we're mangling for RTTI.  */
-  return (fake_anon_scope && !TREE_PUBLIC (decl)
-	  && TREE_CODE (decl) == FUNCTION_DECL);
-}
-
 /* Lambdas can have a bit more context for mangling, specifically
VAR_DECL
    or PARM_DECL context, which doesn't belong in DECL_CONTEXT.  */
 
@@ -791,18 +773,13 @@
 
   context = decl_mangling_context (decl);
 
-  gcc_assert (context != NULL_TREE);
-
-  /* If we need a fake anonymous namespace, force the nested name path.
*/
-  if (needs_fake_anon (decl) && context == global_namespace)
-    context = error_mark_node;
-
   /* A decl in :: or ::std scope is treated specially.  The former is
      mangled using <unscoped-name> or <unscoped-template-name>, the
      latter with a special substitution.  Also, a name that is
      directly in a local function scope is also mangled with
      <unscoped-name> rather than a full <nested-name>.  */
-  if (context == global_namespace
+  if (context == NULL
+      || context == global_namespace
       || DECL_NAMESPACE_STD_P (context)
       || (ignore_local_scope && TREE_CODE (context) == FUNCTION_DECL))
     {
@@ -820,9 +797,6 @@
     }
   else
     {
-      if (context == error_mark_node)
-	context = global_namespace;
-
       /* Handle local names, unless we asked not to (that is, invoked
 	 under <local-name>, to handle only the part of the name under
 	 the local scope).  */
@@ -835,10 +809,10 @@
 	     directly in that function's scope, either decl or one of
 	     its enclosing scopes.  */
 	  tree local_entity = decl;
-	  while (context != global_namespace)
+	  while (context != NULL && context != global_namespace)
 	    {
 	      /* Make sure we're always dealing with decls.  */
-	      if (TYPE_P (context))
+	      if (context != NULL && TYPE_P (context))
 		context = TYPE_NAME (context);
 	      /* Is this a function?  */
 	      if (TREE_CODE (context) == FUNCTION_DECL
@@ -883,6 +857,7 @@
       /* If not, it should be either in the global namespace, or
directly
 	 in a local function scope.  */
       gcc_assert (context == global_namespace
+		  || context != NULL
 		  || TREE_CODE (context) == FUNCTION_DECL);
 
       write_unqualified_name (decl);
@@ -954,9 +929,6 @@
     {
       /* No, just use <prefix>  */
       write_prefix (DECL_CONTEXT (decl));
-      if (needs_fake_anon (decl))
-	/* Pretend this static function is in an anonymous namespace.  */
-	write_source_name (get_anonymous_namespace_name ());
       write_unqualified_name (decl);
     }
   write_char ('E');
@@ -3011,18 +2983,15 @@
   SET_DECL_ASSEMBLER_NAME (decl, id);
 }
 
-/* Generate the mangled representation of TYPE for the typeinfo name.
*/
+/* Generate the mangled representation of TYPE.  */
 
 const char *
-mangle_type_string_for_rtti (const tree type)
+mangle_type_string (const tree type)
 {
   const char *result;
 
   start_mangling (type);
-  /* Mangle in a fake anonymous namespace if necessary.  */
-  fake_anon_scope = true;
   write_type (type);
-  fake_anon_scope = false;
   result = finish_mangling (/*warn=*/false);
   if (DEBUG_MANGLE)
     fprintf (stderr, "mangle_type_string = '%s'\n\n", result);
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 153489)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -4507,7 +4507,6 @@
 extern tree perform_qualification_conversions	(tree, tree);
 
 /* in name-lookup.c */
-extern tree get_anonymous_namespace_name	(void);
 extern tree pushdecl				(tree);
 extern tree pushdecl_maybe_friend		(tree, bool);
 extern void maybe_push_cleanup_level		(tree);
@@ -5288,7 +5287,7 @@
 /* in mangle.c */
 extern void init_mangle				(void);
 extern void mangle_decl				(tree);
-extern const char *mangle_type_string_for_rtti	(tree);
+extern const char *mangle_type_string		(tree);
 extern tree mangle_typeinfo_for_type		(tree);
 extern tree mangle_typeinfo_string_for_type	(tree);
 extern tree mangle_vtbl_for_type		(tree);
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 153489)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -62,14 +62,19 @@
 
 /* Initialize anonymous_namespace_name if necessary, and return it.  */
 
-tree
+static tree
 get_anonymous_namespace_name (void)
 {
   if (!anonymous_namespace_name)
     {
       /* The anonymous namespace has to have a unique name
 	 if typeinfo objects are being compared by name.  */
-      anonymous_namespace_name = get_file_function_name ("N");
+      if (! flag_weak || ! SUPPORTS_ONE_ONLY)
+       anonymous_namespace_name = get_file_function_name ("N");
+      else
+       /* The demangler expects anonymous namespaces to be called
+          something starting with '_GLOBAL__N_'.  */
+       anonymous_namespace_name = get_identifier ("_GLOBAL__N_1");
     }
   return anonymous_namespace_name;
 }
Index: libstdc++-v3/libsupc++/tinfo2.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo2.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo2.cc	(working copy)
@@ -37,7 +37,8 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
 #else
-  return __builtin_strcmp (name (), arg.name ()) < 0;
+  return (name ()[0] == '*') ? name () < arg.name ()
+    :  __builtin_strcmp (name (), arg.name ()) < 0;
 #endif
 }
 
Index: libstdc++-v3/libsupc++/typeinfo
===================================================================
--- libstdc++-v3/libsupc++/typeinfo	(revision 153489)
+++ libstdc++-v3/libsupc++/typeinfo	(working copy)
@@ -94,7 +94,7 @@
     /** Returns an @e implementation-defined byte string; this is not
      *  portable between compilers!  */
     const char* name() const
-    { return __name; }
+    { return __name[0] == '*' ? __name + 1 : __name; }
 
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
     // In old abi, or when weak symbols are not supported, there can
@@ -110,12 +110,15 @@
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
     bool before(const type_info& __arg) const
-    { return __builtin_strcmp (__name, __arg.__name) < 0; }
+    { return (__name[0] == '*' && __arg.__name[0] == '*')
+	? __name < __arg.__name
+	: __builtin_strcmp (__name, __arg.__name) < 0; }
 
     bool operator==(const type_info& __arg) const
     {
       return ((__name == __arg.__name)
-	      || __builtin_strcmp (__name, __arg.__name) == 0);
+	      || (__name[0] != '*' &&
+		  __builtin_strcmp (__name, __arg.__name) == 0));
     }
   #else
     // On some targets we can rely on type_info's NTBS being unique,
Index: libstdc++-v3/libsupc++/tinfo.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
@@ -41,7 +41,8 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
 #else
-  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
0);
+  return (&arg == this)
+    || (name ()[0] != '*' && (__builtin_strcmp (name (), arg.name ())
== 0));
 #endif
 }
 
Index: libstdc++-v3/ChangeLog
===================================================================
--- libstdc++-v3/ChangeLog	(revision 153489)
+++ libstdc++-v3/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-10-28  Jerry Quinn  <jlquinn@optonline.net>
+
+	* libsupc++/tinfo.cc (operator=(const type_info&)): Compare by
+	pointer if name begins with '*'.
+	* libsupc++/typeinfo (type_info::name()): Likewise.
+	* libsupc++/tinfo2.cc (before):  Likewise.
+
 009-10-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
         PR libstdc++/41773


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-28 14:26                       ` Jerry Quinn
@ 2009-10-28 17:34                         ` Jason Merrill
  2009-10-29 10:35                           ` Jerry Quinn
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-10-28 17:34 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Jakub Jelinek, GCC, gcc-patches

On 10/28/2009 07:29 AM, Jerry Quinn wrote:
> +  length = strlen (name);
> +  if (mark_private)
> +      name_string = build_string (length + 1, buf);
> +  else
> +    name_string = build_string (length + 1, name);

These two calls shouldn't be using the same length.  I think the +1 in 
the old code was unnecessary, so you can just remove it from the second 
call.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-28 17:34                         ` Jason Merrill
@ 2009-10-29 10:35                           ` Jerry Quinn
  2009-10-29 12:46                             ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Quinn @ 2009-10-29 10:35 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jakub Jelinek, GCC, gcc-patches

On Wed, 2009-10-28 at 11:35 -0400, Jason Merrill wrote:
> On 10/28/2009 07:29 AM, Jerry Quinn wrote:
> > +  length = strlen (name);
> > +  if (mark_private)
> > +      name_string = build_string (length + 1, buf);
> > +  else
> > +    name_string = build_string (length + 1, name);
> 
> These two calls shouldn't be using the same length.  I think the +1 in 
> the old code was unnecessary, so you can just remove it from the second 
> call.

And here is the latest patch.

Index: gcc/cp/rtti.c
===================================================================
--- gcc/cp/rtti.c	(revision 153489)
+++ gcc/cp/rtti.c	(working copy)
@@ -102,7 +102,7 @@
 static GTY (()) VEC(tinfo_s,gc) *tinfo_descs;
 
 static tree ifnonnull (tree, tree);
-static tree tinfo_name (tree);
+static tree tinfo_name (tree, bool);
 static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t);
 static tree throw_bad_cast (void);
 static tree throw_bad_typeid (void);
@@ -349,16 +349,30 @@
   return exp;
 }
 
-/* Generate the NTBS name of a type.  */
+/* Generate the NTBS name of a type.  If MARK_PRIVATE, put a '*' in
front so that
+   comparisons will be done by pointer rather than string comparison.
*/
 static tree
-tinfo_name (tree type)
+tinfo_name (tree type, bool mark_private)
 {
   const char *name;
+  int length;
   tree name_string;
 
-  name = mangle_type_string_for_rtti (type);
-  name_string = fix_string_type (build_string (strlen (name) + 1,
name));
-  return name_string;
+  name = mangle_type_string (type);
+  length = strlen (name);
+
+  if (mark_private)
+    {
+      /* Inject '*' at beginning of name to force pointer comparison.
*/
+      char* buf = (char*) XALLOCAVEC (char, length + 1);
+      buf[0] = '*';
+      memcpy (buf + 1, name, length);
+      name_string = build_string (length + 1, buf);
+    }
+  else
+    name_string = build_string (length, name);
+
+  return fix_string_type (name_string);
 }
 
 /* Return a VAR_DECL for the internal ABI defined type_info object for
@@ -839,13 +853,12 @@
   tree vtable_ptr;
 
   {
-    tree name_name;
+    tree name_name, name_string;
 
     /* Generate the NTBS array variable.  */
     tree name_type = build_cplus_array_type
 		     (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
 		     NULL_TREE);
-    tree name_string = tinfo_name (target);
 
     /* Determine the name of the variable -- and remember with which
        type it is associated.  */
@@ -862,6 +875,7 @@
     DECL_TINFO_P (name_decl) = 1;
     set_linkage_according_to_type (target, name_decl);
     import_export_decl (name_decl);
+    name_string = tinfo_name (target, !TREE_PUBLIC (name_decl));
     DECL_INITIAL (name_decl) = name_string;
     mark_used (name_decl);
     pushdecl_top_level_and_finish (name_decl, name_string);
Index: gcc/cp/ChangeLog
===================================================================
--- gcc/cp/ChangeLog	(revision 153489)
+++ gcc/cp/ChangeLog	(working copy)
@@ -1,3 +1,15 @@
+2009-10-28  Jerry Quinn  <jlquinn@optonline.net>
+
+	* mangle.c (mangle_type_string_for_rtti): Revert r149964.
+	(needs_fake_anon): Likewise.
+	(write_name): Likewise.
+	(write_nested_name): Likewise.
+	* cp-tree.h (mangle_type_string_for_rtti): Likewise.
+	(get_anonymous_namespace): Likewise.
+	* name-lookup.c (get_anonymous_namespace_name): Likewise.
+	* rtti.c (tinfo_name): Insert '*' in front of private names.
+	(tinfo_base_init): Use it.
+
 2009-10-21  Jakub Jelinek  <jakub@redhat.com>
 
 	* mangle.c (finish_mangling_get_identifier): Use
Index: gcc/cp/mangle.c
===================================================================
--- gcc/cp/mangle.c	(revision 153489)
+++ gcc/cp/mangle.c	(working copy)
@@ -105,10 +105,6 @@
 
 static GTY (()) globals G;
 
-/* Whether or not to pretend that a static function is in an anonymous
-   namespace.  */
-static bool fake_anon_scope;
-
 /* The obstack on which we build mangled names.  */
 static struct obstack *mangle_obstack;
 
@@ -734,20 +730,6 @@
     }
 }
 
-/* Since we now use strcmp to compare typeinfos on all targets because
of
-   the RTLD_LOCAL problem, we need to munge the typeinfo name used for
-   local classes of static functions to fix g++.dg/abi/local1.C.  We do
-   that by pretending that the function is in an anonymous namespace.
*/
-
-static bool
-needs_fake_anon (const_tree decl)
-{
-  /* Pretend there's an anonymous namespace right around a static
-     function if we're mangling for RTTI.  */
-  return (fake_anon_scope && !TREE_PUBLIC (decl)
-	  && TREE_CODE (decl) == FUNCTION_DECL);
-}
-
 /* Lambdas can have a bit more context for mangling, specifically
VAR_DECL
    or PARM_DECL context, which doesn't belong in DECL_CONTEXT.  */
 
@@ -791,18 +773,13 @@
 
   context = decl_mangling_context (decl);
 
-  gcc_assert (context != NULL_TREE);
-
-  /* If we need a fake anonymous namespace, force the nested name path.
*/
-  if (needs_fake_anon (decl) && context == global_namespace)
-    context = error_mark_node;
-
   /* A decl in :: or ::std scope is treated specially.  The former is
      mangled using <unscoped-name> or <unscoped-template-name>, the
      latter with a special substitution.  Also, a name that is
      directly in a local function scope is also mangled with
      <unscoped-name> rather than a full <nested-name>.  */
-  if (context == global_namespace
+  if (context == NULL
+      || context == global_namespace
       || DECL_NAMESPACE_STD_P (context)
       || (ignore_local_scope && TREE_CODE (context) == FUNCTION_DECL))
     {
@@ -820,9 +797,6 @@
     }
   else
     {
-      if (context == error_mark_node)
-	context = global_namespace;
-
       /* Handle local names, unless we asked not to (that is, invoked
 	 under <local-name>, to handle only the part of the name under
 	 the local scope).  */
@@ -835,10 +809,10 @@
 	     directly in that function's scope, either decl or one of
 	     its enclosing scopes.  */
 	  tree local_entity = decl;
-	  while (context != global_namespace)
+	  while (context != NULL && context != global_namespace)
 	    {
 	      /* Make sure we're always dealing with decls.  */
-	      if (TYPE_P (context))
+	      if (context != NULL && TYPE_P (context))
 		context = TYPE_NAME (context);
 	      /* Is this a function?  */
 	      if (TREE_CODE (context) == FUNCTION_DECL
@@ -883,6 +857,7 @@
       /* If not, it should be either in the global namespace, or
directly
 	 in a local function scope.  */
       gcc_assert (context == global_namespace
+		  || context != NULL
 		  || TREE_CODE (context) == FUNCTION_DECL);
 
       write_unqualified_name (decl);
@@ -954,9 +929,6 @@
     {
       /* No, just use <prefix>  */
       write_prefix (DECL_CONTEXT (decl));
-      if (needs_fake_anon (decl))
-	/* Pretend this static function is in an anonymous namespace.  */
-	write_source_name (get_anonymous_namespace_name ());
       write_unqualified_name (decl);
     }
   write_char ('E');
@@ -3011,18 +2983,15 @@
   SET_DECL_ASSEMBLER_NAME (decl, id);
 }
 
-/* Generate the mangled representation of TYPE for the typeinfo name.
*/
+/* Generate the mangled representation of TYPE.  */
 
 const char *
-mangle_type_string_for_rtti (const tree type)
+mangle_type_string (const tree type)
 {
   const char *result;
 
   start_mangling (type);
-  /* Mangle in a fake anonymous namespace if necessary.  */
-  fake_anon_scope = true;
   write_type (type);
-  fake_anon_scope = false;
   result = finish_mangling (/*warn=*/false);
   if (DEBUG_MANGLE)
     fprintf (stderr, "mangle_type_string = '%s'\n\n", result);
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 153489)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -4507,7 +4507,6 @@
 extern tree perform_qualification_conversions	(tree, tree);
 
 /* in name-lookup.c */
-extern tree get_anonymous_namespace_name	(void);
 extern tree pushdecl				(tree);
 extern tree pushdecl_maybe_friend		(tree, bool);
 extern void maybe_push_cleanup_level		(tree);
@@ -5288,7 +5287,7 @@
 /* in mangle.c */
 extern void init_mangle				(void);
 extern void mangle_decl				(tree);
-extern const char *mangle_type_string_for_rtti	(tree);
+extern const char *mangle_type_string		(tree);
 extern tree mangle_typeinfo_for_type		(tree);
 extern tree mangle_typeinfo_string_for_type	(tree);
 extern tree mangle_vtbl_for_type		(tree);
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 153489)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -62,14 +62,19 @@
 
 /* Initialize anonymous_namespace_name if necessary, and return it.  */
 
-tree
+static tree
 get_anonymous_namespace_name (void)
 {
   if (!anonymous_namespace_name)
     {
       /* The anonymous namespace has to have a unique name
 	 if typeinfo objects are being compared by name.  */
-      anonymous_namespace_name = get_file_function_name ("N");
+      if (! flag_weak || ! SUPPORTS_ONE_ONLY)
+       anonymous_namespace_name = get_file_function_name ("N");
+      else
+       /* The demangler expects anonymous namespaces to be called
+          something starting with '_GLOBAL__N_'.  */
+       anonymous_namespace_name = get_identifier ("_GLOBAL__N_1");
     }
   return anonymous_namespace_name;
 }
Index: libstdc++-v3/libsupc++/tinfo2.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo2.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo2.cc	(working copy)
@@ -37,7 +37,8 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
 #else
-  return __builtin_strcmp (name (), arg.name ()) < 0;
+  return (name ()[0] == '*') ? name () < arg.name ()
+    :  __builtin_strcmp (name (), arg.name ()) < 0;
 #endif
 }
 
Index: libstdc++-v3/libsupc++/typeinfo
===================================================================
--- libstdc++-v3/libsupc++/typeinfo	(revision 153489)
+++ libstdc++-v3/libsupc++/typeinfo	(working copy)
@@ -94,7 +94,7 @@
     /** Returns an @e implementation-defined byte string; this is not
      *  portable between compilers!  */
     const char* name() const
-    { return __name; }
+    { return __name[0] == '*' ? __name + 1 : __name; }
 
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
     // In old abi, or when weak symbols are not supported, there can
@@ -110,12 +110,15 @@
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
     bool before(const type_info& __arg) const
-    { return __builtin_strcmp (__name, __arg.__name) < 0; }
+    { return (__name[0] == '*' && __arg.__name[0] == '*')
+	? __name < __arg.__name
+	: __builtin_strcmp (__name, __arg.__name) < 0; }
 
     bool operator==(const type_info& __arg) const
     {
       return ((__name == __arg.__name)
-	      || __builtin_strcmp (__name, __arg.__name) == 0);
+	      || (__name[0] != '*' &&
+		  __builtin_strcmp (__name, __arg.__name) == 0));
     }
   #else
     // On some targets we can rely on type_info's NTBS being unique,
Index: libstdc++-v3/libsupc++/tinfo.cc
===================================================================
--- libstdc++-v3/libsupc++/tinfo.cc	(revision 153489)
+++ libstdc++-v3/libsupc++/tinfo.cc	(working copy)
@@ -41,7 +41,8 @@
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
 #else
-  return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) ==
0);
+  return (&arg == this)
+    || (name ()[0] != '*' && (__builtin_strcmp (name (), arg.name ())
== 0));
 #endif
 }
 
Index: libstdc++-v3/ChangeLog
===================================================================
--- libstdc++-v3/ChangeLog	(revision 153489)
+++ libstdc++-v3/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2009-10-28  Jerry Quinn  <jlquinn@optonline.net>
+
+	* libsupc++/tinfo.cc (operator=(const type_info&)): Compare by
+	pointer if name begins with '*'.
+	* libsupc++/typeinfo (type_info::name()): Likewise.
+	* libsupc++/tinfo2.cc (before):  Likewise.
+
 009-10-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
         PR libstdc++/41773


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-29 10:35                           ` Jerry Quinn
@ 2009-10-29 12:46                             ` Jason Merrill
  2009-11-01  5:02                               ` Jason Merrill
  0 siblings, 1 reply; 34+ messages in thread
From: Jason Merrill @ 2009-10-29 12:46 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Jakub Jelinek, GCC, gcc-patches

On 10/29/2009 01:06 AM, Jerry Quinn wrote:
> And here is the latest patch.

This one is OK, thanks.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: enable-build-with-cxx bootstrap compare broken by r149964
  2009-10-29 12:46                             ` Jason Merrill
@ 2009-11-01  5:02                               ` Jason Merrill
  0 siblings, 0 replies; 34+ messages in thread
From: Jason Merrill @ 2009-11-01  5:02 UTC (permalink / raw)
  To: Jerry Quinn; +Cc: Jakub Jelinek, GCC, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 54 bytes --]

Here's the fix I'm checking in for the * path.

Jason

[-- Attachment #2: tinfo-null.patch --]
[-- Type: text/x-patch, Size: 1506 bytes --]

commit 16463ef55164d4668d6f1eeb150974452e1dbe58
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Oct 31 18:10:17 2009 -0400

    	* rtti.c (tinfo_name): Fix lengths for private case.

diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 2926f97..c7af74a 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -364,10 +364,10 @@ tinfo_name (tree type, bool mark_private)
   if (mark_private)
     {
       /* Inject '*' at beginning of name to force pointer comparison.  */
-      char* buf = (char*) XALLOCAVEC (char, length + 1);
+      char* buf = (char*) XALLOCAVEC (char, length + 2);
       buf[0] = '*';
-      memcpy (buf + 1, name, length);
-      name_string = build_string (length + 1, buf);
+      memcpy (buf + 1, name, length + 1);
+      name_string = build_string (length + 2, buf);
     }
   else
     name_string = build_string (length + 1, name);
diff --git a/gcc/testsuite/g++.dg/rtti/typeid9.C b/gcc/testsuite/g++.dg/rtti/typeid9.C
new file mode 100644
index 0000000..381252d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/rtti/typeid9.C
@@ -0,0 +1,21 @@
+// Test that the typeid name for a local class is properly null-terminated.
+// { dg-do run }
+
+#include <string.h>
+#include <typeinfo>
+#include <stdio.h>
+
+int f()
+{
+  struct A {}; struct B {};
+  const std::type_info &ti = typeid(A);
+  const std::type_info &ti2 = typeid(B);
+  puts (ti.name());
+  puts (ti2.name());
+  return strcmp (ti.name(), "Z1fvE1A") || strcmp (ti2.name(), "Z1fvE1B");
+}
+
+int main()
+{
+  return f();
+}


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2009-11-01  5:02 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-15 18:11 enable-build-with-cxx bootstrap compare broken by r149964 Jerry Quinn
2009-08-17 21:51 ` Jason Merrill
2009-08-18  9:33   ` Jerry Quinn
2009-08-18 19:50     ` Richard Henderson
2009-08-19  2:57       ` Jason Merrill
2009-08-20  8:48       ` Jerry Quinn
2009-08-20 12:33         ` Dave Korn
2009-08-20 13:28           ` Jerry Quinn
2009-08-20 13:37             ` Dave Korn
2009-08-20 14:09               ` Jerry Quinn
2009-08-20 16:51                 ` Dave Korn
2009-08-20 19:26                   ` Dave Korn
2009-08-21 23:01                   ` Jerry Quinn
2009-08-21 23:15                     ` Richard Henderson
2009-08-22 16:33                       ` Jerry Quinn
2009-08-27 12:53 ` Jason Merrill
2009-08-31 16:07   ` Jerry Quinn
2009-09-14 15:54     ` Jason Merrill
2009-09-21 17:06       ` Jason Merrill
2009-09-21 18:43         ` Jerry Quinn
2009-09-21 19:27           ` Jason Merrill
2009-09-22 11:04         ` Jerry Quinn
2009-09-22 13:40           ` Jason Merrill
2009-09-23 13:23             ` Jerry Quinn
2009-09-23 15:05               ` Jason Merrill
2009-10-24  4:53                 ` Jerry Quinn
2009-10-26 13:54                   ` Jakub Jelinek
2009-10-26 14:06                     ` Jason Merrill
2009-10-28 14:26                       ` Jerry Quinn
2009-10-28 17:34                         ` Jason Merrill
2009-10-29 10:35                           ` Jerry Quinn
2009-10-29 12:46                             ` Jason Merrill
2009-11-01  5:02                               ` Jason Merrill
2009-09-03 23:20   ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).