aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-11-09 20:59:15 +0100
committerFelix Fietkau <nbd@nbd.name>2021-11-09 20:59:51 +0100
commit694aed607fbc0a0599f1ff951e5af280500339f9 (patch)
tree1e346250c8b372855f5e6f54dbbe4f4a5ed90530 /include
parent8a6b1a8d29cbd62f005ba20998ca9c8048ff49fc (diff)
downloadupstream-694aed607fbc0a0599f1ff951e5af280500339f9.tar.gz
upstream-694aed607fbc0a0599f1ff951e5af280500339f9.tar.bz2
upstream-694aed607fbc0a0599f1ff951e5af280500339f9.zip
include/bpf.mk: check minimum required clang version
Avoid spurious runtime errors caused by loading eBPF modules built with an old clang version Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'include')
-rw-r--r--include/bpf.mk10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/bpf.mk b/include/bpf.mk
index c68ad74554..967de7a172 100644
--- a/include/bpf.mk
+++ b/include/bpf.mk
@@ -1,6 +1,8 @@
BPF_DEPENDS := @HAS_BPF_TOOLCHAIN
LLVM_VER:=
+CLANG_MIN_VER:=12
+
ifneq ($(CONFIG_USE_LLVM_HOST),)
BPF_TOOLCHAIN_HOST_PATH:=$(call qstrip,$(CONFIG_BPF_TOOLCHAIN_HOST_PATH))
ifneq ($(BPF_TOOLCHAIN_HOST_PATH),)
@@ -61,6 +63,14 @@ BPF_CFLAGS := \
-Wno-unused-label \
-O2 -emit-llvm -Xclang -disable-llvm-passes
+ifeq ($(DUMP),)
+ CLANG_VER:=$(shell clang -dM -E - < /dev/null | grep __clang_major__ | cut -d' ' -f3)
+ CLANG_VER_VALID:=$(shell [ "$(CLANG_VER)" -ge "$(CLANG_MIN_VER)" ] && echo 1 )
+ ifeq ($(CLANG_VER_VALID),)
+ $(error ERROR: LLVM/clang version too old. Minimum required: $(CLANG_MIN_VER), found: $(CLANG_VER))
+ endif
+endif
+
define CompileBPF
$(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \
-c $(1) -o $(patsubst %.c,%.bc,$(1))