Linux static linking is dead?

前端 未结 6 2023
野性不改
野性不改 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:11

    Adding on other answers:

    Due to the reasons said in the other answers, it's not recommended for most of Linux distributions, but there are actually distributions that are made specifically to run statically linked binaries:

    • stali
    • morpheus
    • starchlinux
    • bifrost

    From stali description:

    static linux is based on a hand selected collection of the best tools for each task and each tool being statically linked (including some X clients such as st, surf, dwm, dmenu),

    It also targets binary size reduction through the avoidance of glibc and other bloated GNU libraries where possible (early experiments show that statically linked binaries are usually smaller than their dynamically linked glibc counterparts!!!). Note, this is pretty much contrary to what Ulrich Drepper reckons about static linking.

    Due to the side-benefit that statically linked binaries start faster, the distribution also targets performance gains.

    Statically linking also helps to for dependency reduction.

    You can read more about it in this question about static vs dynamic linking.

提交回复
热议问题