d375e1db0cc53d7f107ec7260b082d49ceb47074
[openwrt/staging/xback.git] /
1 From 7b00d4a90af1d7bff50833ffe1216cf59592353a Mon Sep 17 00:00:00 2001
2 From: Andre Heider <a.heider@gmail.com>
3 Date: Wed, 18 Jan 2023 22:42:28 +0100
4 Subject: [PATCH] Add BPF_LDFLAGS to allow overwriting llc's -march argument
5
6 The argument to clang's -target isn't necessarily the same as to
7 llc's -march.
8
9 Analogue to BPF_CFLAGS, introduce BPF_LDFLAGS to allow e.g.:
10 BPF_TARGET="mipsel-linux-gnu" BPF_LDFLAGS="-march=bpfel -mcpu=v3"
11
12 Signed-off-by: Andre Heider <a.heider@gmail.com>
13 ---
14 configure | 2 ++
15 lib/common.mk | 2 +-
16 lib/libxdp/Makefile | 2 +-
17 3 files changed, 4 insertions(+), 2 deletions(-)
18
19 --- a/configure
20 +++ b/configure
21 @@ -17,10 +17,12 @@ check_opts()
22 : ${DYNAMIC_LIBXDP:=0}
23 : ${MAX_DISPATCHER_ACTIONS:=10}
24 : ${BPF_TARGET:=bpf}
25 + : ${BPF_LDFLAGS:=-march=$(BPF_TARGET)}
26 echo "PRODUCTION:=${PRODUCTION}" >>$CONFIG
27 echo "DYNAMIC_LIBXDP:=${DYNAMIC_LIBXDP}" >>$CONFIG
28 echo "MAX_DISPATCHER_ACTIONS:=${MAX_DISPATCHER_ACTIONS}" >>$CONFIG
29 echo "BPF_TARGET:=${BPF_TARGET}" >>$CONFIG
30 + echo "BPF_LDFLAGS:=${BPF_LDFLAGS}" >>$CONFIG
31 }
32
33 find_tool()
34 --- a/lib/common.mk
35 +++ b/lib/common.mk
36 @@ -115,7 +115,7 @@ $(XDP_OBJ): %.o: %.c $(KERN_USER_H) $(EX
37 -Werror \
38 $(BPF_CFLAGS) \
39 -O2 -emit-llvm -c -g -o ${@:.o=.ll} $<
40 - $(QUIET_LLC)$(LLC) -march=$(BPF_TARGET) -filetype=obj -o $@ ${@:.o=.ll}
41 + $(QUIET_LLC)$(LLC) $(BPF_LDFLAGS) -filetype=obj -o $@ ${@:.o=.ll}
42
43 .PHONY: man
44 ifeq ($(EMACS),)
45 --- a/lib/libxdp/Makefile
46 +++ b/lib/libxdp/Makefile
47 @@ -146,7 +146,7 @@ $(XDP_OBJS): %.o: %.c $(BPF_HEADERS) $(L
48 -Werror \
49 $(BPF_CFLAGS) \
50 -O2 -emit-llvm -c -g -o ${@:.o=.ll} $<
51 - $(QUIET_LLC)$(LLC) -march=$(BPF_TARGET) -filetype=obj -o $@ ${@:.o=.ll}
52 + $(QUIET_LLC)$(LLC) $(BPF_LDFLAGS) -filetype=obj -o $@ ${@:.o=.ll}
53
54 .PHONY: man
55 ifeq ($(EMACS),)