summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHe Zhe <zhe.he@windriver.com>2026-05-09 11:07:39 +0800
committerKhem Raj <khem.raj@oss.qualcomm.com>2026-05-12 01:10:18 -0700
commite65e1a81e412421d6349f9ab1ef368c5c7ff84d1 (patch)
tree127d67acd1182c90b950f235a678d7d0dcc910a8
parenta6a2d6346cf0df9123ead1498cd9fa619b7616b5 (diff)
downloadmeta-openembedded-e65e1a81e412421d6349f9ab1ef368c5c7ff84d1.tar.gz
bpftool-native: Fix -Wdiscarded-qualifiers errors for glibc 2.42+
Backport a patch from kernel to fix the following build errors. bbpf.c: In function ‘kallsyms_cb’: | libbpf.c:8192:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] | 8192 | res = strstr(sym_name, ".llvm."); | | ^ | libbpf.c: In function ‘avail_kallsyms_cb’: | libbpf.c:11497:31: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] | 11497 | if (!(sym_sfx = strstr(sym_name, ".llvm."))) | | ^ | libbpf.c: In function ‘resolve_full_path’: | libbpf.c:12085:35: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] | 12085 | next_path = strchr(s, ':'); | | Signed-off-by: He Zhe <zhe.he@windriver.com> Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
-rw-r--r--meta-oe/recipes-kernel/bpftool/bpftool-native_6.16.bb5
-rw-r--r--meta-oe/recipes-kernel/bpftool/bpftool/0001-libbpf-Fix-Wdiscarded-qualifiers-under-C23.patch69
2 files changed, 73 insertions, 1 deletions
diff --git a/meta-oe/recipes-kernel/bpftool/bpftool-native_6.16.bb b/meta-oe/recipes-kernel/bpftool/bpftool-native_6.16.bb
index fe3ad6138e..edc635517a 100644
--- a/meta-oe/recipes-kernel/bpftool/bpftool-native_6.16.bb
+++ b/meta-oe/recipes-kernel/bpftool/bpftool-native_6.16.bb
@@ -9,7 +9,10 @@ DEPENDS = "binutils-native elfutils-native"
9 9
10inherit native bash-completion 10inherit native bash-completion
11 11
12SRC_URI = "${KERNELORG_MIRROR}/linux/kernel/v6.x/linux-${PV}.tar.xz" 12SRC_URI = "\
13 ${KERNELORG_MIRROR}/linux/kernel/v6.x/linux-${PV}.tar.xz \
14 file://0001-libbpf-Fix-Wdiscarded-qualifiers-under-C23.patch \
15"
13SRC_URI[sha256sum] = "1a4be2fe6b5246aa4ac8987a8a4af34c42a8dd7d08b46ab48516bcc1befbcd83" 16SRC_URI[sha256sum] = "1a4be2fe6b5246aa4ac8987a8a4af34c42a8dd7d08b46ab48516bcc1befbcd83"
14 17
15S = "${UNPACKDIR}/linux-${PV}" 18S = "${UNPACKDIR}/linux-${PV}"
diff --git a/meta-oe/recipes-kernel/bpftool/bpftool/0001-libbpf-Fix-Wdiscarded-qualifiers-under-C23.patch b/meta-oe/recipes-kernel/bpftool/bpftool/0001-libbpf-Fix-Wdiscarded-qualifiers-under-C23.patch
new file mode 100644
index 0000000000..9d2338c821
--- /dev/null
+++ b/meta-oe/recipes-kernel/bpftool/bpftool/0001-libbpf-Fix-Wdiscarded-qualifiers-under-C23.patch
@@ -0,0 +1,69 @@
1From ab21cf885fb2af179c44d8beeabd716133b9385d Mon Sep 17 00:00:00 2001
2From: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
3Date: Sat, 6 Dec 2025 14:28:25 +0500
4Subject: [PATCH] libbpf: Fix -Wdiscarded-qualifiers under C23
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9commit d70f79fef65810faf64dbae1f3a1b5623cdb2345 upstream.
10
11glibc ≥ 2.42 (GCC 15) defaults to -std=gnu23, which promotes
12-Wdiscarded-qualifiers to an error.
13
14In C23, strstr() and strchr() return "const char *".
15
16Change variable types to const char * where the pointers are never
17modified (res, sym_sfx, next_path).
18
19Suggested-by: Florian Weimer <fweimer@redhat.com>
20Suggested-by: Andrii Nakryiko <andrii@kernel.org>
21Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
22Link: https://lore.kernel.org/r/20251206092825.1471385-1-mikhail.v.gavrilov@gmail.com
23Signed-off-by: Alexei Starovoitov <ast@kernel.org>
24[ shung-hsi.yu: needed to fix kernel build failure due to libbpf since glibc
25 2.43+ (which adds 'const' qualifier to strstr) ]
26Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29Upstream-Status: Backport[https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-6.18.y&id=ab21cf885fb2af179c44d8beeabd716133b9385d]
30Signed-off-by: He Zhe <zhe.he@windriver.com>
31---
32 tools/lib/bpf/libbpf.c | 7 ++++---
33 1 file changed, 4 insertions(+), 3 deletions(-)
34
35diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
36index dd3b2f57082d..9c98c6adb6d0 100644
37--- a/tools/lib/bpf/libbpf.c
38+++ b/tools/lib/bpf/libbpf.c
39@@ -8245,7 +8245,7 @@ static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
40 struct bpf_object *obj = ctx;
41 const struct btf_type *t;
42 struct extern_desc *ext;
43- char *res;
44+ const char *res;
45
46 res = strstr(sym_name, ".llvm.");
47 if (sym_type == 'd' && res)
48@@ -11574,7 +11574,8 @@ static int avail_kallsyms_cb(unsigned long long sym_addr, char sym_type,
49 *
50 * [0] fb6a421fb615 ("kallsyms: Match symbols exactly with CONFIG_LTO_CLANG")
51 */
52- char sym_trim[256], *psym_trim = sym_trim, *sym_sfx;
53+ char sym_trim[256], *psym_trim = sym_trim;
54+ const char *sym_sfx;
55
56 if (!(sym_sfx = strstr(sym_name, ".llvm.")))
57 return 0;
58@@ -12159,7 +12160,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
59 if (!search_paths[i])
60 continue;
61 for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) {
62- char *next_path;
63+ const char *next_path;
64 int seg_len;
65
66 if (s[0] == ':')
67--
682.34.1
69