by twblalock · 8y ago · 0 comments
This was understandable in a time when disk space was scarce, but it causes all kinds of dependency hell when you want to install programs that need different versions of the same library, or when you upgrade one of those libraries and break a bunch of programs.
Plan 9 got this right with static linking a long time ago: https://9p.io/wiki/plan9/why_static/index.html. Sadly this has still not been adopted by major Unixy operating systems. Flatpak and Snap seem promising for isolation of dependencies in Linux without requiring full containerization.
Compare that to trying to figure out which of your statically compiled applications happen to include the affected version of the library.
As with so many choices we need to make in software development, it doesn't distill down to one way simply being better. It's a trade off, and in this case it's not just for disk space, but also for maintainability and easily discovering how exposed you are with respect to security.
People manually build stuff. People also manually install binaries than have their own dependencies (even installed wireshark for Windows? I know for a long time, libpcap was installed separately as a sub-process during install). For example, probably 99% of the people that build their own toolchain for development and pushing to production. People also install separate package management systems (brew, cygwin) that might not have their update mechanisms automatically run, or are infrequently run.
This is a compilation and deployment strategy downside. You can mitigate (but not eliminate) this downside through a strong package management system that tracks all this (BTW, is there a package management system in current use that tracks statically compiled dependencies?), but only if users and administrators adhere to strict practices.
There are plenty of package management systems in current use where linking is an ideological or historical choice and has no relevance to security updates.
Similarly, increasingly many programs now ship an entire VM. Eg Eclipse has shipped with its own JRE for years now. Every Electron app comes bundled with a browser and a JS runtime, Dropbox includes Python and half its battery pack, and so on. Strangely, .NET is the odd one out, still requiring system wide installation. Well, at least it has a good backward compat story.
Sure, this makes installers huge, but nobody really cares about that anymore. Similarly the potential space and cache efficiency savings of two programs sharing the same iconv.dll is just not worth the headache.
Command line "package managers" like https://scoop.sh take full advantage of this trend by downloading these installers and not even running them. Instead, scoop just extracts their files into a directory somewhere deep in the homedir (= no admin rights needed) and assumes that said program is fully self-contained. In my opinion, this is lovely.
It's become my firm opinion that the concept of "installation" of applications is silly, causing far more trouble than it is worth.
.NET Core allows both system-wide side-by-side and local deployments of the framework.
Regarding side-by-side libraries, there is WinSxS
What about keeping libraries dynamic, but allowing different versions to co-exist? (basically, it boils down to considering different versions of the same lib as independent libraries)
If this worked, developers would have no incentive to upgrade library versions that are working properly. The number of programs on your system that share the same library version would decrease over time until most of them use different versions, so you will miss out on the advantage of dynamic linking anyway -- updating a library would only fix security holes in a subset of your programs. You might as well just statically link everything and call it a day.
Please don't. Especially if I don't have your source code.
A reduced amount of binaries to upgrade is only the tip of the iceberg.
Even if I have 10 programs using 10 different versions of the same library, dynamic linking is a better choice than static linking.
Because it allows security upgrades, independently of any collaboration with the vendors of these 10 programs.
The reason dependency hell arises is because there is a lack of discipline in setting the soname correctly according to a semantic versioning (i.e. someone change the interface without changing the soversion)
When soname is set correctly, there isn't really that much difference between /usr/lib and the GAC in Windows.