aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_cpp.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2022-02-17 11:40:05 -0800
committerAndrii Nakryiko <andrii@kernel.org>2022-02-19 16:46:11 -0800
commita33c0c792d0aa2140d79799ca41d68428d2206cc (patch)
treee47f17e9feda17e4ab9523103990cee44bcd321e /tools/testing/selftests/bpf/test_cpp.cpp
parentbpf: Call maybe_wait_bpf_programs() only once from generic_map_delete_batch() (diff)
downloadlinux-dev-a33c0c792d0aa2140d79799ca41d68428d2206cc.tar.xz
linux-dev-a33c0c792d0aa2140d79799ca41d68428d2206cc.zip
selftests/bpf: Fix a clang deprecated-declarations compilation error
Build the kernel and selftest with clang compiler with LLVM=1, make -j LLVM=1 make -C tools/testing/selftests/bpf -j LLVM=1 I hit the following selftests/bpf compilation error: In file included from test_cpp.cpp:3: /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf.h:73:8: error: 'relaxed_core_relocs' is deprecated: libbpf v0.6+: field has no effect [-Werror,-Wdeprecated-declarations] struct bpf_object_open_opts { ^ test_cpp.cpp:56:2: note: in implicit move constructor for 'bpf_object_open_opts' first required here LIBBPF_OPTS(bpf_object_open_opts, opts); ^ /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:77:3: note: expanded from macro 'LIBBPF_OPTS' (struct TYPE) { \ ^ /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf.h:90:2: note: 'relaxed_core_relocs' has been explicitly marked deprecated here LIBBPF_DEPRECATED_SINCE(0, 6, "field has no effect") ^ /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:24:4: note: expanded from macro 'LIBBPF_DEPRECATED_SINCE' (LIBBPF_DEPRECATED("libbpf v" # major "." # minor "+: " msg)) ^ /.../tools/testing/selftests/bpf/tools/include/bpf/libbpf_common.h:19:47: note: expanded from macro 'LIBBPF_DEPRECATED' #define LIBBPF_DEPRECATED(msg) __attribute__((deprecated(msg))) There are two ways to fix the issue, one is to use GCC diagnostic ignore pragma, and the other is to open code bpf_object_open_opts instead of using LIBBPF_OPTS. Since in general LIBBPF_OPTS is preferred, the patch fixed the issue by adding proper GCC diagnostic ignore pragmas. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220217194005.2765348-1-yhs@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/test_cpp.cpp')
-rw-r--r--tools/testing/selftests/bpf/test_cpp.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_cpp.cpp b/tools/testing/selftests/bpf/test_cpp.cpp
index 773f165c4898..19ad172036da 100644
--- a/tools/testing/selftests/bpf/test_cpp.cpp
+++ b/tools/testing/selftests/bpf/test_cpp.cpp
@@ -1,6 +1,9 @@
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
#include <iostream>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <bpf/libbpf.h>
+#pragma GCC diagnostic pop
#include <bpf/bpf.h>
#include <bpf/btf.h>
#include "test_core_extern.skel.h"