Skip to contentSkip to conversation

Kconfig: Add an option for debugging OpenSBI

RFC PATCH New Bin Meng 3 participants 3 messages Feb 23, 2023 – Feb 24, 2023 Kbuild

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

RFC PATCH 1/1 Kconfig: Add an option for debugging OpenSBI

Add a new Kconfig option CONFIG_OPENSBI_DEBUG to prevent compiler optimizations using -O2.

---

 Kconfig  | 7 +++++++
 Makefile | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
Kconfig +7 -0
index acfc138..123ea66 100644
@@ -23,3 +23,10 @@ source "$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig"
 source "$(OPENSBI_SRC_DIR)/lib/utils/Kconfig"
 
 source "$(OPENSBI_SRC_DIR)/firmware/Kconfig"
+
+menu "General Setup"
+
+config OPENSBI_DEBUG
+	bool "Disable compiler optimizations for debugging"
+
+endmenu
Makefile +6 -1
index b20404f..b4ed548 100644
@@ -331,7 +331,12 @@ GENFLAGS	+=	$(libsbiutils-genflags-y)
 GENFLAGS	+=	$(platform-genflags-y)
 GENFLAGS	+=	$(firmware-genflags-y)
 
-CFLAGS		=	-g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
+CFLAGS		=	-g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
+ifeq ($(CONFIG_OPENSBI_DEBUG),y)
+CFLAGS		+=	-O0
+else
+CFLAGS		+=	-O2
+endif
 CFLAGS		+=	-fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
 # enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
 ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH 1/1 Kconfig: Add an option for debugging OpenSBI

Quoted 16 lines · Bin Meng

Add a new Kconfig option CONFIG_OPENSBI_DEBUG to prevent compiler optimizations using -O2.

---

 Kconfig  | 7 +++++++
 Makefile | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
Kconfig +0 -0
index acfc138..123ea66 100644

Kconfig source "$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig" · line 32

Quoted 10 lines
Kconfig +7 -0
@@ -23,3 +23,10 @@ source "$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig"
 source "$(OPENSBI_SRC_DIR)/lib/utils/Kconfig"
 
 source "$(OPENSBI_SRC_DIR)/firmware/Kconfig"
+
+menu "General Setup"
+
+config OPENSBI_DEBUG
+       bool "Disable compiler optimizations for debugging"
+
+endmenu\

Rather than adding a Kconfig option, I would suggest having a simple make command-line option. For example, "make DEBUG=1"

Regards,
Anup

Quoted 21 lines
Makefile +6 -2
index b20404f..b4ed548 100644
@@ -331,7 +331,12 @@ GENFLAGS   +=      $(libsbiutils-genflags-y)
 GENFLAGS       +=      $(platform-genflags-y)
 GENFLAGS       +=      $(firmware-genflags-y)
 
-CFLAGS         =       -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
+CFLAGS         =       -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
+ifeq ($(CONFIG_OPENSBI_DEBUG),y)
+CFLAGS         +=      -O0
+else
+CFLAGS         +=      -O2
+endif
 CFLAGS         +=      -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align
 # enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
 ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
--

2.25.1

#2 lore raw

RFC PATCH 1/1 Kconfig: Add an option for debugging OpenSBI

? 2023-02-24???? 10:19 +0530?Anup Patel???

Quoted 19 lines · Bin Meng
Quoted 18 lines

Add a new Kconfig option CONFIG_OPENSBI_DEBUG to prevent compiler optimizations using -O2.

---

?Kconfig? | 7 +++++++
?Makefile | 7 ++++++-
?2 files changed, 13 insertions(+), 1 deletion(-)

Kconfig +0 -0
index acfc138..123ea66 100644
@@ -23,3 +23,10 @@ source "$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig"

?source "$(OPENSBI_SRC_DIR)/lib/utils/Kconfig"

Quoted 12 lines

Kconfig source "$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig"

Quoted 8 lines

?source "$(OPENSBI_SRC_DIR)/firmware/Kconfig"

Kconfig +7 -0
+
+menu "General Setup"
+
+config OPENSBI_DEBUG
+?????? bool "Disable compiler optimizations for debugging"
+
+endmenu\

Rather than adding a Kconfig option, I would suggest having a simple make command-line option. For example, "make DEBUG=1"

Agree to add a command line option so that don't need to re-run make menuconfig when finally generate the release firmware

Regards,
Xiang W

Quoted 25 lines

Regards,
Anup

Quoted 21 lines
Makefile +6 -1
index b20404f..b4ed548 100644
@@ -331,7 +331,12 @@ GENFLAGS?? +=????? $(libsbiutils-genflags-y)
 ?GENFLAGS?????? +=????? $(platform-genflags-y)
 ?GENFLAGS?????? +=????? $(firmware-genflags-y)
 
-CFLAGS???????? =?????? -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -O2
+CFLAGS???????? =?????? -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
+ifeq ($(CONFIG_OPENSBI_DEBUG),y)
+CFLAGS???????? +=????? -O0
+else
+CFLAGS???????? +=????? -O2
+endif

?CFLAGS???????? +=????? -fno-omit-frame-pointer -fno-optimize-sibling-calls -mstrict-align ?# enable -m(no-)save-restore option by CC_SUPPORT_SAVE_RESTORE
?ifeq ($(CC_SUPPORT_SAVE_RESTORE),y)
--
2.25.1