Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf bpf: Enclose libbpf.h include within HAVE_LIBBPF_SUPPORT

As it uses the 'deprecated' attribute in a way that breaks the build
with old gcc compilers, so to continue being able to build in such
systems where NO_LIBBPF=1 is being used, enclose it under
HAVE_LIBBPF_SUPPORT.

1 centos:6 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
2 oraclelinux:6 : FAIL gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)

CC /tmp/build/perf/builtin-record.o
In file included from util/bpf-loader.h:11,
from builtin-record.c:39:
/git/linux/tools/lib/bpf/libbpf.h:203: error: wrong number of arguments specified for 'deprecated' attribute

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+28
+3
tools/perf/util/bpf-loader.h
··· 8 8 9 9 #include <linux/compiler.h> 10 10 #include <linux/err.h> 11 + 12 + #ifdef HAVE_LIBBPF_SUPPORT 11 13 #include <bpf/libbpf.h> 12 14 13 15 enum bpf_loader_errno { ··· 40 38 BPF_LOADER_ERRNO__OBJCONF_MAP_IDX2BIG, /* Index too large */ 41 39 __BPF_LOADER_ERRNO__END, 42 40 }; 41 + #endif // HAVE_LIBBPF_SUPPORT 43 42 44 43 struct evsel; 45 44 struct evlist;
+25
tools/perf/util/parse-events.c
··· 668 668 return ret; 669 669 } 670 670 671 + #ifdef HAVE_LIBBPF_SUPPORT 671 672 struct __add_bpf_event_param { 672 673 struct parse_events_state *parse_state; 673 674 struct list_head *list; ··· 901 900 list_splice_tail(&obj_head_config, head_config); 902 901 return err; 903 902 } 903 + #else // HAVE_LIBBPF_SUPPORT 904 + int parse_events_load_bpf_obj(struct parse_events_state *parse_state, 905 + struct list_head *list __maybe_unused, 906 + struct bpf_object *obj __maybe_unused, 907 + struct list_head *head_config __maybe_unused) 908 + { 909 + parse_events__handle_error(parse_state->error, 0, 910 + strdup("BPF support is not compiled"), 911 + strdup("Make sure libbpf-devel is available at build time.")); 912 + return -ENOTSUP; 913 + } 914 + 915 + int parse_events_load_bpf(struct parse_events_state *parse_state, 916 + struct list_head *list __maybe_unused, 917 + char *bpf_file_name __maybe_unused, 918 + bool source __maybe_unused, 919 + struct list_head *head_config __maybe_unused) 920 + { 921 + parse_events__handle_error(parse_state->error, 0, 922 + strdup("BPF support is not compiled"), 923 + strdup("Make sure libbpf-devel is available at build time.")); 924 + return -ENOTSUP; 925 + } 926 + #endif // HAVE_LIBBPF_SUPPORT 904 927 905 928 static int 906 929 parse_breakpoint_type(const char *type, struct perf_event_attr *attr)