Linux static linking is dead?

前端 未结 6 2032
野性不改
野性不改 2020-11-28 19:42

In fact, -static gcc flag on Linux doesn\'t work now. Let me cite from the GNU libc FAQ:

2.22. Even statically linked programs need s

6条回答
  •  醉话见心
    2020-11-28 20:02

    Concerning that fact is there any reasonable way now to create a full-functioning static build on Linux or static linking is completely dead on Linux?

    I do not know where to find the historic references, but yes, static linking is dead on GNU systems. (I believe it died during the transition from libc4/libc5 to libc6/glibc 2.x.)

    The feature was deemed useless in light of:

    • Security vulnerabilities. Application which was statically linked doesn't even support upgrade of libc. If app was linked on system containing a lib vulnerability then it is going to be perpetuated within the statically linked executable.

    • Code bloat. If many statically linked applications are ran on the same system, standard libraries wouldn't be reused, since every application contains inside its own copy of everything. (Try du -sh /usr/lib to understand the extent of the problem.)

    Try digging LKML and glibc mail list archives from 10-15 years ago. I'm pretty sure long ago I have seen something related on LKML.

提交回复
热议问题