[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bzb0Rv=vtarbKr_4-roQsb4P41UerPPagObWMx-73GMo=Q@mail.gmail.com>
Date: Mon, 15 Mar 2021 22:23:27 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Andrii Nakryiko <andrii@...nel.org>
Cc: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 4/4] selftests/bpf: build everything in debug mode
On Sat, Mar 13, 2021 at 1:09 PM Andrii Nakryiko <andrii@...nel.org> wrote:
>
> Build selftests, bpftool, and libbpf in debug mode with DWARF data to
> facilitate easier debugging.
>
> In terms of impact on building and running selftests. Build is actually faster
> now:
>
> BEFORE: make -j60 380.21s user 37.87s system 1466% cpu 28.503 total
> AFTER: make -j60 345.47s user 37.37s system 1599% cpu 23.939 total
>
> test_progs runtime seems to be the same:
>
> BEFORE:
> real 1m5.139s
> user 0m1.600s
> sys 0m43.977s
>
> AFTER:
> real 1m3.799s
> user 0m1.721s
> sys 0m42.420s
>
> Huge difference is being able to debug issues throughout test_progs, bpftool,
> and libbpf without constantly updating 3 Makefiles by hand (including GDB
> seeing the source code without any extra incantations).
>
> Signed-off-by: Andrii Nakryiko <andrii@...nel.org>
> ---
> tools/testing/selftests/bpf/Makefile | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index c3999587bc23..d0db2b673c6f 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 -rdynamic -Wall -O2 $(GENFLAGS) $(SAN_CFLAGS) \
> +CFLAGS += -g -Og -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,6 +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' \
I was asked about '-Og' flag and the minimum GCC version that supports
it. It seems it was added in GCC 4.8 ([0]), so given the kernel's
minimum version is GCC 4.9, we shouldn't need take any extra
precautions to handle older compilers.
[0] https://gcc.gnu.org/gcc-4.8/changes.html
> OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \
> prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install
>
> @@ -218,6 +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' \
> DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
>
> ifneq ($(BPFOBJ),$(HOST_BPFOBJ))
> @@ -225,7 +227,8 @@ $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
> ../../../include/uapi/linux/bpf.h \
> | $(INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf
> $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \
> - OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
> + EXTRA_CFLAGS='-g -Og' \
> + OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
> DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
> endif
>
> --
> 2.24.1
>
Powered by blists - more mailing lists