summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHe Zhe <zhe.he@windriver.com>2020-06-30 08:33:02 +0000
committerKhem Raj <raj.khem@gmail.com>2020-06-30 08:13:36 -0700
commit14a52c3633e8f32fdf8bb5a259a41f5cfb8cc535 (patch)
treec4d0fa0b82eef62bf4d7cd164cc86b3944949fa4
parent18581f39824818651ecb4c6cb65244ad67c7f01f (diff)
downloadmeta-clang-14a52c3633e8f32fdf8bb5a259a41f5cfb8cc535.tar.gz
bcc: Fix KBUILD_MODNAME errors for kernel 5.7 and latter
Backport two patches to fix the following runtime failures. Networking tools fail with include/net/flow_offload.h:304:4: error: use of undeclared identifier 'KBUILD_MODNAME'. Signed-off-by: He Zhe <zhe.he@windriver.com>
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch27
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch176
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb2
3 files changed, 205 insertions, 0 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch
new file mode 100644
index 0000000..1ca73ba
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch
@@ -0,0 +1,27 @@
1From 9e2415679e41adacc59dd7a426d505232f0b7129 Mon Sep 17 00:00:00 2001
2From: William Findlay <william@williamfindlay.com>
3Date: Wed, 17 Jun 2020 12:07:48 -0400
4Subject: [PATCH 1/2] Add KBUILD_MODNAME flag to default cflags
5
6Upstream-Status: Backported [https://github.com/iovisor/bcc/pull/2974/commits/badd85c58549d0e7f0d536490c41213141e180c5]
7
8Signed-off-by: He Zhe <zhe.he@windriver.com>
9---
10 src/cc/frontends/clang/kbuild_helper.cc | 1 +
11 1 file changed, 1 insertion(+)
12
13diff --git a/src/cc/frontends/clang/kbuild_helper.cc b/src/cc/frontends/clang/kbuild_helper.cc
14index db5ca7f6..e3aade89 100644
15--- a/src/cc/frontends/clang/kbuild_helper.cc
16+++ b/src/cc/frontends/clang/kbuild_helper.cc
17@@ -101,6 +101,7 @@ int KBuildHelper::get_flags(const char *uname_machine, vector<string> *cflags) {
18 cflags->push_back("-D__HAVE_BUILTIN_BSWAP16__");
19 cflags->push_back("-D__HAVE_BUILTIN_BSWAP32__");
20 cflags->push_back("-D__HAVE_BUILTIN_BSWAP64__");
21+ cflags->push_back("-DKBUILD_MODNAME=\"bcc\"");
22
23 // If ARCH env variable is set, pass this along.
24 if (archenv)
25--
262.26.2
27
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch
new file mode 100644
index 0000000..dd87997
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch
@@ -0,0 +1,176 @@
1From eb8b0487a05d650499b20fdd5edeb6e47c2c17a5 Mon Sep 17 00:00:00 2001
2From: William Findlay <william@williamfindlay.com>
3Date: Wed, 17 Jun 2020 18:59:43 -0400
4Subject: [PATCH 2/2] Delete existing kbuild_modname definitions
5
6Upstream-Status: Backported [https://github.com/iovisor/bcc/pull/2974/commits/a5bdc9c65746389d7072e1e8e583025dde78e91b]
7
8Adjust context
9
10Signed-off-by: He Zhe <zhe.he@windriver.com>
11---
12 examples/networking/xdp/xdp_drop_count.py | 1 -
13 examples/networking/xdp/xdp_macswap_count.py | 1 -
14 examples/networking/xdp/xdp_redirect_cpu.py | 1 -
15 examples/networking/xdp/xdp_redirect_map.py | 1 -
16 tests/python/test_clang.py | 8 --------
17 tools/tcplife.lua | 1 -
18 tools/tcplife.py | 1 -
19 tools/tcpstates.py | 1 -
20 8 files changed, 15 deletions(-)
21
22diff --git a/examples/networking/xdp/xdp_drop_count.py b/examples/networking/xdp/xdp_drop_count.py
23index f03273e9..512e0a20 100755
24--- a/examples/networking/xdp/xdp_drop_count.py
25+++ b/examples/networking/xdp/xdp_drop_count.py
26@@ -52,7 +52,6 @@ else:
27
28 # load BPF program
29 b = BPF(text = """
30-#define KBUILD_MODNAME "foo"
31 #include <uapi/linux/bpf.h>
32 #include <linux/in.h>
33 #include <linux/if_ether.h>
34diff --git a/examples/networking/xdp/xdp_macswap_count.py b/examples/networking/xdp/xdp_macswap_count.py
35index 0e2b21ca..770ce8ca 100755
36--- a/examples/networking/xdp/xdp_macswap_count.py
37+++ b/examples/networking/xdp/xdp_macswap_count.py
38@@ -50,7 +50,6 @@ else:
39
40 # load BPF program
41 b = BPF(text = """
42-#define KBUILD_MODNAME "foo"
43 #include <uapi/linux/bpf.h>
44 #include <linux/in.h>
45 #include <linux/if_ether.h>
46diff --git a/examples/networking/xdp/xdp_redirect_cpu.py b/examples/networking/xdp/xdp_redirect_cpu.py
47index 15b0d09b..470079f4 100755
48--- a/examples/networking/xdp/xdp_redirect_cpu.py
49+++ b/examples/networking/xdp/xdp_redirect_cpu.py
50@@ -30,7 +30,6 @@ if (cpu_id > max_cpu):
51
52 # load BPF program
53 b = BPF(text = """
54-#define KBUILD_MODNAME "foo"
55 #include <uapi/linux/bpf.h>
56 #include <linux/in.h>
57 #include <linux/if_ether.h>
58diff --git a/examples/networking/xdp/xdp_redirect_map.py b/examples/networking/xdp/xdp_redirect_map.py
59index 4a622723..4936ac1e 100755
60--- a/examples/networking/xdp/xdp_redirect_map.py
61+++ b/examples/networking/xdp/xdp_redirect_map.py
62@@ -29,7 +29,6 @@ out_idx = ip.link_lookup(ifname=out_if)[0]
63
64 # load BPF program
65 b = BPF(text = """
66-#define KBUILD_MODNAME "foo"
67 #include <uapi/linux/bpf.h>
68 #include <linux/in.h>
69 #include <linux/if_ether.h>
70diff --git a/tests/python/test_clang.py b/tests/python/test_clang.py
71index 886eebed..648494cf 100755
72--- a/tests/python/test_clang.py
73+++ b/tests/python/test_clang.py
74@@ -78,7 +78,6 @@ int count_foo(struct pt_regs *ctx, unsigned long a, unsigned long b) {
75
76 def test_probe_read3(self):
77 text = """
78-#define KBUILD_MODNAME "foo"
79 #include <net/tcp.h>
80 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})
81 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
82@@ -90,7 +89,6 @@ int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
83
84 def test_probe_read4(self):
85 text = """
86-#define KBUILD_MODNAME "foo"
87 #include <net/tcp.h>
88 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})
89 int test(struct pt_regs *ctx, struct sk_buff *skb) {
90@@ -102,7 +100,6 @@ int test(struct pt_regs *ctx, struct sk_buff *skb) {
91
92 def test_probe_read_whitelist1(self):
93 text = """
94-#define KBUILD_MODNAME "foo"
95 #include <net/tcp.h>
96 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
97 // The below define is in net/tcp.h:
98@@ -120,7 +117,6 @@ int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
99
100 def test_probe_read_whitelist2(self):
101 text = """
102-#define KBUILD_MODNAME "foo"
103 #include <net/tcp.h>
104 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
105 // The below define is in net/tcp.h:
106@@ -1072,7 +1068,6 @@ int test(struct __sk_buff *ctx) {
107
108 def test_probe_read_return(self):
109 text = """
110-#define KBUILD_MODNAME "foo"
111 #include <uapi/linux/ptrace.h>
112 #include <linux/tcp.h>
113 static inline unsigned char *my_skb_transport_header(struct sk_buff *skb) {
114@@ -1088,7 +1083,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
115
116 def test_probe_read_multiple_return(self):
117 text = """
118-#define KBUILD_MODNAME "foo"
119 #include <uapi/linux/ptrace.h>
120 #include <linux/tcp.h>
121 static inline u64 error_function() {
122@@ -1109,7 +1103,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
123
124 def test_probe_read_return_expr(self):
125 text = """
126-#define KBUILD_MODNAME "foo"
127 #include <uapi/linux/ptrace.h>
128 #include <linux/tcp.h>
129 static inline unsigned char *my_skb_transport_header(struct sk_buff *skb) {
130@@ -1125,7 +1118,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
131
132 def test_probe_read_return_call(self):
133 text = """
134-#define KBUILD_MODNAME "foo"
135 #include <uapi/linux/ptrace.h>
136 #include <linux/tcp.h>
137 static inline struct tcphdr *my_skb_transport_header(struct sk_buff *skb) {
138diff --git a/tools/tcplife.lua b/tools/tcplife.lua
139index 3f4f6afd..5e311631 100755
140--- a/tools/tcplife.lua
141+++ b/tools/tcplife.lua
142@@ -25,7 +25,6 @@ uint16_t ntohs(uint16_t netshort);
143
144 local program = [[
145 #include <uapi/linux/ptrace.h>
146-#define KBUILD_MODNAME "foo"
147 #include <linux/tcp.h>
148 #include <net/sock.h>
149 #include <bcc/proto.h>
150diff --git a/tools/tcplife.py b/tools/tcplife.py
151index d4e679dd..c2bd8236 100755
152--- a/tools/tcplife.py
153+++ b/tools/tcplife.py
154@@ -66,7 +66,6 @@ debug = 0
155 # define BPF program
156 bpf_text = """
157 #include <uapi/linux/ptrace.h>
158-#define KBUILD_MODNAME "foo"
159 #include <linux/tcp.h>
160 #include <net/sock.h>
161 #include <bcc/proto.h>
162diff --git a/tools/tcpstates.py b/tools/tcpstates.py
163index b9a64387..09bbe0ce 100755
164--- a/tools/tcpstates.py
165+++ b/tools/tcpstates.py
166@@ -61,7 +61,6 @@ debug = 0
167 # define BPF program
168 bpf_text = """
169 #include <uapi/linux/ptrace.h>
170-#define KBUILD_MODNAME "foo"
171 #include <linux/tcp.h>
172 #include <net/sock.h>
173 #include <bcc/proto.h>
174--
1752.26.2
176
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb
index 563c6cc..5a628db 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb
@@ -17,6 +17,8 @@ RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz"
17SRC_URI = "gitsm://github.com/iovisor/bcc \ 17SRC_URI = "gitsm://github.com/iovisor/bcc \
18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ 18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \
19 file://0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch \ 19 file://0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch \
20 file://0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch \
21 file://0001-Delete-existing-kbuild_modname-definitions.patch \
20 " 22 "
21 23
22SRCREV = "942227484d3207f6a42103674001ef01fb5335a0" 24SRCREV = "942227484d3207f6a42103674001ef01fb5335a0"