Rebase to bcc-0.25.0
Rebase bcc to 0.25.0. Also fixes some conversion errors raised by clang 15 (treated as warning before) and rebuild on libbpf 1.0. Resolves bz#2117708 Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
This commit is contained in:
parent
8d7fa3d949
commit
6709eeb1f8
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@
|
|||||||
/bcc-0.21.0.tar.gz
|
/bcc-0.21.0.tar.gz
|
||||||
/bcc-0.22.0.tar.gz
|
/bcc-0.22.0.tar.gz
|
||||||
/bcc-0.24.0.tar.gz
|
/bcc-0.24.0.tar.gz
|
||||||
|
/bcc-0.25.0.tar.gz
|
||||||
|
77
Fix-bpf_pseudo_fd-type-conversion-error.patch
Normal file
77
Fix-bpf_pseudo_fd-type-conversion-error.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
From 62ded75dca77dc53cbfb2a25ba825510de7600a0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yonghong Song <yhs@fb.com>
|
||||||
|
Date: Sat, 13 Aug 2022 17:50:07 -0700
|
||||||
|
Subject: [PATCH] Fix bpf_pseudo_fd() type conversion error
|
||||||
|
|
||||||
|
With llvm15 and llvm16, the following command line
|
||||||
|
sudo ./trace.py 'smp_call_function_single "%K", arg1'
|
||||||
|
will cause error:
|
||||||
|
/virtual/main.c:60:36: error: incompatible integer to pointer conversion passing 'u64'
|
||||||
|
(aka 'unsigned long long') to parameter of type 'void *' [-Wint-conversion]
|
||||||
|
bpf_perf_event_output(ctx, bpf_pseudo_fd(1, -1), CUR_CPU_IDENTIFIER, &__data, sizeof(__data));
|
||||||
|
^~~~~~~~~~~~~~~~~~~~
|
||||||
|
1 error generated.
|
||||||
|
Failed to compile BPF module <text>
|
||||||
|
|
||||||
|
In helpers.h, we have
|
||||||
|
u64 bpf_pseudo_fd(u64, u64) asm("llvm.bpf.pseudo");
|
||||||
|
Apparently, <= llvm14 can tolerate u64 -> 'void *' conversion, but
|
||||||
|
llvm15 by default will cause an error.
|
||||||
|
|
||||||
|
Let us explicitly convert bpf_pseudo_fd to 'void *' to avoid
|
||||||
|
such errors.
|
||||||
|
|
||||||
|
Signed-off-by: Yonghong Song <yhs@fb.com>
|
||||||
|
---
|
||||||
|
src/cc/frontends/clang/b_frontend_action.cc | 10 +++++-----
|
||||||
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
index a4e05b16..dbeba3e4 100644
|
||||||
|
--- a/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
+++ b/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
@@ -957,7 +957,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
||||||
|
string arg0 = rewriter_.getRewrittenText(expansionRange(Call->getArg(0)->getSourceRange()));
|
||||||
|
string args_other = rewriter_.getRewrittenText(expansionRange(SourceRange(GET_BEGINLOC(Call->getArg(1)),
|
||||||
|
GET_ENDLOC(Call->getArg(2)))));
|
||||||
|
- txt = "bpf_perf_event_output(" + arg0 + ", bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
+ txt = "bpf_perf_event_output(" + arg0 + ", (void *)bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
txt += ", CUR_CPU_IDENTIFIER, " + args_other + ")";
|
||||||
|
|
||||||
|
// e.g.
|
||||||
|
@@ -986,7 +986,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
||||||
|
string meta_len = rewriter_.getRewrittenText(expansionRange(Call->getArg(3)->getSourceRange()));
|
||||||
|
txt = "bpf_perf_event_output(" +
|
||||||
|
skb + ", " +
|
||||||
|
- "bpf_pseudo_fd(1, " + fd + "), " +
|
||||||
|
+ "(void *)bpf_pseudo_fd(1, " + fd + "), " +
|
||||||
|
"((__u64)" + skb_len + " << 32) | BPF_F_CURRENT_CPU, " +
|
||||||
|
meta + ", " +
|
||||||
|
meta_len + ");";
|
||||||
|
@@ -1006,12 +1006,12 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
||||||
|
string keyp = rewriter_.getRewrittenText(expansionRange(Call->getArg(1)->getSourceRange()));
|
||||||
|
string flag = rewriter_.getRewrittenText(expansionRange(Call->getArg(2)->getSourceRange()));
|
||||||
|
txt = "bpf_" + string(memb_name) + "(" + ctx + ", " +
|
||||||
|
- "bpf_pseudo_fd(1, " + fd + "), " + keyp + ", " + flag + ");";
|
||||||
|
+ "(void *)bpf_pseudo_fd(1, " + fd + "), " + keyp + ", " + flag + ");";
|
||||||
|
} else if (memb_name == "ringbuf_output") {
|
||||||
|
string name = string(Ref->getDecl()->getName());
|
||||||
|
string args = rewriter_.getRewrittenText(expansionRange(SourceRange(GET_BEGINLOC(Call->getArg(0)),
|
||||||
|
GET_ENDLOC(Call->getArg(2)))));
|
||||||
|
- txt = "bpf_ringbuf_output(bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
+ txt = "bpf_ringbuf_output((void *)bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
txt += ", " + args + ")";
|
||||||
|
|
||||||
|
// e.g.
|
||||||
|
@@ -1033,7 +1033,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
||||||
|
} else if (memb_name == "ringbuf_reserve") {
|
||||||
|
string name = string(Ref->getDecl()->getName());
|
||||||
|
string arg0 = rewriter_.getRewrittenText(expansionRange(Call->getArg(0)->getSourceRange()));
|
||||||
|
- txt = "bpf_ringbuf_reserve(bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
+ txt = "bpf_ringbuf_reserve((void *)bpf_pseudo_fd(1, " + fd + ")";
|
||||||
|
txt += ", " + arg0 + ", 0)"; // Flags in reserve are meaningless
|
||||||
|
} else if (memb_name == "ringbuf_discard") {
|
||||||
|
string name = string(Ref->getDecl()->getName());
|
||||||
|
--
|
||||||
|
2.37.3
|
||||||
|
|
96
Fix-clang-15-int-to-pointer-conversion-errors.patch
Normal file
96
Fix-clang-15-int-to-pointer-conversion-errors.patch
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
From ff39c45fb063ec448e7aff8b6cc83cb5c625e573 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jerome Marchand <jmarchan@redhat.com>
|
||||||
|
Date: Wed, 26 Oct 2022 14:41:54 +0200
|
||||||
|
Subject: [PATCH] Fix clang 15 int to pointer conversion errors
|
||||||
|
|
||||||
|
Since version 15, clang issues error for implicit conversion of
|
||||||
|
integer to pointer. Several tools are broken. This patch add explicit
|
||||||
|
pointer cast where needed.
|
||||||
|
|
||||||
|
Fixes the following errors:
|
||||||
|
/virtual/main.c:37:18: error: incompatible integer to pointer conversion initializing 'struct request *' with an expression of type 'unsigned long' [-Wint-conversion]
|
||||||
|
struct request *req = ctx->di;
|
||||||
|
^ ~~~~~~~
|
||||||
|
/virtual/main.c:49:18: error: incompatible integer to pointer conversion initializing 'struct request *' with an expression of type 'unsigned long' [-Wint-conversion]
|
||||||
|
struct request *req = ctx->di;
|
||||||
|
^ ~~~~~~~
|
||||||
|
2 errors generated.
|
||||||
|
|
||||||
|
/virtual/main.c:73:19: error: incompatible integer to pointer conversion initializing 'struct pt_regs *' with an expression of type 'unsigned long' [-Wint-conversion]
|
||||||
|
struct pt_regs * __ctx = ctx->di;
|
||||||
|
^ ~~~~~~~
|
||||||
|
/virtual/main.c:100:240: error: incompatible integer to pointer conversion passing 'u64' (aka 'unsigned long long') to parameter of type 'const void *' [-Wint-conversion]
|
||||||
|
data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&({ typeof(struct task_struct *) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&task->real_parent); _val; })->tgid); _val; });
|
||||||
|
^~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
/virtual/main.c:100:118: error: incompatible integer to pointer conversion passing 'u64' (aka 'unsigned long long') to parameter of type 'const void *' [-Wint-conversion]
|
||||||
|
data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&({ typeof(struct task_struct *) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&task->real_parent); _val; })->tgid); _val; });
|
||||||
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
||||||
|
---
|
||||||
|
src/cc/frontends/clang/b_frontend_action.cc | 18 +++++++++---------
|
||||||
|
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
index d0cf995e..9939011c 100644
|
||||||
|
--- a/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
+++ b/src/cc/frontends/clang/b_frontend_action.cc
|
||||||
|
@@ -521,9 +521,9 @@ bool ProbeVisitor::VisitUnaryOperator(UnaryOperator *E) {
|
||||||
|
string pre, post;
|
||||||
|
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
||||||
|
if (cannot_fall_back_safely)
|
||||||
|
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)";
|
||||||
|
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)";
|
||||||
|
else
|
||||||
|
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)";
|
||||||
|
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)";
|
||||||
|
post = "); _val; })";
|
||||||
|
rewriter_.ReplaceText(expansionLoc(E->getOperatorLoc()), 1, pre);
|
||||||
|
rewriter_.InsertTextAfterToken(expansionLoc(GET_ENDLOC(sub)), post);
|
||||||
|
@@ -585,9 +585,9 @@ bool ProbeVisitor::VisitMemberExpr(MemberExpr *E) {
|
||||||
|
string pre, post;
|
||||||
|
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
||||||
|
if (cannot_fall_back_safely)
|
||||||
|
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)&";
|
||||||
|
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)&";
|
||||||
|
else
|
||||||
|
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)&";
|
||||||
|
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)&";
|
||||||
|
post = rhs + "); _val; })";
|
||||||
|
rewriter_.InsertText(expansionLoc(GET_BEGINLOC(E)), pre);
|
||||||
|
rewriter_.ReplaceText(expansionRange(SourceRange(member, GET_ENDLOC(E))), post);
|
||||||
|
@@ -639,9 +639,9 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
|
||||||
|
|
||||||
|
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
||||||
|
if (cannot_fall_back_safely)
|
||||||
|
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)((";
|
||||||
|
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)((";
|
||||||
|
else
|
||||||
|
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)((";
|
||||||
|
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)((";
|
||||||
|
if (isMemberDereference(base)) {
|
||||||
|
pre += "&";
|
||||||
|
// If the base of the array subscript is a member dereference, we'll rewrite
|
||||||
|
@@ -751,8 +751,8 @@ void BTypeVisitor::genParamDirectAssign(FunctionDecl *D, string& preamble,
|
||||||
|
arg->addAttr(UnavailableAttr::CreateImplicit(C, "ptregs"));
|
||||||
|
size_t d = idx - 1;
|
||||||
|
const char *reg = calling_conv_regs[d];
|
||||||
|
- preamble += " " + text + " = " + fn_args_[0]->getName().str() + "->" +
|
||||||
|
- string(reg) + ";";
|
||||||
|
+ preamble += " " + text + " = (" + arg->getType().getAsString() + ")" +
|
||||||
|
+ fn_args_[0]->getName().str() + "->" + string(reg) + ";";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -766,7 +766,7 @@ void BTypeVisitor::genParamIndirectAssign(FunctionDecl *D, string& preamble,
|
||||||
|
|
||||||
|
if (idx == 0) {
|
||||||
|
new_ctx = "__" + arg->getName().str();
|
||||||
|
- preamble += " struct pt_regs * " + new_ctx + " = " +
|
||||||
|
+ preamble += " struct pt_regs * " + new_ctx + " = (void *)" +
|
||||||
|
arg->getName().str() + "->" +
|
||||||
|
string(calling_conv_regs[0]) + ";";
|
||||||
|
} else {
|
||||||
|
--
|
||||||
|
2.37.3
|
||||||
|
|
13
bcc.spec
13
bcc.spec
@ -24,13 +24,14 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: bcc
|
Name: bcc
|
||||||
Version: 0.24.0
|
Version: 0.25.0
|
||||||
Release: 3%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: BPF Compiler Collection (BCC)
|
Summary: BPF Compiler Collection (BCC)
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://github.com/iovisor/bcc
|
URL: https://github.com/iovisor/bcc
|
||||||
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Patch0: libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch
|
Patch0: Fix-bpf_pseudo_fd-type-conversion-error.patch
|
||||||
|
Patch1: Fix-clang-15-int-to-pointer-conversion-errors.patch
|
||||||
|
|
||||||
# Arches will be included as upstream support is added and dependencies are
|
# Arches will be included as upstream support is added and dependencies are
|
||||||
# satisfied in the respective arches
|
# satisfied in the respective arches
|
||||||
@ -52,9 +53,9 @@ BuildRequires: ncurses-devel
|
|||||||
%if %{with lua}
|
%if %{with lua}
|
||||||
BuildRequires: pkgconfig(luajit)
|
BuildRequires: pkgconfig(luajit)
|
||||||
%endif
|
%endif
|
||||||
BuildRequires: libbpf-devel >= 0.0.5-3, libbpf-static >= 0.0.5-3
|
BuildRequires: libbpf-devel >= 2:0.8.0-1, libbpf-static >= 2:0.8.0-1
|
||||||
|
|
||||||
Requires: libbpf >= 0.0.5-3
|
Requires: libbpf >= 2:0.8.0-1
|
||||||
Requires: tar
|
Requires: tar
|
||||||
Recommends: kernel-devel
|
Recommends: kernel-devel
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ Command line tools for BPF Compiler Collection (BCC)
|
|||||||
%if %{with libbpf_tools}
|
%if %{with libbpf_tools}
|
||||||
%package -n libbpf-tools
|
%package -n libbpf-tools
|
||||||
Summary: Command line libbpf tools for BPF Compiler Collection (BCC)
|
Summary: Command line libbpf tools for BPF Compiler Collection (BCC)
|
||||||
BuildRequires: libbpf-devel >= 0.0.5-3, libbpf-static >= 0.0.5-3
|
BuildRequires: libbpf-devel >= 2:0.8.0-1, libbpf-static >= 2:0.8.0-1
|
||||||
BuildRequires: bpftool
|
BuildRequires: bpftool
|
||||||
|
|
||||||
%description -n libbpf-tools
|
%description -n libbpf-tools
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
From c353d172e34f93eb281b679ee6ab3e039db0f420 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jerome Marchand <jmarchan@redhat.com>
|
|
||||||
Date: Tue, 15 Mar 2022 17:59:24 +0100
|
|
||||||
Subject: [PATCH] libbpf-tools: Allow to use different cflags for bpf targets
|
|
||||||
|
|
||||||
commit 531b698cdc20 ("libbpf-tools: Enable compilation warnings for
|
|
||||||
BPF programs") applies CFLAGS to all targets. However, some of the c
|
|
||||||
flags typically used by distribution are not available to the bpf
|
|
||||||
target. Add a new BPFCFLAGS macro to take care of that.
|
|
||||||
|
|
||||||
Fixes the following compilation error on fedora:
|
|
||||||
|
|
||||||
BPF bashreadline.bpf.o
|
|
||||||
clang-13: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
|
|
||||||
clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Wunused-command-line-argument]
|
|
||||||
clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' [-Wunused-command-line-argument]
|
|
||||||
clang-13: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
|
|
||||||
error: option 'cf-protection=return' cannot be specified on this target
|
|
||||||
error: option 'cf-protection=branch' cannot be specified on this target
|
|
||||||
2 errors generated.
|
|
||||||
---
|
|
||||||
libbpf-tools/Makefile | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/libbpf-tools/Makefile b/libbpf-tools/Makefile
|
|
||||||
index faa26139..aba19e00 100644
|
|
||||||
--- a/libbpf-tools/Makefile
|
|
||||||
+++ b/libbpf-tools/Makefile
|
|
||||||
@@ -7,6 +7,7 @@ LIBBPF_SRC := $(abspath ../src/cc/libbpf/src)
|
|
||||||
LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a)
|
|
||||||
INCLUDES := -I$(OUTPUT) -I../src/cc/libbpf/include/uapi
|
|
||||||
CFLAGS := -g -O2 -Wall
|
|
||||||
+BPFCFLAGS := -g -O2 -Wall
|
|
||||||
INSTALL ?= install
|
|
||||||
prefix ?= /usr/local
|
|
||||||
ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/')
|
|
||||||
@@ -107,7 +108,7 @@ $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT)
|
|
||||||
|
|
||||||
$(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(ARCH)/vmlinux.h | $(OUTPUT)
|
|
||||||
$(call msg,BPF,$@)
|
|
||||||
- $(Q)$(CLANG) $(CFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \
|
|
||||||
+ $(Q)$(CLANG) $(BPFCFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \
|
|
||||||
-I$(ARCH)/ $(INCLUDES) -c $(filter %.c,$^) -o $@ && \
|
|
||||||
$(LLVM_STRIP) -g $@
|
|
||||||
|
|
||||||
--
|
|
||||||
2.35.1
|
|
||||||
|
|
2
sources
2
sources
@ -1 +1 @@
|
|||||||
SHA512 (bcc-0.24.0.tar.gz) = 951672e3a8e5ad56eedf513477317ec3d3b4cf2d594bbfce20f3d19ddf7ce255e9dcfc69d9b05bb765a16e769c8e42d7c57071ddb86fb32437f527d3d25d19b6
|
SHA512 (bcc-0.25.0.tar.gz) = 9f71f6c21d1f66054985562168d5848352f5029383e9c65c907a6f044258bc23df842cc65db20bfaaf33789e69c9b8e7b606a32dc882cbdf093b71768c8b521d
|
||||||
|
Loading…
Reference in New Issue
Block a user