Commit 5531939a authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

Merge branch 'Build BPF selftests and its libbpf, bpftool in debug mode'



Andrii Nakryiko says:

====================

Build BPF selftests and libbpf and bpftool, that are used as part of
selftests, in debug mode (specifically, -Og). This makes it much simpler and
nicer to do development and/or bug fixing. See patch #4 for some unscientific
measurements.

This patch set fixes new maybe-unitialized warnings produced in -Og build
mode. Patch #1 fixes the blocker which was causing some XDP selftests failures
due to non-zero padding in bpf_xdp_set_link_opts, which only happened in debug
mode.
====================

Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 4d0b9389 252e3cbf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -546,6 +546,7 @@ static int do_dump(int argc, char **argv)
			NEXT_ARG();
			if (argc < 1) {
				p_err("expecting value for 'format' option\n");
				err = -EINVAL;
				goto done;
			}
			if (strcmp(*argv, "c") == 0) {
@@ -555,11 +556,13 @@ static int do_dump(int argc, char **argv)
			} else {
				p_err("unrecognized format specifier: '%s', possible values: raw, c",
				      *argv);
				err = -EINVAL;
				goto done;
			}
			NEXT_ARG();
		} else {
			p_err("unrecognized option: '%s'", *argv);
			err = -EINVAL;
			goto done;
		}
	}
+1 −2
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ static int do_batch(int argc, char **argv)
	int n_argc;
	FILE *fp;
	char *cp;
	int err;
	int err = 0;
	int i;

	if (argc < 2) {
@@ -370,7 +370,6 @@ static int do_batch(int argc, char **argv)
	} else {
		if (!json_output)
			printf("processed %d commands\n", lines);
		err = 0;
	}
err_close:
	if (fp != stdin)
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ static int do_dump_btf(const struct btf_dumper *d,
		       void *value)
{
	__u32 value_id;
	int ret;
	int ret = 0;

	/* start of key-value pair */
	jsonw_start_object(d->jw);
+1 −0
Original line number Diff line number Diff line
@@ -507,6 +507,7 @@ struct xdp_link_info {
struct bpf_xdp_set_link_opts {
	size_t sz;
	int old_fd;
	size_t :0;
};
#define bpf_xdp_set_link_opts__last_field old_fd

+5 −2
Original line number Diff line number Diff line
@@ -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'				       \
		    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,6 +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'					       \
		    OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
		    DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
endif
Loading