Skip to content

Commit 49c339c

Browse files
committed
ci: fix test_cpp build on bpf-next
Apply as temporary patch upstream fix ([0]) that has to go through bpf/master, so we fix bpf-next tree as well. [0] https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/ Signed-off-by: Andrii Nakryiko <[email protected]>
1 parent bcf94bb commit 49c339c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 41c24102af7b6236277a214428b203d51a3462df Mon Sep 17 00:00:00 2001
2+
From: Stanislav Fomichev <[email protected]>
3+
Date: Thu, 25 Jul 2024 14:40:29 -0700
4+
Subject: [PATCH 1/1] selftests/bpf: Filter out _GNU_SOURCE when compiling
5+
test_cpp
6+
7+
Jakub reports build failures when merging linux/master with net tree:
8+
9+
CXX test_cpp
10+
In file included from <built-in>:454:
11+
<command line>:2:9: error: '_GNU_SOURCE' macro redefined [-Werror,-Wmacro-redefined]
12+
2 | #define _GNU_SOURCE
13+
| ^
14+
<built-in>:445:9: note: previous definition is here
15+
445 | #define _GNU_SOURCE 1
16+
17+
The culprit is commit cc937dad85ae ("selftests: centralize -D_GNU_SOURCE= to
18+
CFLAGS in lib.mk") which unconditionally added -D_GNU_SOUCE to CLFAGS.
19+
Apparently clang++ also unconditionally adds it for the C++ targets [0]
20+
which causes a conflict. Add small change in the selftests makefile
21+
to filter it out for test_cpp.
22+
23+
Not sure which tree it should go via, targeting bpf for now, but net
24+
might be better?
25+
26+
0: https://stackoverflow.com/questions/11670581/why-is-gnu-source-defined-by-default-and-how-to-turn-it-off
27+
28+
Signed-off-by: Stanislav Fomichev <[email protected]>
29+
Signed-off-by: Andrii Nakryiko <[email protected]>
30+
Acked-by: Jiri Olsa <[email protected]>
31+
Link: https://lore.kernel.org/bpf/[email protected]
32+
---
33+
tools/testing/selftests/bpf/Makefile | 2 +-
34+
1 file changed, 1 insertion(+), 1 deletion(-)
35+
36+
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
37+
index dd49c1d23a60..81d4757ecd4c 100644
38+
--- a/tools/testing/selftests/bpf/Makefile
39+
+++ b/tools/testing/selftests/bpf/Makefile
40+
@@ -713,7 +713,7 @@ $(OUTPUT)/xdp_features: xdp_features.c $(OUTPUT)/network_helpers.o $(OUTPUT)/xdp
41+
# Make sure we are able to include and link libbpf against c++.
42+
$(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
43+
$(call msg,CXX,,$@)
44+
- $(Q)$(CXX) $(CFLAGS) $(filter %.a %.o %.cpp,$^) $(LDLIBS) -o $@
45+
+ $(Q)$(CXX) $(subst -D_GNU_SOURCE=,,$(CFLAGS)) $(filter %.a %.o %.cpp,$^) $(LDLIBS) -o $@
46+
47+
# Benchmark runner
48+
$(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h $(BPFOBJ)
49+
--
50+
2.43.0
51+

0 commit comments

Comments
 (0)