I hoped to drop "test_core_extern.skel.h" tools/testing/selftests/bpf/Makefile as test_cpp.cpp includes it: $ git grep include tools/testing/selftests/bpf/test_cpp.cpp tools/testing/selftests/bpf/test_cpp.cpp:#include "test_core_extern.skel.h" $ git diff diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 044bfdcf5b74..a93e4d6ff93c 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -450,7 +450,7 @@ $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ # Make sure we are able to include and link libbpf against c++. -$(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ) +$(OUTPUT)/test_cpp: test_cpp.cpp $(BPFOBJ) $(call msg,CXX,,$@) $(Q)$(CXX) $(CFLAGS) $^ $(LDLIBS) -o $@ When using g++: $ llvm-objdump-12 -Dr test_cpp | grep test_core_extern 77dd: e8 be 01 00 00 callq 0x79a0 <_ZL25test_core_extern__destroyP16test_core_extern> 7842: e8 59 01 00 00 callq 0x79a0 <_ZL25test_core_extern__destroyP16test_core_extern> 00000000000079a0 <_ZL25test_core_extern__destroyP16test_core_extern>: 79a3: 74 1a je 0x79bf <_ZL25test_core_extern__destroyP16test_core_extern+0x1f> 79af: 74 05 je 0x79b6 <_ZL25test_core_extern__destroyP16test_core_extern+0x16> 799e: 74 06 je 0x79a6 <_ZL25test_core_extern__destroyP16test_core_extern+0x6> 7942: 73 61 jae 0x79a5 <_ZL25test_core_extern__destroyP16test_core_extern+0x5> 7945: 70 6c jo 0x79b3 <_ZL25test_core_extern__destroyP16test_core_extern+0x13> 794b: 70 65 jo 0x79b2 <_ZL25test_core_extern__destroyP16test_core_extern+0x12> 7954: 73 5f jae 0x79b5 <_ZL25test_core_extern__destroyP16test_core_extern+0x15> 79aa: 79 00 jns 0x79ac <_ZL25test_core_extern__destroyP16test_core_extern+0xc> When using clang++-12: $ llvm-objdump-12 -Dr test_cpp | grep test_core_extern [ empty ] Last I tried: selftests-bpf-Makefile-EXTRA_CXXFLAGS-x-c-header.diff diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 044bfdcf5b74..df07fd9325d0 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -27,6 +27,7 @@ CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) $(SAN_CFLAGS) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program LDLIBS += -lcap -lelf -lz -lrt -lpthread +EXTRA_CXXFLAGS := -x c-header # Order correspond to 'make run_tests' order TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \ @@ -452,7 +453,7 @@ $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) # Make sure we are able to include and link libbpf against c++. $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ) $(call msg,CXX,,$@) - $(Q)$(CXX) $(CFLAGS) $^ $(LDLIBS) -o $@ + $(Q)$(CXX) $(CFLAGS) $(EXTRA_CXXFLAGS) $^ $(LDLIBS) -o $@ # Benchmark runner $(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h NOPE. - Sedat -