|
|
|
|
|
by Annatar
2821 days ago
|
|
The reason why static linking has been all but banned is security and bug fixes: with static linking, the bugs and performance issues are fused into the resulting binary; fixes to libc will require a complete re-build. If you're delivering static binaries for embedded firmware images, this will quickly turn into a security maintenance nightmare, especially for end users of the final product. Linking dynamically with libc will never be an issue on illumos- or any real UNIX-based operating system because libc includes all previous interface versions and can therefore guarantee that it is backward compatible. Long story short: develop and build your software on an illumos-based operating system like OmniOS or SmartOS and dynamically link only with libc and you won't have to worry about static linking for convenience delivery: link on the oldest version of SmartOS and sleep well at night knowing your application will work on the latest nightly build. As an added bonus, your binary will be smaller and the runtime linker will only mmap(2) the required code pages out of libc into memory. http://garrett.damore.org/2015/09/on-go-portability-and-syst... |
|
I am not from a software development background (I am kind of (Verilog), but am not much familiar with the best practices of software development). So you comment was quite insightful for me.
>The reason why static linking has been all but banned is security and bug fixes: with static linking, the bugs and performance issues are fused into the resulting binary; fixes to libc will require a complete re-build.
Wouldn't the same apply to the whole binary itself even if it is dynamically linked? What if the app itself has a security bug? Wouldn't the overhead to fix+recompile the statically linked binary be the same as that for dynamically linked?
[Or may be the problem is that the users with the binaries build with buggy musl-gcc need to be aware that there's a security risk, and that they need to download the fixed version I later re-deployed?]
> If you're delivering static binaries for embedded firmware images, this will quickly turn into a security maintenance nightmare, especially for end users of the final product.
Hmm, my goal is to deploy simple CLI apps. Here's an example of one[0] in progress. If someone wants to try this CLI app for Todoist, my goal is that they should be just able to download it and run.
> Linking dynamically with libc will never be an issue on illumos- or any real UNIX-based operating system because libc includes all previous interface versions and can therefore guarantee that it is backward compatible.
Do you know if I to use illumos/OmniOS/SmartOS (this is the first time I am hearing about these) on Travis CI? And how?
> Long story short: develop and build your software on an illumos-based operating system like OmniOS or SmartOS and dynamically link only with libc and you won't have to worry about static linking for convenience delivery: link on the oldest version of SmartOS and sleep well at night knowing your application will work on the latest nightly build.
Thanks! If I can do this on Travis CI (or any other auto-deployment solution via GitHub or even Gitlab), I am willing to give that a try. I am open to suggestions and pointers on how to do that.
> As an added bonus, your binary will be smaller and
+1
> the runtime linker will only mmap(2) the required code pages out of libc into memory.
That part, I did not understand :)
[0]: https://github.com/kaushalmodi/ntodo