summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2021-12-06 19:33:45 -0800
committerAndrii Nakryiko <andrii@kernel.org>2021-12-06 19:33:45 -0800
commitfda684fb5ec9ff5afb76441ad5371f89aa3775a4 (patch)
tree0dc4ce1066208d66a19fae3eae4f780333021fd1
parent29f2e5bd9439445fe14ba8570b1c9a7ad682df84 (diff)
parent6f670d06e47c774bc065aaa84a527a4838f34bd8 (diff)
Merge branch 'samples: bpf: fix build issues with Clang/LLVM'
Alexander Lobakin says: ==================== Samples, at least XDP ones, can be built only with the compiler used to build the kernel itself. However, XDP sample infra introduced in Aug'21 was probably tested with GCC/Binutils only as it's not really compilable for now with Clang/LLVM. These two are trivial fixes addressing this. ==================== Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
-rw-r--r--samples/bpf/Makefile7
-rw-r--r--samples/bpf/xdp_sample_user.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 6ae62b1dc938..38638845db9d 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -215,6 +215,11 @@ TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
endif
TPROGS_LDLIBS += $(LIBBPF) -lelf -lz
+TPROGLDLIBS_xdp_monitor += -lm
+TPROGLDLIBS_xdp_redirect += -lm
+TPROGLDLIBS_xdp_redirect_cpu += -lm
+TPROGLDLIBS_xdp_redirect_map += -lm
+TPROGLDLIBS_xdp_redirect_map_multi += -lm
TPROGLDLIBS_tracex4 += -lrt
TPROGLDLIBS_trace_output += -lrt
TPROGLDLIBS_map_perf_test += -lrt
@@ -345,7 +350,7 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
# Override includes for xdp_sample_user.o because $(srctree)/usr/include in
# TPROGS_CFLAGS causes conflicts
-XDP_SAMPLE_CFLAGS += -Wall -O2 -lm \
+XDP_SAMPLE_CFLAGS += -Wall -O2 \
-I$(src)/../../tools/include \
-I$(src)/../../tools/include/uapi \
-I$(LIBBPF_INCLUDE) \
diff --git a/samples/bpf/xdp_sample_user.h b/samples/bpf/xdp_sample_user.h
index d97465ff8c62..5f44b877ecf5 100644
--- a/samples/bpf/xdp_sample_user.h
+++ b/samples/bpf/xdp_sample_user.h
@@ -45,7 +45,9 @@ const char *get_driver_name(int ifindex);
int get_mac_addr(int ifindex, void *mac_addr);
#pragma GCC diagnostic push
+#ifndef __clang__
#pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
__attribute__((unused))
static inline char *safe_strncpy(char *dst, const char *src, size_t size)
{