Commit c18cf78d authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cc3b964d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@

#include <linux/compiler.h>
#include <linux/err.h>

#ifdef HAVE_LIBBPF_SUPPORT
#include <bpf/libbpf.h>

enum bpf_loader_errno {
@@ -38,6 +40,7 @@ enum bpf_loader_errno {
	BPF_LOADER_ERRNO__OBJCONF_MAP_IDX2BIG,	/* Index too large */
	__BPF_LOADER_ERRNO__END,
};
#endif // HAVE_LIBBPF_SUPPORT

struct evsel;
struct evlist;
+25 −0
Original line number Diff line number Diff line
@@ -668,6 +668,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
	return ret;
}

#ifdef HAVE_LIBBPF_SUPPORT
struct __add_bpf_event_param {
	struct parse_events_state *parse_state;
	struct list_head *list;
@@ -900,6 +901,30 @@ int parse_events_load_bpf(struct parse_events_state *parse_state,
		list_splice_tail(&obj_head_config, head_config);
	return err;
}
#else // HAVE_LIBBPF_SUPPORT
int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
			      struct list_head *list __maybe_unused,
			      struct bpf_object *obj __maybe_unused,
			      struct list_head *head_config __maybe_unused)
{
	parse_events__handle_error(parse_state->error, 0,
				   strdup("BPF support is not compiled"),
				   strdup("Make sure libbpf-devel is available at build time."));
	return -ENOTSUP;
}

int parse_events_load_bpf(struct parse_events_state *parse_state,
			  struct list_head *list __maybe_unused,
			  char *bpf_file_name __maybe_unused,
			  bool source __maybe_unused,
			  struct list_head *head_config __maybe_unused)
{
	parse_events__handle_error(parse_state->error, 0,
				   strdup("BPF support is not compiled"),
				   strdup("Make sure libbpf-devel is available at build time."));
	return -ENOTSUP;
}
#endif // HAVE_LIBBPF_SUPPORT

static int
parse_breakpoint_type(const char *type, struct perf_event_attr *attr)