内核编译的优化

如果在 make menuconfig里面选择 "Optimize for size", 将会使用 -Os 的选项给 gcc.

 573 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 574 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
 575 else
 576 KBUILD_CFLAGS   += -O2
 577 endif

gcc 里面对 -Os的解释如下:

-Os Optimize for size.  -Os enables all -O2 optimizations that do not
           typically increase code size.  It also performs further
           optimizations designed to reduce code size.

           -Os disables the following optimization flags: -falign-functions
           -falign-jumps  -falign-loops -falign-labels  -freorder-blocks
           -freorder-blocks-and-partition -fprefetch-loop-arrays
           -ftree-vect-loop-version

一句话,这个选项选择之后,将会编出一个size很小的内核景象。

你可能感兴趣的:(内核编译的优化)