The name mangling schemes of C++ compilers vary, but they are documented publicl
ID: 654254 • Letter: T
Question
The name mangling schemes of C++ compilers vary, but they are documented publicly. Why aren't linkers made to decode a mangled symbol from an object file and attempt to find a mangled version via any of the mangling conventions across the other object files/static libraries? If linkers could do this, wouldn't it help alleviate the problem with C++ libraries that they have to be re-compiled by each compiler to have symbols that can be resolved?
List of mangling documentations I found:
MSVC++ mangling conventions
GCC un-mangler
MSVC++ un-mangling function documentation
LLVM mangle class
Explanation / Answer
Name mangling is a very small part of the problem.
Object layout is only defined in the C++ standard for a very restricted set of classes (essentially only standard layout types - and then only as much as the C standard does, alignment and padding are still to be considered). For anything that has virtuals, any form of non-trivial inheritance, mixed public and private members, etc. the standard doesn't say how they should be layed out in memory.
Two compilers can (and this is not purely hypothetical, this does happen in practice) return different values for sizeof(std::string) for instance. There is nothing in the standard that says: an std::string is represented like this in memory. So interoperability at the object file level doesn't exist.
Binary compatibility between C++ compilers is a much larger problem than just name mangling. You'd need to standardize much more than what is currently specified.