Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/uclibc: fix usage of DODEBUG option
@ 2022-08-02 13:36 Ben Wolsieffer
  2022-08-02 22:29 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Wolsieffer @ 2022-08-02 13:36 UTC (permalink / raw)
  To: buildroot; +Cc: Ben Wolsieffer

The DODEBUG option passes -O0 and -DDEBUG to the compiler, which has a
significant impact on runtime behavior and performance. Currently,
DODEBUG is enabled by BR2_ENABLE_DEBUG, but it makes more sense for it
to be enabled by BR_ENABLE_RUNTIME_DEBUG.

This patch implements the above change, and also disables the DOSTRIP
option when BR2_ENABLE_DEBUG is set, allowing debug info to be retained.

Lastly, this patch passes all of $(TARGET_CFLAGS) to make, instead of
just $(TARGET_ABI). This enables debug symbols when appropriate.

Signed-off-by: Ben Wolsieffer <Ben.Wolsieffer@hefring.com>
---
 package/uclibc/uclibc.mk | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/package/uclibc/uclibc.mk b/package/uclibc/uclibc.mk
index 0e17a8e65d..cfdd6a2714 100644
--- a/package/uclibc/uclibc.mk
+++ b/package/uclibc/uclibc.mk
@@ -216,12 +216,21 @@ endif
 #
 # Debug
 #
-ifeq ($(BR2_ENABLE_DEBUG),y)
+ifeq ($(BR2_ENABLE_RUNTIME_DEBUG),y)
 define UCLIBC_DEBUG_CONFIG
 	$(call KCONFIG_ENABLE_OPT,DODEBUG)
 endef
 endif
 
+#
+# Disable stripping
+#
+ifeq ($(BR2_ENABLE_DEBUG),y)
+define UCLIBC_STRIP_CONFIG
+	$(call KCONFIG_DISABLE_OPT,DOSTRIP)
+endef
+endif
+
 #
 # Endianness
 #
@@ -374,7 +383,7 @@ endif
 # Commands
 #
 
-UCLIBC_EXTRA_CFLAGS = $(TARGET_ABI)
+UCLIBC_EXTRA_CFLAGS = $(TARGET_CFLAGS)
 
 # uClibc-ng does not build with LTO, so explicitly disable it
 # when using a compiler that may have support for LTO
@@ -412,6 +421,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS
 	$(UCLIBC_POWERPC_TYPE_CONFIG)
 	$(UCLIBC_X86_TYPE_CONFIG)
 	$(UCLIBC_DEBUG_CONFIG)
+	$(UCLIBC_STRIP_CONFIG)
 	$(UCLIBC_ENDIAN_CONFIG)
 	$(UCLIBC_IPV6_CONFIG)
 	$(UCLIBC_FLOAT_CONFIG)
-- 
2.37.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] package/uclibc: fix usage of DODEBUG option
  2022-08-02 13:36 [Buildroot] [PATCH] package/uclibc: fix usage of DODEBUG option Ben Wolsieffer
@ 2022-08-02 22:29 ` Thomas Petazzoni via buildroot
  2022-08-03 20:05   ` Ben Wolsieffer
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-08-02 22:29 UTC (permalink / raw)
  To: Ben Wolsieffer; +Cc: buildroot

Hello Ben,

Thanks for this contribution, good change! Below some
comments/questions.

On Tue,  2 Aug 2022 09:36:25 -0400
Ben Wolsieffer <ben.wolsieffer@hefring.com> wrote:

> The DODEBUG option passes -O0 and -DDEBUG to the compiler, which has a
> significant impact on runtime behavior and performance. Currently,
> DODEBUG is enabled by BR2_ENABLE_DEBUG, but it makes more sense for it
> to be enabled by BR_ENABLE_RUNTIME_DEBUG.
> 
> This patch implements the above change, and also disables the DOSTRIP
> option when BR2_ENABLE_DEBUG is set, allowing debug info to be retained.

We want to disable stripping unconditionally. stripping is done by
Buildroot on the $(TARGET_DIR) when stripping is enabled. Ideally,
packages should not themselves strip binaries.

> Lastly, this patch passes all of $(TARGET_CFLAGS) to make, instead of
> just $(TARGET_ABI). This enables debug symbols when appropriate.

This has a bit more impact:

TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED)

TARGET_CPPFLAGS means we will now be passing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64

TARGET_OPTIMIZATION means we will now be passing -Oxyz, perhaps
overriding the optimization level chosen by uClibc? We have seen that
causing problems with glibc for example, I don't know if we need to be
careful in a similar way with uClibc.

TARGET_HARDENED means we will be passing -D_FORTIFY_SOURCE=1/2 if
BR2_FORTIFY_SOURCE_1=y or BR2_FORTIFY_SOURCE_2=y.

I'm not saying no to this change, but again we need to consider the
impact.

One more careful option is perhaps to do:

UCLIBC_EXTRA_CFLAGS = $(TARGET_CFLAGS) $(TARGET_DEBUGGING)

This achieves the same goal of having the debugging symbols, without
risking of introducing extra flags.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] package/uclibc: fix usage of DODEBUG option
  2022-08-02 22:29 ` Thomas Petazzoni via buildroot
@ 2022-08-03 20:05   ` Ben Wolsieffer
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Wolsieffer @ 2022-08-03 20:05 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot

Thanks for the review!

On Wed, Aug 03, 2022 at 12:29:33AM +0200, Thomas Petazzoni wrote:
> > The DODEBUG option passes -O0 and -DDEBUG to the compiler, which has a
> > significant impact on runtime behavior and performance. Currently,
> > DODEBUG is enabled by BR2_ENABLE_DEBUG, but it makes more sense for it
> > to be enabled by BR_ENABLE_RUNTIME_DEBUG.
> > 
> > This patch implements the above change, and also disables the DOSTRIP
> > option when BR2_ENABLE_DEBUG is set, allowing debug info to be retained.
> 
> We want to disable stripping unconditionally. stripping is done by
> Buildroot on the $(TARGET_DIR) when stripping is enabled. Ideally,
> packages should not themselves strip binaries.
> 

Ok, I will make this unconditional in v2.

> > Lastly, this patch passes all of $(TARGET_CFLAGS) to make, instead of
> > just $(TARGET_ABI). This enables debug symbols when appropriate.
> 
> This has a bit more impact:
> 
> TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING) $(TARGET_HARDENED)
> 
> TARGET_CPPFLAGS means we will now be passing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
> 
> TARGET_OPTIMIZATION means we will now be passing -Oxyz, perhaps
> overriding the optimization level chosen by uClibc? We have seen that
> causing problems with glibc for example, I don't know if we need to be
> careful in a similar way with uClibc.
> 
> TARGET_HARDENED means we will be passing -D_FORTIFY_SOURCE=1/2 if
> BR2_FORTIFY_SOURCE_1=y or BR2_FORTIFY_SOURCE_2=y.
> 
> I'm not saying no to this change, but again we need to consider the
> impact.
> 
> One more careful option is perhaps to do:
> 
> UCLIBC_EXTRA_CFLAGS = $(TARGET_CFLAGS) $(TARGET_DEBUGGING)
> 
> This achieves the same goal of having the debugging symbols, without
> risking of introducing extra flags.
> 

I haven't experienced any problems due to these flags, but I can't prove
they won't break things for others, so I will use your suggestion for
v2.

Ben
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-03 20:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 13:36 [Buildroot] [PATCH] package/uclibc: fix usage of DODEBUG option Ben Wolsieffer
2022-08-02 22:29 ` Thomas Petazzoni via buildroot
2022-08-03 20:05   ` Ben Wolsieffer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox