Skip to content

Commit e64fbca

Browse files
alobakinanakryiko
authored andcommitted
samples: bpf: Fix xdp_sample_user.o linking with Clang
Clang (13) doesn't get the jokes about specifying libraries to link in cclags of individual .o objects: clang-13: warning: -lm: 'linker' input unused [-Wunused-command-line-argument] [ ... ] LD samples/bpf/xdp_redirect_cpu LD samples/bpf/xdp_redirect_map_multi LD samples/bpf/xdp_redirect_map LD samples/bpf/xdp_redirect LD samples/bpf/xdp_monitor /usr/bin/ld: samples/bpf/xdp_sample_user.o: in function `sample_summary_print': xdp_sample_user.c:(.text+0x84c): undefined reference to `floor' /usr/bin/ld: xdp_sample_user.c:(.text+0x870): undefined reference to `ceil' /usr/bin/ld: xdp_sample_user.c:(.text+0x8cf): undefined reference to `floor' /usr/bin/ld: xdp_sample_user.c:(.text+0x8f3): undefined reference to `ceil' [ more ] Specify '-lm' as ldflags for all xdp_sample_user.o users in the main Makefile and remove it from ccflags of ^ in Makefile.target -- just like it's done for all other samples. This works with all compilers. Fixes: 6e1051a ("samples: bpf: Convert xdp_monitor to XDP samples helper") Fixes: b926c55 ("samples: bpf: Convert xdp_redirect to XDP samples helper") Fixes: e531a22 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper") Fixes: bbe6586 ("samples: bpf: Convert xdp_redirect_map to XDP samples helper") Fixes: 594a116 ("samples: bpf: Convert xdp_redirect_map_multi to XDP samples helper") Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/bpf/20211203195004.5803-2-alexandr.lobakin@intel.com
1 parent 29f2e5b commit e64fbca

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎samples/bpf/Makefile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
215215
endif
216216

217217
TPROGS_LDLIBS += $(LIBBPF) -lelf -lz
218+
TPROGLDLIBS_xdp_monitor += -lm
219+
TPROGLDLIBS_xdp_redirect += -lm
220+
TPROGLDLIBS_xdp_redirect_cpu += -lm
221+
TPROGLDLIBS_xdp_redirect_map += -lm
222+
TPROGLDLIBS_xdp_redirect_map_multi += -lm
218223
TPROGLDLIBS_tracex4 += -lrt
219224
TPROGLDLIBS_trace_output += -lrt
220225
TPROGLDLIBS_map_perf_test += -lrt
@@ -345,7 +350,7 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
345350

346351
# Override includes for xdp_sample_user.o because $(srctree)/usr/include in
347352
# TPROGS_CFLAGS causes conflicts
348-
XDP_SAMPLE_CFLAGS += -Wall -O2 -lm \
353+
XDP_SAMPLE_CFLAGS += -Wall -O2 \
349354
-I$(src)/../../tools/include \
350355
-I$(src)/../../tools/include/uapi \
351356
-I$(LIBBPF_INCLUDE) \

0 commit comments

Comments
 (0)