Hi,
I came back to this from [libc++] Remove _LIBCPP_DISABLE_AVAILABILITY macro by ldionne · Pull Request #112952 · llvm/llvm-project · GitHub and noticed that this was left unanswered. I think this was around the time of the Discourse migration so that may be why this was lost.
Either way, libc++'s goal is always to be 100% ABI compatible, except in tiny corner cases where we evaluate that it won’t impact anyone. However, I don’t see how the changes in D91517 could break the ABI. I think the issue reported by @isuruf is slightly different.
Isuru notes that the facet structure in libc++ used to be ABCD, and now as of D91517 it is ABCFD, with a new set of fields in the middle.
Yes, but the word “structure” here is used a bit incorrectly. There is an array internal to the built library (.a
or .dylib
) that used to contain elements in order ABCD, and now it contains elements in order ABCFD. But that’s an implementation detail of the built library, and it doesn’t affect anything on its ABI boundary. That internal array gets passed around as a black box by the headers.
He notes crashes when mixing binaries built against before and after D91517 versions of libc++, which is fair enough and easy to understand.
Specifically, I think the problem that was reported is that if a program uses both an old libc++.a
and a new libc++.a
at the same time, then you may get crashes. In other words, running into issues with this requires having multiple copies of libc++ in the same program, which is indeed an ODR violation unless you’re very careful.
What’s happening is basically that the new libc++.a
is creating an array in order ABCFD, and then some other part of the program is processing it using a function taken from the old libc++.a
that expects it as ABCD. Or something along those lines. But if you had exactly one copy of the library in your program (as should be done), there would be no problem.
In particular, there is no backwards compatibility problem in the general sense: if you compiled your program against old headers and ran against an old libc++.dylib
, it works since the headers are passing the ABCD array as a black box and never reaching into it. If you now run the program against a new libc++.dylib
(e.g. you update your system and get a new version of the dylib but you don’t rebuild your program), the code instantiated from the headers are still passing an array around as a black box, except it now happens to be laid out as ABCFD. There is no problem as long as the headers don’t look into that “black box”, which AFAICT they don’t.