Conversation

can someone tell me why c++ compilers don't checksum class layouts to let the linker warn you if you've fucked up ABI compatibility? ocaml does this, works well
Quote Tweet
the answer is that i forgot to pass an option to my code generator, so half of the compiled code used one (up to date) class definition inline in the source file and the other half of the compiled code used another (outdated) class definition in the header file infuriating
Show this thread
8
77
Replying to
The biggest reason, I guess, is inability to reliably handle all the madness C++ ABI can conjure. Hell, you can break ABI without even changing class layout. My favorite example of this is making TrivialType class non-trivial.
1
Replying to
Not in the sense of ABI compatibility though. Compilers produce *some set of bytes* that *most often* works as expected, but sometimes still blows everything up. AFAIK there are no ABI analysis tools whatsoever (on the level where you check if ABIs for two _source_ files match).
2
I did hit an issue where enabling -ftrivial-auto-var-init=zero caused a minor change that broke the checks and I had to regenerate the ABI information. The failure was a very minor issue and I just applied a very blunt fix for the problem since this isn't relevant to us anyway.
1
2
source.android.com/devices/archit is some of the documentation. Maybe useful to someone as a starting point. It doesn't have much relevance to my work and my awareness of it is limited to my annoyance at the added build time (esp. clean builds) and this *one time* it had a false positive.
Show replies
Replying to and
Thanks a lot, I'd check it out! When I faced a similar problem (to enforce back/forward compatibility of some libraries with zero false negatives) I was only able to come up with a much coarser approach - to rely on compiler emitting the same bytes for ABI every time.
1