3 ms·
The problem I see with that is what happens if you have dynamic library C (globe) and application A that’s rebuilt but library B (which sits between A and C) ha
by vlovich123 5y ago
The problem I see with that is what happens if you have dynamic library C (globe) and application A that’s rebuilt but library B (which sits between A and C) hasn’t. Now you have a linking error. What happens if you rebuild B and C but A hasn’t been rebuilt. That means B still needs to know to set up aliases for back compat (which you won’t find out until runtime). What if library B is yielding the changed ABI type and A is feeding it to C?
I think it’s a useful tool but I don’t think it’s an ABI versioning panacea (even c++ adoption of inline namespaces within libraries is limited with the standard library being the only place I’ve seen it used in a meaningful way).
- duped 5y agothe solution is to stop linking libraries globally
- wizzwizz4 5y agoThen you raise the number of libraries in your program to some power > 1, due to the proliferation of versions. Hope you're using compile-time LTO with code deduplication!
- duped 5y agoMost libraries are not shared, even when they are ostensibly "shared" libraries. Plus disk is cheap, it seems dumb to optimize for it in the 21st century. You don't need LTO for dead code elimination.
- KerrAvon 5y agoA number of libraries are in fact shared. And RAM is not cheap when considered across the entire OS, and if every process has their own copy of the library, that’s a lot of RAM eaten up by needless duplication.
- vlovich123 5y agoIs that necessarily true in a world of zram?
- salawat 5y agoCPU cycles are still quite expensive, I assure you. It adds up.
- duped 5y agoIt's negligible, for example : https://drewdevault.com/dynlib https://drewdevault.com/dynlib
- LegionMammal978 5y agoIMHO, the real solution is to avoid exposing opaque types from library C in the interface of library B. Obviously, some libraries do this anyway, so your criticism is valid. Library C's headers would likely need some #define to link to the old functions and types for compatibility. But transparent aliases are still very effective in the case of shallow dynamic-library dependency graphs (e.g., most open-source projects), even if, as you note, they aren't a panacea. (I'm not even sure there is one: there'll always be a Y2038 bug or TLS deprecation or whatever that library C needs to make a breaking change to fix.)
- noobermin 5y agoYou should mention that libraries already do this! That is a major argument for this proposal. Some libs already have these levels of indirection, this just adds it to the langauge as opposed to having to use pragmas or __attribute__((alias("_blah"))) everywhere.