bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>,
	Peter Zijlstra <peterz@infradead.org>, Yonghong Song <yhs@fb.com>
Subject: [PATCH v5 bpf-next 07/16] libbpf: re-build libbpf.so when libbpf.map changes
Date: Sun, 15 Aug 2021 00:06:00 -0700	[thread overview]
Message-ID: <20210815070609.987780-8-andrii@kernel.org> (raw)
In-Reply-To: <20210815070609.987780-1-andrii@kernel.org>

Ensure libbpf.so is re-built whenever libbpf.map is modified.  Without this,
changes to libbpf.map are not detected and versioned symbols mismatch error
will be reported until `make clean && make` is used, which is a suboptimal
developer experience.

Fixes: 306b267cb3c4 ("libbpf: Verify versioned symbols")
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index ec14aa725bb0..74c3b73a5fbe 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -4,8 +4,9 @@
 RM ?= rm
 srctree = $(abs_srctree)
 
+VERSION_SCRIPT := libbpf.map
 LIBBPF_VERSION := $(shell \
-	grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \
+	grep -oE '^LIBBPF_([0-9.]+)' $(VERSION_SCRIPT) | \
 	sort -rV | head -n1 | cut -d'_' -f2)
 LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
 
@@ -110,7 +111,6 @@ SHARED_OBJDIR	:= $(OUTPUT)sharedobjs/
 STATIC_OBJDIR	:= $(OUTPUT)staticobjs/
 BPF_IN_SHARED	:= $(SHARED_OBJDIR)libbpf-in.o
 BPF_IN_STATIC	:= $(STATIC_OBJDIR)libbpf-in.o
-VERSION_SCRIPT	:= libbpf.map
 BPF_HELPER_DEFS	:= $(OUTPUT)bpf_helper_defs.h
 
 LIB_TARGET	:= $(addprefix $(OUTPUT),$(LIB_TARGET))
@@ -163,10 +163,10 @@ $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h
 
 $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION)
 
-$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN_SHARED)
+$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN_SHARED) $(VERSION_SCRIPT)
 	$(QUIET_LINK)$(CC) $(LDFLAGS) \
 		--shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \
-		-Wl,--version-script=$(VERSION_SCRIPT) $^ -lelf -lz -o $@
+		-Wl,--version-script=$(VERSION_SCRIPT) $< -lelf -lz -o $@
 	@ln -sf $(@F) $(OUTPUT)libbpf.so
 	@ln -sf $(@F) $(OUTPUT)libbpf.so.$(LIBBPF_MAJOR_VERSION)
 
@@ -181,7 +181,7 @@ $(OUTPUT)libbpf.pc:
 
 check: check_abi
 
-check_abi: $(OUTPUT)libbpf.so
+check_abi: $(OUTPUT)libbpf.so $(VERSION_SCRIPT)
 	@if [ "$(GLOBAL_SYM_COUNT)" != "$(VERSIONED_SYM_COUNT)" ]; then	 \
 		echo "Warning: Num of global symbols in $(BPF_IN_SHARED)"	 \
 		     "($(GLOBAL_SYM_COUNT)) does NOT match with num of"	 \
-- 
2.30.2


  parent reply	other threads:[~2021-08-15  7:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15  7:05 [PATCH v5 bpf-next 00/16] BPF perf link and user-provided bpf_cookie Andrii Nakryiko
2021-08-15  7:05 ` [PATCH v5 bpf-next 01/16] bpf: refactor BPF_PROG_RUN into a function Andrii Nakryiko
2021-08-15  7:05 ` [PATCH v5 bpf-next 02/16] bpf: refactor BPF_PROG_RUN_ARRAY family of macros into functions Andrii Nakryiko
2021-08-15  7:05 ` [PATCH v5 bpf-next 03/16] bpf: refactor perf_event_set_bpf_prog() to use struct bpf_prog input Andrii Nakryiko
2021-08-15  7:05 ` [PATCH v5 bpf-next 04/16] bpf: implement minimal BPF perf link Andrii Nakryiko
2021-08-15  7:05 ` [PATCH v5 bpf-next 05/16] bpf: allow to specify user-provided bpf_cookie for BPF perf links Andrii Nakryiko
2021-08-16 11:46   ` Peter Zijlstra
2021-08-15  7:05 ` [PATCH v5 bpf-next 06/16] bpf: add bpf_get_attach_cookie() BPF helper to access bpf_cookie value Andrii Nakryiko
2021-08-15  7:06 ` Andrii Nakryiko [this message]
2021-08-15  7:06 ` [PATCH v5 bpf-next 08/16] libbpf: remove unused bpf_link's destroy operation, but add dealloc Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 09/16] libbpf: use BPF perf link when supported by kernel Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 10/16] libbpf: add bpf_cookie support to bpf_link_create() API Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 11/16] libbpf: add bpf_cookie to perf_event, kprobe, uprobe, and tp attach APIs Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 12/16] selftests/bpf: test low-level perf BPF link API Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 13/16] selftests/bpf: extract uprobe-related helpers into trace_helpers.{c,h} Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 14/16] selftests/bpf: add bpf_cookie selftests for high-level APIs Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 15/16] libbpf: add uprobe ref counter offset support for USDT semaphores Andrii Nakryiko
2021-08-15  7:06 ` [PATCH v5 bpf-next 16/16] selftests/bpf: add ref_ctr_offset selftests Andrii Nakryiko
2021-08-16 23:10 ` [PATCH v5 bpf-next 00/16] BPF perf link and user-provided bpf_cookie patchwork-bot+netdevbpf

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=20210815070609.987780-8-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=peterz@infradead.org \
    --cc=yhs@fb.com \
    /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).