[openwrt/openwrt] bpf: check llvm version only when used

LEDE Commits lede-commits at lists.infradead.org
Sun Oct 30 16:58:06 PDT 2022


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/c58177b5dcb3461efef0adefe570dd8a8d966ec4

commit c58177b5dcb3461efef0adefe570dd8a8d966ec4
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Wed Oct 26 23:05:31 2022 +0200

    bpf: check llvm version only when used
    
    unetd always includes $(INCLUDE_DIR)/bpf.mk. This file always checks if
    the LLVM version is supported in CLANG_VER_VALID. unetd only needs bpf
    when UNETD_VXLAN_SUPPORT is set. It fails when UNETD_VXLAN_SUPPORT is
    not set and llvm is not installed.
    
    Fix it by only checking the LLVM version when a LLVM toolchain is
    available.
    
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 include/bpf.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/bpf.mk b/include/bpf.mk
index 7d0cfbd76d..e43fcad50c 100644
--- a/include/bpf.mk
+++ b/include/bpf.mk
@@ -63,6 +63,7 @@ BPF_CFLAGS := \
 	-Wno-unused-label \
 	-O2 -emit-llvm -Xclang -disable-llvm-passes
 
+ifneq ($(CONFIG_HAS_BPF_TOOLCHAIN),)
 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 )
@@ -70,6 +71,7 @@ ifeq ($(DUMP),)
     $(error ERROR: LLVM/clang version too old. Minimum required: $(CLANG_MIN_VER), found: $(CLANG_VER))
   endif
 endif
+endif
 
 define CompileBPF
 	$(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \




More information about the lede-commits mailing list