diff mbox series

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

Message ID 20240102083643.3055484-1-thomas.petazzoni@bootlin.com
State Accepted
Headers show
Series [v3] Config.in: change default optimization level from -Os to -O2 | expand

Commit Message

Thomas Petazzoni Jan. 2, 2024, 8:36 a.m. UTC
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>
---
 Config.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Yann E. MORIN Jan. 7, 2024, 5:01 p.m. UTC | #1
Thomas, All,

On 2024-01-02 09:36 +0100, Thomas Petazzoni via buildroot spake thusly:
> 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>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  Config.in | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Config.in b/Config.in
> index 554b4062eb..bd4bf872aa 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!)"
> -- 
> 2.43.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/Config.in b/Config.in
index 554b4062eb..bd4bf872aa 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!)"