While -Og is designed to work well with debugger, it's still inferior to -O0
in terms of debuggability experience. It will cause some variables to still be
inlined, it will also prevent single-stepping some statements and otherwise
interfere with debugging experience. So switch to -O0 which turns off any
optimization and provides the best debugging experience.

Signed-off-by: Andrii Nakryiko <and...@kernel.org>
---
 tools/testing/selftests/bpf/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile 
b/tools/testing/selftests/bpf/Makefile
index 6448c626498f..22a88580b491 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -21,7 +21,7 @@ endif
 
 BPF_GCC                ?= $(shell command -v bpf-gcc;)
 SAN_CFLAGS     ?=
-CFLAGS += -g -Og -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS)             \
+CFLAGS += -g -O0 -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS)             \
          -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)          \
          -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT)                      \
          -Dbpf_prog_load=bpf_prog_test_load                            \
@@ -201,7 +201,7 @@ $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] 
$(BPFTOOLDIR)/Makefile)    \
                    $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool
        $(Q)$(MAKE) $(submake_extras)  -C $(BPFTOOLDIR)                        \
                    CC=$(HOSTCC) LD=$(HOSTLD)                                  \
-                   EXTRA_CFLAGS='-g -Og'                                      \
+                   EXTRA_CFLAGS='-g -O0'                                      \
                    OUTPUT=$(HOST_BUILD_DIR)/bpftool/                          \
                    prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install
 
@@ -219,7 +219,7 @@ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)  
               \
           ../../../include/uapi/linux/bpf.h                                   \
           | $(INCLUDE_DIR) $(BUILD_DIR)/libbpf
        $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
-                   EXTRA_CFLAGS='-g -Og'                                       
       \
+                   EXTRA_CFLAGS='-g -O0'                                      \
                    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
 
 ifneq ($(BPFOBJ),$(HOST_BPFOBJ))
@@ -227,7 +227,7 @@ $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] 
$(BPFDIR)/Makefile)                \
           ../../../include/uapi/linux/bpf.h                                   \
           | $(INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf
        $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR)                             \
-                   EXTRA_CFLAGS='-g -Og'                                       
       \
+                   EXTRA_CFLAGS='-g -O0'                                      \
                    OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
                    DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
 endif
-- 
2.30.2

Reply via email to