Boost logo

Boost :

Subject: Re: [boost] [filesystem] 1.49 linking with c++0x
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2012-07-12 21:32:54


On Jul 12, 2012, at 7:55 AM, Sebastian Redl wrote:

> On 12.07.2012 12:01, Andrey Semashev wrote:
>> On Thursday 12 July 2012 10:21:12 Sebastian Redl wrote:
>>> You cannot safely mix and match C++03 and C++11 code with GCC no matter what libraries you use. The standard library itself breaks binary compatibility between the two versions. Boost builds on the standard library. So no change in Filesystem is going to rescue binary compatibility for you.
>> But you can build and link both C++03 and C++11 programs against libstdc++,
>> can't you? So it must either contain both ABIs or have some compatibility
>> layer. Why is it not possible to use both ABIs then?
>>
> Just did a bit of searching and found that the GCC developers actually delayed the ABI split so far, so it was actually possible to have compatible 03 and 11 versions, except that a breakage now slipped into 4.7 (apparently earlier than indented). The reason why you can still use the same libstdc++ is that the breakage is in std::list, and there is no precompiled std::list code in the dynamic library.
>
> http://docs.redhat.com/docs/en-US/Red_Hat_Developer_Toolset/1/html/1.0_Release_Notes/ch-Known_Issues.html

This is very interesting and something I did not know would be a problem. This is almost as bad as 32 vs 64 bit libs and the library name should include the c++ version it works with. If you are using 3rd party libs that you cannot rebuild for c++11 then you a SOL.

Considering the ABI hasn't broken yet for GCC or (VS2010??), I would think boost should avoid breaking the boost ABI as well based upon a simple compile flag.

I would expect a failure earlier in the build process that clearly states that I am 'using the wrong header'... or 'boost was not built with c++11 feature X enabled'.

This could be solved by providing an implementation for both the versions of the few methods with broken ABI... create two files:

copy_file_03.cpp
copy_file_11.cpp

Compile them with different flags, and then link them both into the boost::filesystem library. Now you have one library that will work both ways without having to worry about 'duplicate symbols' created by trying to link two versions of boost_filesystem into the same exe simply to resolve one method.

At the very least these issues need to be clearly documented and a policy put in place for when, how, and why a boost library will break its ABI for C++11.

>
> Sebastian
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk