Skip to contentSkip to conversation

Config.in: add -Og option

PATCH New Martin Kelly 3 participants 6 messages May 13, 2016 – May 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Config.in: add -Og option

-Og (introduced in GCC 4.8) lets you optimize for debugging experience, which can be useful for when you want optimized code that is nonetheless debuggable.

---
 Config.in           | 11 +++++++++++
 package/Makefile.in |  3 +++
 2 files changed, 14 insertions(+)
Config.in +11 -0
index b5cc892..9330de1 100644
@@ -510,6 +510,17 @@ config BR2_OPTIMIZE_3
 	  and also turns on the -finline-functions, -funswitch-loops and
 	  -fgcse-after-reload options.
 
+config BR2_OPTIMIZE_g
+	bool "optimize debugging experience"
+	select BR2_HOST_GCC_AT_LEAST_4_8
+	help
+	  Optimize debugging experience. -Og enables optimizations that do not
+	  interfere with debugging. It should be the optimization level of choice for
+	  the standard edit-compile-debug cycle, offering a reasonable level of
+	  optimization while maintaining fast compilation and a good debugging
+	  experience. If you use multiple -O options, with or without level numbers,
+	  the last such option is the one that is effective.
+
 config BR2_OPTIMIZE_S
 	bool "optimize for size"
 	help
package/Makefile.in +3 -0
index 616bdd0..2d6ff89 100644
@@ -122,6 +122,9 @@ endif
 ifeq ($(BR2_OPTIMIZE_3),y)
 TARGET_OPTIMIZATION = -O3
 endif
+ifeq ($(BR2_OPTIMIZE_g),y)
+TARGET_OPTIMIZATION = -Og
+endif
 ifeq ($(BR2_OPTIMIZE_S),y)
 TARGET_OPTIMIZATION = -Os
 endif
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 Config.in: add -Og option

Hello,

Quoted 5 lines · Martin Kelly

-Og (introduced in GCC 4.8) lets you optimize for debugging experience, which can be useful for when you want optimized code that is nonetheless debuggable.

Thanks for submitting this patch. I had never heard of -Og, but it seems like a useful addition.

Config.in config BR2_OPTIMIZE_3 · line 515

Quoted 3 lines
Config.in +3 -0
+config BR2_OPTIMIZE_g
+	bool "optimize debugging experience"
+	select BR2_HOST_GCC_AT_LEAST_4_8

select? You can't select an option such as BR2_HOST_GCC_AT_LEAST_4_8. How could Buildroot *force* the host machine to have gcc >= 4.8 ?

In addition, using BR2_HOST_GCC_AT_LEAST_4_8 is wrong here: what we care about is the version of the *target* compiler, not the version of the host compiler.

So this line should instead be:

depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8

Config.in config BR2_OPTIMIZE_3 · line 522

Quoted 7 lines
Config.in +7 -0
+	help
+	  Optimize debugging experience. -Og enables optimizations that do not
+	  interfere with debugging. It should be the optimization level of choice for
+	  the standard edit-compile-debug cycle, offering a reasonable level of
+	  optimization while maintaining fast compilation and a good debugging
+	  experience. If you use multiple -O options, with or without level numbers,
+	  the last such option is the one that is effective.

I believe some of those lines are too long. They should have a maximum length of 72 characters.

Would you mind reworking your patch to address those two issues and sending an updated version?

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 Config.in: add -Og option

Quoted 19 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Martin Kelly

-Og (introduced in GCC 4.8) lets you optimize for debugging experience, which can be useful for when you want optimized code that is nonetheless debuggable.

Thanks for submitting this patch. I had never heard of -Og, but it seems like a useful addition.

Config.in config BR2_OPTIMIZE_3 · line 515

Quoted 3 lines
Config.in +3 -0
+config BR2_OPTIMIZE_g
+	bool "optimize debugging experience"
+	select BR2_HOST_GCC_AT_LEAST_4_8

select? You can't select an option such as BR2_HOST_GCC_AT_LEAST_4_8. How could Buildroot *force* the host machine to have gcc >= 4.8 ?

Quoted 8 lines

In addition, using BR2_HOST_GCC_AT_LEAST_4_8 is wrong here: what we care about is the version of the *target* compiler, not the version of the host compiler.

So this line should instead be:

depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8

Thanks, I agree. I wasn't sure whether to use select or depends. In hindsight, I should have checked, but I'll fix up the patch and send a revision.

Quoted 11 lines

Config.in config BR2_OPTIMIZE_3 · line 522

Quoted 7 lines
Config.in +7 -0
+	help
+	  Optimize debugging experience. -Og enables optimizations that do not
+	  interfere with debugging. It should be the optimization level of choice for
+	  the standard edit-compile-debug cycle, offering a reasonable level of
+	  optimization while maintaining fast compilation and a good debugging
+	  experience. If you use multiple -O options, with or without level numbers,
+	  the last such option is the one that is effective.

I believe some of those lines are too long. They should have a maximum length of 72 characters.

Quoted 3 lines

Would you mind reworking your patch to address those two issues and sending an updated version?

Got it, will do. I wrapped it to 80 lines.

#3 lore raw

PATCH 1/1 Config.in: add -Og option

Quoted 24 lines · Martin Kelly
Quoted 23 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Martin Kelly

-Og (introduced in GCC 4.8) lets you optimize for debugging experience, which can be useful for when you want optimized code that is nonetheless debuggable.

Thanks for submitting this patch. I had never heard of -Og, but it seems like a useful addition.

Config.in config BR2_OPTIMIZE_3 · line 515

Quoted 3 lines
Config.in +3 -0
+config BR2_OPTIMIZE_g
+    bool "optimize debugging experience"
+    select BR2_HOST_GCC_AT_LEAST_4_8

select? You can't select an option such as BR2_HOST_GCC_AT_LEAST_4_8. How could Buildroot *force* the host machine to have gcc >= 4.8 ?

In addition, using BR2_HOST_GCC_AT_LEAST_4_8 is wrong here: what we care about is the version of the *target* compiler, not the version of the host compiler.

Quoted 9 lines
Quoted 4 lines

So this line should instead be:

depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8

Thanks, I agree. I wasn't sure whether to use select or depends. In hindsight, I should have checked, but I'll fix up the patch and send a revision.

I sent a revised patch to the list. Please tell me if you notice anything else to fix up.

#4 lore raw

PATCH 1/1 Config.in: add -Og option

In reply to Martin Kelly

Hi Martin,

In addition to Thomas's comments, I'd like to reword the help text a little.

Quoted 15 lines · Martin Kelly

-Og (introduced in GCC 4.8) lets you optimize for debugging experience, which can be useful for when you want optimized code that is nonetheless debuggable.

---
 Config.in           | 11 +++++++++++
 package/Makefile.in |  3 +++
 2 files changed, 14 insertions(+)
Config.in +0 -0
index b5cc892..9330de1 100644

Config.in config BR2_OPTIMIZE_3 · line 514

Quoted 5 lines
Config.in +2 -0
@@ -510,6 +510,17 @@ config BR2_OPTIMIZE_3
 	  and also turns on the -finline-functions, -funswitch-loops and
 	  -fgcse-after-reload options.
 
+config BR2_OPTIMIZE_g
+	bool "optimize debugging experience"

bool "optimize for debugging"

Config.in config BR2_OPTIMIZE_3 · line 522

Quoted 8 lines
Config.in +8 -0
+	select BR2_HOST_GCC_AT_LEAST_4_8
+	help
+	  Optimize debugging experience. -Og enables optimizations that do not
+	  interfere with debugging. It should be the optimization level of choice for
+	  the standard edit-compile-debug cycle, offering a reasonable level of
+	  optimization while maintaining fast compilation and a good debugging
+	  experience. If you use multiple -O options, with or without level numbers,
+	  the last such option is the one that is effective.

The last sentence doesn't fit here. So:

Optimize for debugging. This enables optimizations that do not interfere with debugging. It should be the optimisation level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.

Regards,
Arnout

Quoted 19 lines
Config.in +1 -0
+
 config BR2_OPTIMIZE_S
 	bool "optimize for size"
 	help
package/Makefile.in +3 -0
index 616bdd0..2d6ff89 100644
@@ -122,6 +122,9 @@ endif
 ifeq ($(BR2_OPTIMIZE_3),y)
 TARGET_OPTIMIZATION = -O3
 endif
+ifeq ($(BR2_OPTIMIZE_g),y)
+TARGET_OPTIMIZATION = -Og
+endif
 ifeq ($(BR2_OPTIMIZE_S),y)
 TARGET_OPTIMIZATION = -Os
 endif
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

PATCH 1/1 Config.in: add -Og option

Quoted 7 lines · Arnout Vandecappelle

Hi Martin,

In addition to Thomas's comments, I'd like to reword the help text a
little.

Quoted 8 lines

The last sentence doesn't fit here. So:

Optimize for debugging. This enables optimizations that do not interfere with debugging. It should be the optimisation level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.

Your wording seems fine. Mine was just copied from the manpage :). I'll revise the patch to use that wording.