[v3] namespace association re-work

Benjamin Kosnik bkoz@redhat.com
Sun Dec 18 11:05:00 GMT 2005


Yo people.

This patch re-works the libstdc++ includes and namespaces. In
particular, it changes the way libstdc++ uses namespace associations
(aka strong using) to implement the debug mode: instead of separate,
top-level namespaces, it uses a nested approach.

ie:

namespace __gnu_debug { }
namespace __gnu_norm { }

becomes:

namespace std
{
  namespace __gnu_debug { }
  namespace __gnu_norm { }
}

by doing this, the pernicious issues with std::swap
specialization in debug mode are now fixed. In a nutshell, libstdc++
runs with -D_GLIBCXX_DEBUG and without are now equivalent.

This will allow fixes for c++/16021 that require use of namespace
associations in a nested context.

This re-arrangement is on by default, and compatibility shims have
been put in to make sure that old exported symbols are mapped to the
new, nested symbols. Fortunately, only a few debug symbols were ever
exported. It is believed that this is compatible, ABI-wise.

In addition, there is a versioning mode, which is off by default. To
enable, configure with --enable-symvers=gnu-versioned-namespace. This
mode is most definitely not ABI-compatible, as it changes std:: to
std::_6 for linking purposes.

However, solutions of this type solve or partially solve
libstdc++/24660, libstdc++/21405, and libstdc++/21072

In general, I'm quite pleased with this approach, although initially I
was not thrilled by the namespace and macro combination. Frankly, I
don't see a way around this if we are to do a nested debug mode. Every
attempt was made to make the changes as non-invasive as possible. I
think the potential benefits are worth it.

I'd like to check this in, but will wait a bit for comments.

This has been tested pretty extensively.

tested x86/linux
tested x86/linux -D_GLIBCXX_DEBUG
tested x86/linux --enable-symvers=gnu-versioned-namespace
tested x86/linux --enable-symvers=gnu-versioned-namespace -D_GLIBCXX_DEBUG
tested x86/linux --disable-hosted-libstdcxx
tested x86/linux --enable-clocale=generic

-benjamin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.20051218-5.bz2
Type: application/x-bzip2
Size: 32187 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20051218/a8114692/attachment.bz2>


More information about the Libstdc++ mailing list