title: Linking problems due to symbols with abi::cxx11?
body: <p>We recently caught a report because of <a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html" rel="noreferrer">GCC 5.1, libstdc++ and Dual ABI</a>. It seems <a href="http://llvm.org/bugs/show_bug.cgi?id=23529" rel="noreferrer">Clang is not aware of the GCC inline namespace changes</a>, so it generates code based on one set of namespaces or symbols, while GCC used another set of namespaces or symbols. At link time, there are problems due to missing symbols.</p>
  
  <p>If I am parsing the <a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html" rel="noreferrer">Dual ABI</a> page correctly, it looks like a matter of pivoting on <code>_GLIBCXX_USE_CXX11_ABI</code> and <code>abi::cxx11</code> with some additional hardships. More reading is available on Red Hat's blog at <a href="http://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/" rel="noreferrer">GCC5 and the C++11 ABI</a> and <a href="http://allanmcrae.com/2015/06/the-case-of-gcc-5-1-and-the-two-c-abis/" rel="noreferrer">The Case of GCC-5.1 and the Two C++ ABIs</a>.</p>
  
  <p>Below is from a Ubuntu 15 machine. The machine provides GCC 5.2.1.</p>
  
  <pre><code>$ cat test.cxx
  #include &lt;string&gt;
  
  std::string foo __attribute__ ((visibility ("default")));
  std::string bar __attribute__ ((visibility ("default")));
  
  $ g++ -g3 -O2 -shared test.cxx -o test.so
  
  $ nm test.so | grep _Z3
  ...
  0000201c B _Z3barB5cxx11
  00002034 B _Z3fooB5cxx11
  
  $ echo _Z3fooB5cxx11 _Z3barB5cxx11 | c++filt 
  foo[abi:cxx11] bar[abi:cxx11]
  </code></pre>
  
  <p>How can I generate a binary with symbols using both decorations ("coexistence" as the Red Hat blog calls it)?</p>
  
  <p>Or, what are the options available to us?</p>
  
  <hr>
  
  <p>I'm trying to achieve an "it just works" for users. I don't care if there are two weak symbols with two different behaviors (<code>std::string</code> lacks copy-on-write, while <code>std::string[abi:cxx11]</code> provides copy-on-write). Or, one can be an alias for the other.</p>
  
  <p>Debian has a boatload of similar bugs at <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=libstdc%2B%2B-cxx11;users=debian-gcc@lists.debian.org" rel="noreferrer">Debian Bug report logs: Bugs tagged libstdc++-cxx11</a>. Their solution was to rebuild everything under the new ABI, but it did not handle the corner case of mixing/matching compilers modulo the ABI changes.</p>
  
  <p>In the Apple world, I think this is close to a fat binary. But I'm not sure what to do in the Linux/GCC world. Finally, we don't control how the distro's build the library, and we don't control what compilers are used to link an applications with the library.</p>