How to decrease the size of generated binaries?

后端 未结 7 1257
谎友^
谎友^ 2021-02-01 05:53

I know that there is an option \"-Os\" to \"Optimize for size\", but it has little affect, or even increase the size on some occasion :(

strip (or \"-s\" option) remov

7条回答
  •  失恋的感觉
    2021-02-01 06:20

    It also depends on the architecture you are using.

    On arm, you have the Thumb instruction set that is here to reduce the generated code size.

    You can also avoid dynamic linking and prefer static linking for libs only used by your program or very few programs on your system. This will not decrease the size of your generated binary per se, but overall, you will use less space on your system for this program.

提交回复
热议问题