Skip to content

Commit 6d3bdec

Browse files
heyrutvikanakryiko
authored andcommitted
examples/c: replace llvm-strip symlink with BPF static linking
Rather than relying on the system's llvm-strip tool, which could be missing and failing the build, use "bpftool" to generate bpf object files. Signed-off-by: Rutvik Patel <[email protected]>
1 parent fa8cf5d commit 6d3bdec

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/c/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
22
OUTPUT := .output
33
CLANG ?= clang
4-
LLVM_STRIP ?= llvm-strip
54
LIBBPF_SRC := $(abspath ../../libbpf/src)
65
BPFTOOL_SRC := $(abspath ../../bpftool/src)
76
LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a)
@@ -107,10 +106,12 @@ $(LIBBLAZESYM_HEADER): $(LIBBLAZESYM_SRC)/target/release/libblazesym.a | $(OUTPU
107106
$(Q)cp $(LIBBLAZESYM_SRC)/target/release/blazesym.h $@
108107

109108
# Build BPF code
110-
$(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(VMLINUX) | $(OUTPUT)
109+
$(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(VMLINUX) | $(OUTPUT) $(BPFTOOL)
111110
$(call msg,BPF,$@)
112-
$(Q)$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
113-
$(Q)$(LLVM_STRIP) -g $@ # strip useless DWARF info
111+
$(Q)$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(ARCH) \
112+
$(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) \
113+
-c $(filter %.c,$^) -o $(patsubst %.bpf.o,%.tmp.bpf.o,$@)
114+
$(Q)$(BPFTOOL) gen object $@ $(patsubst %.bpf.o,%.tmp.bpf.o,$@)
114115

115116
# Generate BPF skeletons
116117
$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT) $(BPFTOOL)

0 commit comments

Comments
 (0)