Skip to content

Commit 06d469c

Browse files
committed
Merge bitcoin#28629: test: fix usdt undeclared function errors on mantis
4077e43 test: fix usdt undeclared function errors on mantis (willcl-ark) Pull request description: This is one way to fix bitcoin#28600 Recently usage of undeclared functions became an error rather than a warning, in C2x. https://reviews.llvm.org/D122983?id=420290 This change has migrated into the build tools of Ubuntu 23.10 which now causes the USDT tests to fail to compile, see bitcoin#28600 I think there are various potential fixes: 1. Manually declare the functions we use 2. Fix imports so that manual declarations aren't needed 3. Revert the new C2X behaviour and don't error on implicit function declarations I would have preferred solution 2, but I believe this will require changes to the upstream bcc package. Having played with the imports I can get things working in a standalone C program, using system headers, but when building the program from a python context as we do in the test it uses its own headers (bundled with the python lib) rather than the system ones, and manually importing (some) system headers results in definition mismatches. I also investigated explicitly importing required headers from the package, which use paths like `#import </virtual/bcc/bcc_helpers.h>`, but this seems more obtuse and brittle than simply ignoring the warning. Therefore I think that until the upstream python pacakge fixes their declarations, we should fix this by setting `-Wno-error=implicit-function-declaration` for the tracing programs. cc maflcko 0xB10C ACKs for top commit: maflcko: lgtm ACK 4077e43 Tree-SHA512: 8368bb1155e920a95db128dc893267f8dab64f1ae53f6d63c6d9294e2e4e92bef8515e3697e9113228bedc51c0afdbc5bbcf558c119bf0eb3293dc2ced86b435
2 parents a927d5c + 4077e43 commit 06d469c

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

test/functional/interface_usdt_coinselection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def run_test(self):
166166
ctx.enable_probe(probe="coin_selection:normal_create_tx_internal", fn_name="trace_normal_create_tx")
167167
ctx.enable_probe(probe="coin_selection:attempting_aps_create_tx", fn_name="trace_attempt_aps")
168168
ctx.enable_probe(probe="coin_selection:aps_create_tx_internal", fn_name="trace_aps_create_tx")
169-
self.bpf = BPF(text=coinselection_tracepoints_program, usdt_contexts=[ctx], debug=0)
169+
self.bpf = BPF(text=coinselection_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
170170

171171
self.log.info("Prepare wallets")
172172
self.generate(self.nodes[0], 101)

test/functional/interface_usdt_mempool.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
replaced_events.perf_submit(ctx, &replaced, sizeof(replaced));
120120
return 0;
121121
}
122+
122123
"""
123124

124125

@@ -143,7 +144,7 @@ def added_test(self):
143144
node = self.nodes[0]
144145
ctx = USDT(pid=node.process.pid)
145146
ctx.enable_probe(probe="mempool:added", fn_name="trace_added")
146-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0)
147+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
147148

148149
def handle_added_event(_, data, __):
149150
events.append(bpf["added_events"].event(data))
@@ -180,7 +181,7 @@ def removed_test(self):
180181
node = self.nodes[0]
181182
ctx = USDT(pid=node.process.pid)
182183
ctx.enable_probe(probe="mempool:removed", fn_name="trace_removed")
183-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0)
184+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
184185

185186
def handle_removed_event(_, data, __):
186187
events.append(bpf["removed_events"].event(data))
@@ -226,7 +227,7 @@ def replaced_test(self):
226227
node = self.nodes[0]
227228
ctx = USDT(pid=node.process.pid)
228229
ctx.enable_probe(probe="mempool:replaced", fn_name="trace_replaced")
229-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0)
230+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
230231

231232
def handle_replaced_event(_, data, __):
232233
events.append(bpf["replaced_events"].event(data))
@@ -277,7 +278,7 @@ def rejected_test(self):
277278
self.log.info("Hooking into mempool:rejected tracepoint...")
278279
ctx = USDT(pid=node.process.pid)
279280
ctx.enable_probe(probe="mempool:rejected", fn_name="trace_rejected")
280-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0)
281+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
281282

282283
def handle_rejected_event(_, data, __):
283284
events.append(bpf["rejected_events"].event(data))

test/functional/interface_usdt_net.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __repr__(self):
114114
fn_name="trace_inbound_message")
115115
ctx.enable_probe(probe="net:outbound_message",
116116
fn_name="trace_outbound_message")
117-
bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0)
117+
bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
118118

119119
EXPECTED_INOUTBOUND_VERSION_MSG = 1
120120
checked_inbound_version_msg = 0

test/functional/interface_usdt_utxocache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_uncache(self):
175175
ctx = USDT(pid=self.nodes[0].process.pid)
176176
ctx.enable_probe(probe="utxocache:uncache",
177177
fn_name="trace_utxocache_uncache")
178-
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0)
178+
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
179179

180180
# The handle_* function is a ctypes callback function called from C. When
181181
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -244,7 +244,7 @@ def test_add_spent(self):
244244
ctx.enable_probe(probe="utxocache:add", fn_name="trace_utxocache_add")
245245
ctx.enable_probe(probe="utxocache:spent",
246246
fn_name="trace_utxocache_spent")
247-
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0)
247+
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
248248

249249
# The handle_* function is a ctypes callback function called from C. When
250250
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -333,7 +333,7 @@ def test_flush(self):
333333
ctx = USDT(pid=self.nodes[0].process.pid)
334334
ctx.enable_probe(probe="utxocache:flush",
335335
fn_name="trace_utxocache_flush")
336-
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0)
336+
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
337337

338338
# The handle_* function is a ctypes callback function called from C. When
339339
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -390,7 +390,7 @@ def handle_utxocache_flush(_, data, __):
390390
ctx = USDT(pid=self.nodes[0].process.pid)
391391
ctx.enable_probe(probe="utxocache:flush",
392392
fn_name="trace_utxocache_flush")
393-
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0)
393+
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
394394
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
395395

396396
self.log.info(f"prune blockchain to trigger a flush for pruning")

test/functional/interface_usdt_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __repr__(self):
9494
ctx.enable_probe(probe="validation:block_connected",
9595
fn_name="trace_block_connected")
9696
bpf = BPF(text=validation_blockconnected_program,
97-
usdt_contexts=[ctx], debug=0)
97+
usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
9898

9999
def handle_blockconnected(_, data, __):
100100
event = ctypes.cast(data, ctypes.POINTER(Block)).contents

0 commit comments

Comments
 (0)