|
@@ -195,6 +195,8 @@ HOSTLOADLIBES_xdpsock += -pthread
|
|
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
|
|
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
|
|
LLC ?= llc
|
|
LLC ?= llc
|
|
CLANG ?= clang
|
|
CLANG ?= clang
|
|
|
|
+LLVM_OBJCOPY ?= llvm-objcopy
|
|
|
|
+BTF_PAHOLE ?= pahole
|
|
|
|
|
|
# Detect that we're cross compiling and use the cross compiler
|
|
# Detect that we're cross compiling and use the cross compiler
|
|
ifdef CROSS_COMPILE
|
|
ifdef CROSS_COMPILE
|
|
@@ -202,6 +204,16 @@ HOSTCC = $(CROSS_COMPILE)gcc
|
|
CLANG_ARCH_ARGS = -target $(ARCH)
|
|
CLANG_ARCH_ARGS = -target $(ARCH)
|
|
endif
|
|
endif
|
|
|
|
|
|
|
|
+BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
|
|
|
|
+BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
|
|
|
|
+BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
|
|
|
|
+
|
|
|
|
+ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
|
|
|
|
+ EXTRA_CFLAGS += -g
|
|
|
|
+ LLC_FLAGS += -mattr=dwarfris
|
|
|
|
+ DWARF2BTF = y
|
|
|
|
+endif
|
|
|
|
+
|
|
# Trick to allow make to be run from this directory
|
|
# Trick to allow make to be run from this directory
|
|
all:
|
|
all:
|
|
$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
|
|
$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
|
|
@@ -260,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
|
|
-Wno-gnu-variable-sized-type-not-at-end \
|
|
-Wno-gnu-variable-sized-type-not-at-end \
|
|
-Wno-address-of-packed-member -Wno-tautological-compare \
|
|
-Wno-address-of-packed-member -Wno-tautological-compare \
|
|
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
|
|
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
|
|
- -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
|
|
|
|
|
|
+ -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
|
|
|
|
+ifeq ($(DWARF2BTF),y)
|
|
|
|
+ $(BTF_PAHOLE) -J $@
|
|
|
|
+endif
|