From 292949c638e304ad5104004b95de7895ef3bd405 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 2 Jan 2024 09:36:42 +0100 Subject: [PATCH] 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 Acked-by: Yann E. MORIN Signed-off-by: Yann E. MORIN --- Config.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Config.in b/Config.in index 7b6ea801e7..113adf0755 100644 --- a/Config.in +++ b/Config.in @@ -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!)"