[cfe-dev] May libc++ support symbol versioning?
David Chisnall via cfe-dev
cfe-dev at lists.llvm.org
Tue Feb 25 06:49:59 PST 2020
Hi,
I would be interested to know who is making that statement on behalf of
the FreeBSD project. We made a conscious decision *not* to use symbol
versioning for the FreeBSD build of libc++ when we imported it.
Symbol versioning allows you to provide versions for exported symbols.
This is a good solution for maintaining backwards compatibility in C
libraries, where the only things exported from a library are functions
(or, occasionally, globals) and it is often possible to provide
backwards-compatibility versions of functions. For example, FreeBSD
libc provides some compat versions of stat for callers that will provide
a smaller statbuf structure than the newer version of the API expects to
fill.
In contrast, C++ libraries export complex types and expect to inline a
large number of the operations on them. The boundary of a C++ library
is much more fuzzy. Types declared in libc++ headers become part of the
name mangling for any functions that take them as arguments. Symbol
versioning does not help with that at all.
Libc++ does provide a mechanism for incrementally changing the ABI. All
of the standard types are declared in the std::__v1 namespace. We could
provide the new versions in the std::__v2 namespace and conditionally
import either version into the std namespace depending on the
compilation options. That would allow code linked against libc++ today
to continue to use the old versions, but allow new code to adopt the new
versions, with the caveat that it would change name mangling of any
function that took a standard library type as arguments, so you would
not be able to mix a library built with old libc++ with one built
against new libc++.
This solution is not actually much better than FreeBSD bumping the
SONAME and relegating the old libc++ to a COMPAT version. I was under
the impression that this was the plan for FreeBSD 12, but apparently it
didn't happen. It is something that should definitely be done for
FreeBSD 13.
David
On 25/02/2020 06:30, Zhihao Yuan via cfe-dev wrote:
> Hi,
>
> I got message from FreeBSD about whether
> they can upgrade to V2 ABI. To summarize
> the discussion:
>
> FreeBSD is not willing to land an ABI
> break unless it is for the purpose of
> introducing symbol version because
> breaking libc++ ABI means breaking
> ABI in three actively supported
> FreeBSD versions. There is no such
> thing called "break in the next release."
>
> May libc++ support symbol versioning
> in V2 or a specific variant of ABI?
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> _______________________________________________
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list