> These days, almost every C++ compiler uses the Itanium C++ ABI’s name mangling rules. The notable exception is MSVC, which uses a completely different format.
You stay classy, Microsoft.
> Its not just the grammar that’s huge, the symbols themselves are too. Here is a pretty big mangled C++ symbol from SpiderMonkey [...] That’s 355 bytes!
Here's a >4kB symbol I encountered while liberating some ebooks from an abandoned DRM app:
I believe Microsoft's mangling scheme is actually older than gcc's current one. While gcc changed its name mangling everywhere to a new one based on Intel's IA-64 ABI, MSVC probably kept its own unchanged from compiler release to compiler release. I don't recall the reason for gcc changing its name mangling; perhaps better standard compliance?
IIRC, the MSVC scheme has an annoying property, in that "class foo" and "struct foo" have different mangling, while they're supposed to be completely interchangeable according to the C++ standard (other than the default access being "private" for class and "public" for struct).
If you want some huge symbols, introduce Boost Lambda into a project. Doing a single for_each with a Boost Lambda can introduce symbols of several 100k.
Well, my memory was a bit wrong (it's been about 6 years since I last looked at this), and it's not as bad as I remember. It's not great, mind you, but here are the binary sizes for a simple program:
Boost Lambda (unstripped): 44176 bytes
Boost Lambda (stripped): 18808 bytes
C++11 Lambda (unstripped): 24896 bytes
C++11 Lambda (stripped): 14712 bytes
Test program is pretty simple:
#include <algorithm>
#include <iostream>
#include <vector>
#include <boost/lambda/lambda.hpp>
using namespace boost::lambda;
int main(int, const char**)
{
std::vector<int> v;
for (int i = 0; i < 100; ++i)
v.push_back(i);
//std::for_each(std::begin(v), std::end(v), std::cout << _1 << constant('\n'));
std::for_each(std::begin(v), std::end(v), [](int i) { std::cout << i << '\n'; });
return 0;
}
I'm using Boost 1.58.0 and GCC 5.4.0 with -std=c++1y flag only to get the numbers above.
>> These days, almost every C++ compiler uses the Itanium C++ ABI’s name mangling rules. The notable exception is MSVC, which uses a completely different format.
> You stay classy, Microsoft.
This is only true on the HN universe of clang, gcc and MSVC++ trio.
Out there in the real world, there are plenty of C++ compilers being used.
You stay classy, Microsoft.
> Its not just the grammar that’s huge, the symbols themselves are too. Here is a pretty big mangled C++ symbol from SpiderMonkey [...] That’s 355 bytes!
Here's a >4kB symbol I encountered while liberating some ebooks from an abandoned DRM app: