Config.in: change default optimization level from -Os to -O2

Historically, Buildroot has defaulted to -Os as the gcc optimization
flags. However, this default is probably not the most appropriate
anymore, and this commit therefore changes the default to -O2.

Here are some arguments in favor of this change:

- Most Buildroot users use Buildroot for platforms that have a
  reasonable amount of storage, and the difference between -Os and -O2
  in terms of code size is no longer as significant compared to the
  size of storage available on average embedded Linux devices
  typically found these days.

- -Os can have a pretty bad performance impact, compared to -O2.

- -Os is much less widely tested than -O2. For example, with recent
   versions of gcc, there are parts of Qt5 that segfault when compiled
   with -Os and work perfectly fine with -O2. Yes, it's a compiler bug
   that should be fixed, but in the mean time, having a default that's
   more widely used/tested makes sense.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Acked-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Thomas Petazzoni 2024-01-02 09:36:42 +01:00 committed by Yann E. MORIN
parent 9501bc80f5
commit 292949c638

View File

@ -474,7 +474,7 @@ config BR2_STRIP_EXCLUDE_DIRS
choice
prompt "gcc optimization level"
default BR2_OPTIMIZE_S
default BR2_OPTIMIZE_2
help
Set the optimization level for gcc
@ -520,6 +520,7 @@ config BR2_OPTIMIZE_2
-falign-loops -falign-labels -ftree-vrp -ftree-pre. Please
note the warning under -fgcse about invoking -O2 on programs
that use computed gotos.
This is the default.
config BR2_OPTIMIZE_3
bool "optimization level 3"
@ -548,7 +549,6 @@ config BR2_OPTIMIZE_S
-falign-loops -falign-labels -freorder-blocks
-freorder-blocks-and-partition -fprefetch-loop-arrays
-ftree-vect-loop-version
This is the default.
config BR2_OPTIMIZE_FAST
bool "optimize for fast (may break packages!)"