From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>,
Ian Rogers <irogers@google.com>,
linux-perf-users@vger.kernel.org,
Andrii Nakryiko <andrii@kernel.org>
Subject: [PATCH 2/2] perf tools: Add weak variants for the deprecated libbpf functions
Date: Tue, 9 Nov 2021 15:07:07 +0100 [thread overview]
Message-ID: <20211109140707.1689940-3-jolsa@kernel.org> (raw)
In-Reply-To: <20211109140707.1689940-1-jolsa@kernel.org>
Adding weak functions for deprecated libbpf functions, so that
we don't get build fail with libbpf version where they are
finally removed.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/bpf-event.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index ceb96360fd12..476427f3e804 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -22,6 +22,20 @@
#include "record.h"
#include "util/synthetic-events.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+int btf__get_from_id(__u32 id, struct btf **btf);
+struct bpf_program *bpf_program__next(struct bpf_program *prog,
+ const struct bpf_object *obj);
+struct bpf_map *bpf_map__next(const struct bpf_map *map, const struct bpf_object *obj);
+const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
+#pragma GCC diagnostic pop
+
+int __weak btf__get_from_id(__u32 id __maybe_unused, struct btf **btf __maybe_unused)
+{
+ return -ENOTSUP;
+}
+
struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
{
struct btf *btf;
@@ -33,6 +47,13 @@ struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
return err ? ERR_PTR(err) : btf;
}
+struct bpf_program * __weak
+bpf_program__next(struct bpf_program *prog __maybe_unused,
+ const struct bpf_object *obj __maybe_unused)
+{
+ return NULL;
+}
+
struct bpf_program * __weak
bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
{
@@ -42,6 +63,12 @@ bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
#pragma GCC diagnostic pop
}
+struct bpf_map * __weak bpf_map__next(const struct bpf_map *map __maybe_unused,
+ const struct bpf_object *obj __maybe_unused)
+{
+ return NULL;
+}
+
struct bpf_map * __weak
bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)
{
@@ -51,6 +78,12 @@ bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)
#pragma GCC diagnostic pop
}
+const void * __weak btf__get_raw_data(const struct btf *btf __maybe_unused,
+ __u32 *size __maybe_unused)
+{
+ return NULL;
+}
+
const void * __weak
btf__raw_data(const struct btf *btf_ro, __u32 *size)
{
--
2.31.1
prev parent reply other threads:[~2021-11-09 14:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 14:07 [PATCH 0/2] perf tools: Fix perf build with dynamic libbpf Jiri Olsa
2021-11-09 14:07 ` [PATCH 1/2] perf tools: Add more weak libbpf functions Jiri Olsa
2021-11-09 18:49 ` Ian Rogers
2021-11-09 23:33 ` Andrii Nakryiko
2021-11-10 8:45 ` Jiri Olsa
2021-11-10 22:37 ` Andrii Nakryiko
2021-11-11 7:14 ` Jiri Olsa
2021-11-10 8:39 ` Jiri Olsa
2021-11-13 13:40 ` Arnaldo Carvalho de Melo
2021-11-09 14:07 ` Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211109140707.1689940-3-jolsa@kernel.org \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).