From nobody Sun Dec 14 21:34:14 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 556B41C3C0D; Sun, 15 Dec 2024 22:12:44 +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=1734300769; cv=none; b=o75C+NVyQ0c6a1pDL31W/Ksk0ai2ZQnH0sihn+CJW/vCHTQqFzjwRi1cRAB0i2dmiSUj3dEGtbKt6uz+aqYobcpRxb5Lp4yzkWyH/aP1X0xi0agmDnG88imN0zYahPclcC/xhbxsxfcH15vOKzrCP3x4+raHBUhrf/NYftbczyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734300769; c=relaxed/simple; bh=cejteu26OFS/bbgZBUIfz1AIVTEWFGANsO6qmCunL/4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lTHacVbmzKLq0iCVXesvVHwDAfNNN4uk/KEgBcAOrooTriicWfrOrnF7WAeEqOB/Tjl27RlRchzsGq2ehcxqtIYyxzNLScgIGYejwVfMTb5hCKe9k/DSjhx9oJSVev9UnoUcLgNUpTbfSJVl7j5y4xDTgO3t8d8za4JhQny7t/M= 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 DEB8311FB; Sun, 15 Dec 2024 14:13:11 -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 6CF4A3F720; Sun, 15 Dec 2024 14:12:40 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Quentin Monnet , 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 , Namhyung Kim , 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 v3 1/3] tools build: Add feature test for libelf with ZSTD Date: Sun, 15 Dec 2024 22:12:21 +0000 Message-Id: <20241215221223.293205-2-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215221223.293205-1-leo.yan@arm.com> References: <20241215221223.293205-1-leo.yan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The macro ELFCOMPRESS_ZSTD defines the compress algorithm, which was introduced in the commit ("libelf: Document and make ELFCOMPRESS_ZSTD usable with old system elf.h") of the repository elfutils-0.188-67. Therefore, libelf 0.189 and later versions require to link the libzstd library. Add a test for checking if libelf supports ZSTD algorithm. Pass the macro ELFCOMPRESS_ZSTD 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 Tested-by: Namhyung Kim Acked-by: Jiri Olsa Acked-by: Andrii Nakryiko --- 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 e25cdb7db40e..ce2f37f62dfc 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -77,6 +77,7 @@ FEATURE_TESTS_BASIC :=3D \ 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 cbf751b6f0f7..680f9b07150f 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -28,6 +28,7 @@ FILES=3D \ 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 =20 +$(OUTPUT)test-libelf-zstd.bin: + $(BUILD) -lelf -lz -lzstd + $(OUTPUT)test-libdebuginfod.bin: $(BUILD) -ldebuginfod =20 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 =20 +#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/t= est-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; +} --=20 2.34.1