aboutsummaryrefslogtreecommitdiffstats
path: root/include/bpf.mk
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-11-02 10:39:35 +0100
committerFelix Fietkau <nbd@nbd.name>2021-11-02 10:39:37 +0100
commitcfb022cd5f5baea4f2e78b6f4b21bd1eca3e60ee (patch)
tree2ac0246f324b1c28db4e4f7a18f519d441eb7ea9 /include/bpf.mk
parentda668eb03bbd4290d0acf7f6cea9edcf5de51692 (diff)
downloadupstream-cfb022cd5f5baea4f2e78b6f4b21bd1eca3e60ee.tar.gz
upstream-cfb022cd5f5baea4f2e78b6f4b21bd1eca3e60ee.tar.bz2
upstream-cfb022cd5f5baea4f2e78b6f4b21bd1eca3e60ee.zip
include/bpf.mk: fix compile for big-endian targets
llvm-opt and llc need endian flags in the target as well Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'include/bpf.mk')
-rw-r--r--include/bpf.mk5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/bpf.mk b/include/bpf.mk
index 6223648c5d..9636ad5165 100644
--- a/include/bpf.mk
+++ b/include/bpf.mk
@@ -22,6 +22,7 @@ LLVM_STRIP:=$(LLVM_PATH)/llvm-strip$(LLVM_VER)
BPF_KARCH:=mips
BPF_ARCH:=mips$(if $(CONFIG_BIG_ENDIAN),,el)
+BPF_TARGET:=bpf$(if $(CONFIG_BIG_ENDIAN),eb,el)
BPF_HEADERS_DIR:=$(STAGING_DIR)/bpf-headers
@@ -59,9 +60,9 @@ BPF_CFLAGS := \
define CompileBPF
$(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \
-c $(1) -o $(patsubst %.c,%.bc,$(1))
- $(LLVM_OPT) -O2 -mtriple=bpf-pc-linux < $(patsubst %.c,%.bc,$(1)) > $(patsubst %.c,%.opt,$(1))
+ $(LLVM_OPT) -O2 -mtriple=$(BPF_TARGET) < $(patsubst %.c,%.bc,$(1)) > $(patsubst %.c,%.opt,$(1))
$(LLVM_DIS) < $(patsubst %.c,%.opt,$(1)) > $(patsubst %.c,%.S,$(1))
- $(LLVM_LLC) -march=bpf -filetype=obj -o $(patsubst %.c,%.o,$(1)) < $(patsubst %.c,%.S,$(1))
+ $(LLVM_LLC) -march=$(BPF_TARGET) -filetype=obj -o $(patsubst %.c,%.o,$(1)) < $(patsubst %.c,%.S,$(1))
$(LLVM_STRIP) --strip-debug $(patsubst %.c,%.o,$(1))
endef