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 }