From patchwork Wed Dec 11 09:31:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13903270 X-Patchwork-Delegate: bpf@iogearbox.net Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BB581A83F2; Wed, 11 Dec 2024 09:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909493; cv=none; b=uSvyGO6uBG+ls3WxXM6DD7eqYvlZW9CvHaMOFLhOMIPihCscwIg/aMubO7u/cuoIwHHW1s6YNzX7DQ14x/pxcUh58vLrcCMo4VYbBPfPB391I66v1yJzdbaTRbImHlehq/PcKNYsWsOHcmuTMFyUfQbKiaoeHjwFoAk8MdMA0uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909493; c=relaxed/simple; bh=+2hNpiRkDq+lYivHIxOhw1agZtenBpaN92VHsvs+U3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q7YbloAg1zfSj0sBEMbF3V80Pro5ptziHnwu5HDrama2b8XvxsUhQ/6yFVrw1LiDBJ5GnUJOBkgbDysrwpqQsbhXy90C8BxtDovHqO3XJH8AsPouxBzFeG/dnVmxJWWM8FB6deSvzSYvmRWn4t3MZdCRyk18qigW2yFDLXpq3KQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7BE131692; Wed, 11 Dec 2024 01:31:57 -0800 (PST) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 126E83F5A1; Wed, 11 Dec 2024 01:31:25 -0800 (PST) From: Leo Yan To: Quentin Monnet , Arnaldo Carvalho de Melo , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Nick Terrell , Ian Rogers , Adrian Hunter , "Liang, Kan" , James Clark , Guilherme Amadio , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 1/3] tools build: Add feature test for libelf with ZSTD Date: Wed, 11 Dec 2024 09:31:12 +0000 Message-Id: <20241211093114.263742-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211093114.263742-1-leo.yan@arm.com> References: <20241211093114.263742-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a test for checking if libelf supports ZSTD compress algorithm. The macro ELFCOMPRESS_ZSTD is defined for the algorithm, pass it as an argument to the elf_compress() function. If the build succeeds, it means the feature is supported. Signed-off-by: Leo Yan Tested-by: Quentin Monnet Reviewed-by: Quentin Monnet Acked-by: Jiri Olsa --- tools/build/Makefile.feature | 1 + tools/build/feature/Makefile | 4 ++++ tools/build/feature/test-all.c | 4 ++++ tools/build/feature/test-libelf-zstd.c | 9 +++++++++ 4 files changed, 18 insertions(+) create mode 100644 tools/build/feature/test-libelf-zstd.c diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index bca47d136f05..b2884bc23775 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -43,6 +43,7 @@ FEATURE_TESTS_BASIC := \ libelf-getphdrnum \ libelf-gelf_getnote \ libelf-getshdrstrndx \ + libelf-zstd \ libnuma \ numa_num_possible_cpus \ libperl \ diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 043dfd00fce7..f12b89103d7a 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -28,6 +28,7 @@ FILES= \ test-libelf-getphdrnum.bin \ test-libelf-gelf_getnote.bin \ test-libelf-getshdrstrndx.bin \ + test-libelf-zstd.bin \ test-libdebuginfod.bin \ test-libnuma.bin \ test-numa_num_possible_cpus.bin \ @@ -196,6 +197,9 @@ $(OUTPUT)test-libelf-gelf_getnote.bin: $(OUTPUT)test-libelf-getshdrstrndx.bin: $(BUILD) -lelf +$(OUTPUT)test-libelf-zstd.bin: + $(BUILD) -lelf -lz -lzstd + $(OUTPUT)test-libdebuginfod.bin: $(BUILD) -ldebuginfod diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 80ac297f8196..67125f967860 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c @@ -58,6 +58,10 @@ # include "test-libelf-getshdrstrndx.c" #undef main +#define main main_test_libelf_zstd +# include "test-libelf-zstd.c" +#undef main + #define main main_test_libslang # include "test-libslang.c" #undef main diff --git a/tools/build/feature/test-libelf-zstd.c b/tools/build/feature/test-libelf-zstd.c new file mode 100644 index 000000000000..a1324a1db3bb --- /dev/null +++ b/tools/build/feature/test-libelf-zstd.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +int main(void) +{ + elf_compress(NULL, ELFCOMPRESS_ZSTD, 0); + return 0; +} From patchwork Wed Dec 11 09:31:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13903271 X-Patchwork-Delegate: bpf@iogearbox.net Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA42E1DFE26; Wed, 11 Dec 2024 09:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909495; cv=none; b=b663YQXN3op/a1gzd6I6XwUiokv2Iwr0yH1hU0dEZtP6NhODukXcAQFOWBZQXZ/HZ04j7s5O7SUSDOTV+6N7s3STpnI1+PWUXJCZo90GNH+Mo5/pa7g1Ifih35SsNCNXM6kXvsCc7mpcQO8D9GZSA14qK4MlHypxZ5jMsemjuy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909495; c=relaxed/simple; bh=X9+Xj3FxZhc2xOgYA2XMpUSAuIEXmIqjePznJEy0+fI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KA6cqfuEkWAhabqddzUMi0ArmsMQabWIqBB009KswHgt1vsCA7BbqDZWqm6U6iNYhii/hbqYVQ/Z2wZvjogGweXsk1lOjmfXpsEU9EIgFGmB62nTcVubjdqd5vNL4BKnn4686qA/5Zu5hcx1sIt99qPy6R5QoNxka71Aqouu6vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2AFFC16F2; Wed, 11 Dec 2024 01:32:01 -0800 (PST) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B48153F5A1; Wed, 11 Dec 2024 01:31:29 -0800 (PST) From: Leo Yan To: Quentin Monnet , Arnaldo Carvalho de Melo , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Nick Terrell , Ian Rogers , Adrian Hunter , "Liang, Kan" , James Clark , Guilherme Amadio , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 2/3] perf: build: Minor improvement for linking libzstd Date: Wed, 11 Dec 2024 09:31:13 +0000 Message-Id: <20241211093114.263742-3-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211093114.263742-1-leo.yan@arm.com> References: <20241211093114.263742-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The zstd library will be automatically linked automatically by detecting the feature-libzstd. It is no need to explicitly link it for static builds, so remove the redundant linkage. It is contradictory to detect the feature-libelf-zstd while the build configuration NO_LIBZSTD is set. Report an error for reminding users not to set NO_LIBZSTD. Signed-off-by: Leo Yan --- tools/perf/Makefile.config | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 0e4f6a860ae2..155cb9d20011 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -171,7 +171,7 @@ ifdef LIBDW_DIR endif DWARFLIBS := -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) - DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd + DWARFLIBS += -lelf -lz -llzma -lbz2 LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0 LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION))) @@ -566,6 +566,12 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT endif + ifeq ($(feature-libelf-zstd), 1) + ifdef NO_LIBZSTD + $(error Error: libzstd is required by libelf, please do not set NO_LIBZSTD) + endif + endif + ifndef NO_LIBDEBUGINFOD $(call feature_check,libdebuginfod) ifeq ($(feature-libdebuginfod), 1) From patchwork Wed Dec 11 09:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 13903272 X-Patchwork-Delegate: bpf@iogearbox.net Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 980B61A83E5; Wed, 11 Dec 2024 09:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909499; cv=none; b=peXFVVkFn3+zjtrFbJscXsLJ2NjWYrOcvgDsjAqJic/4wx+1zeimEsbvojqDtUuMNyhSELjmPvkDxwUSUI/DaXAX82snVX48xHQnFExrI7/y8uvL1uGYKHBazu/8ZdDPj1kr6rJBtDWr2pTTLzrf7uteLvzaOgYQDKd1I/q9pww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733909499; c=relaxed/simple; bh=h5PW0NQebtRhPbFzeEM2+4jOCjLuzVNQAkAakIMMjcU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kRzZ/b3iTRoGYQNKXGzWtaJB0jOblguOfrsolVbaaiFsjv65M2IV8NygrYWfTZHvwE1Xx+kJZohIeRQX2oijVjLue+xhUGPEdnPZ+mVGuOSKtGn1W2UiBqMX9ZTNjdpZnKuJIUhyWbmxgVbAO4NzkkIHkoMIERA39wXsZxMYkbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D7B721713; Wed, 11 Dec 2024 01:32:04 -0800 (PST) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 63C663F5A1; Wed, 11 Dec 2024 01:31:33 -0800 (PST) From: Leo Yan To: Quentin Monnet , Arnaldo Carvalho de Melo , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Nick Terrell , Ian Rogers , Adrian Hunter , "Liang, Kan" , James Clark , Guilherme Amadio , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 3/3] bpftool: Link zstd lib required by libelf Date: Wed, 11 Dec 2024 09:31:14 +0000 Message-Id: <20241211093114.263742-4-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211093114.263742-1-leo.yan@arm.com> References: <20241211093114.263742-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net When the feature-libelf-zstd is detected, the zstd lib is required by libelf. Link the zstd lib in this case. Signed-off-by: Leo Yan --- tools/bpf/bpftool/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index a4263dfb5e03..469f841abaff 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -106,6 +106,7 @@ FEATURE_TESTS += libbfd-liberty FEATURE_TESTS += libbfd-liberty-z FEATURE_TESTS += disassembler-four-args FEATURE_TESTS += disassembler-init-styled +FEATURE_TESTS += libelf-zstd FEATURE_DISPLAY := clang-bpf-co-re FEATURE_DISPLAY += llvm @@ -113,6 +114,7 @@ FEATURE_DISPLAY += libcap FEATURE_DISPLAY += libbfd FEATURE_DISPLAY += libbfd-liberty FEATURE_DISPLAY += libbfd-liberty-z +FEATURE_DISPLAY += libelf-zstd check_feat := 1 NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall @@ -132,6 +134,12 @@ endif LIBS = $(LIBBPF) -lelf -lz LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz + +ifeq ($(feature-libelf-zstd),1) +LIBS += -lzstd +LIBS_BOOTSTRAP += -lzstd +endif + ifeq ($(feature-libcap), 1) CFLAGS += -DUSE_LIBCAP LIBS += -lcap