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
6 The argument to clang's -target isn't necessarily the same as to
9 Analogue to BPF_CFLAGS, introduce BPF_LDFLAGS to allow e.g.:
10 BPF_TARGET="mipsel-linux-gnu" BPF_LDFLAGS="-march=bpfel -mcpu=v3"
12 Signed-off-by: Andre Heider <a.heider@gmail.com>
16 lib/libxdp/Makefile | 2 +-
17 3 files changed, 4 insertions(+), 2 deletions(-)
21 @@ -17,10 +17,12 @@ check_opts()
22 : ${DYNAMIC_LIBXDP:=0}
23 : ${MAX_DISPATCHER_ACTIONS:=10}
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
36 @@ -115,7 +115,7 @@ $(XDP_OBJ): %.o: %.c $(KERN_USER_H) $(EX
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}
45 --- a/lib/libxdp/Makefile
46 +++ b/lib/libxdp/Makefile
47 @@ -146,7 +146,7 @@ $(XDP_OBJS): %.o: %.c $(BPF_HEADERS) $(L
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}