#20350: Work with gcc's new cxx11 abi
--------------------------------------+------------------------
       Reporter:  vbraun              |        Owner:
           Type:  defect              |       Status:  new
       Priority:  major               |    Milestone:  sage-7.2
      Component:  packages: standard  |   Resolution:
       Keywords:                      |    Merged in:
        Authors:                      |    Reviewers:
Report Upstream:  N/A                 |  Work issues:
         Branch:                      |       Commit:
   Dependencies:                      |     Stopgaps:
--------------------------------------+------------------------

Comment (by leif):

 Replying to [ticket:20350 vbraun]:
 > gcc-5 introduces a new cxx11 abi, and linking C++ libraries with
 different abi versions will cause missing `std::__cxx11` symbols like
 > {{{
 > undefined reference to `std::__cxx11::basic_string<char,
 std::char_traits<char>, std::allocator<char>
 >::push_back(char)@GLIBCXX_3.4.21'
 > }}}

 GCC's newer libstdc++ comes (by default at least) with a ''dual'' ABI, so
 there's no problem when older programs or libraries use the newer one
 (e.g. if we upgrade our GCC to 5.x or later and the system GCC is < 5.x).

 \\

 > This is an issue whenever we build our own gcc; Right now that means
 gcc-4.9.3 which only supports the old abi. So linking with any system C++
 library will fail, and there are various optional libraries that packages
 test for and link when available.

 The real problem arises from incompatibilites of (C++) libraries that
 expose functions whose signatures contain types like `std::string`,
 because the symbol names differ depending on whether the library was
 compiled using the old or the new ABI (same of course when compiling code
 ''using'' such libraries).  This leads to linker errors ''if a library and
 modules using it'' are compiled with different ABIs (but only if the
 modules ''actually use'' such functions).

 \\

 > Also, gcc-5 system installations may default to the old abi (e.g.
 Fedora), so we can't just do a version check. [...]

 Well, that's easy to figure out, and we can configure Sage's GCC (>= 5.x)
 accordingly: ;-)
 {{{
 #!sh
 GCC_CONFIGURE_CXX_ABI="--with-default-libstdcxx-abi="$(
 ($CXX -x c++ -S -o - - | awk '/.globl/{print
 $2!~/__cxx11/?"gcc4-compatible":"c++11"}') <<EOF
 #include <string>
 void foo(std::string s){}
 EOF
 }}}

 \\

 > Its clear that we must update our gcc to 5 if we ever want to be able to
 link to new-abi libraries. Then we could also match the abi by putting
 `-D_GLIBCXX_USE_CXX11_ABI=[0|1]` into the `CFLAGS`.

 `CXXFLAGS` (if respected by a package) that is, but see above.

--
Ticket URL: <https://trac.sagemath.org/ticket/20350#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to