E
E
egor_spk2018-05-02 21:14:38
C++ / C#
egor_spk, 2018-05-02 21:14:38

How to achieve ABI stability?

Hello colleagues!
Recently, I have been closely studying the issue of ABI stability. I have developed two main approaches:

  • adhere to some recommendations for the chosen compiler, for example, Itanium C++ ABI ;
  • put stability into the design of the application, for example, use the pimpl idiom.

Regarding the 2nd approach, there were several questions that I would like to get answers to. Further questions imply that the public interface does not change and compatibility within the same compiler is required.
  1. Dynamic library loading (dlopen, LoadLibrary, Boost.DLL). Are the problems (at least there is no name corruption) ABI relevant for this case?
  2. Pimpl:
    • Does adding an abstract interface affect ABI stability (introducing vtables)?
    • How to beat template methods/template class?


Sorry for some confusion. I tried to be brief.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kamil Khamitov, 2018-05-02
@egor_spk

1 -- there is a mangled import in boost.dll
2 -- if we don't save every byte, then we don't
use template classes only on the client side.
Either C interface or classes with PIMPL stick out from the DLL.
And template helpers wrap on top of them.
Export / import of templates from dll is evil and is not supported by anyone except MSVC

V
Vitaly, 2018-05-02
@vt4a2h

In my opinion, the most stable way is to make a simple C interface for the lib and provide C++ wrappers that the user of your lib will compile himself. After that, all your problems will be solved :)
Another solution is to wait for the 23rd standard, where, according to rumors, the C++ ABI will be standardized. But this is a very optimistic expectation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question