netifd: update to Git HEAD (2024-09-03)
[openwrt/staging/stintel.git] / include / bpf.mk
index 7d0cfbd76db45ef17d0778ea817a1f74ebba6035..85c3edb4c773b2341eb08206ffe2dba3f76e0e06 100644 (file)
@@ -33,7 +33,8 @@ BPF_TARGET:=bpf$(if $(CONFIG_BIG_ENDIAN),eb,el)
 BPF_HEADERS_DIR:=$(STAGING_DIR)/bpf-headers
 
 BPF_KERNEL_INCLUDE := \
-       -nostdinc -isystem $(TOOLCHAIN_DIR)/include \
+       -nostdinc -isystem $(TOOLCHAIN_ROOT_DIR)/lib/gcc/*/*/include \
+       $(patsubst %,-isystem%,$(TOOLCHAIN_INC_DIRS)) \
        -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include \
        -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic \
        -I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/generated \
@@ -63,13 +64,15 @@ BPF_CFLAGS := \
        -Wno-unused-label \
        -O2 -emit-llvm -Xclang -disable-llvm-passes
 
-ifeq ($(DUMP),)
+ifneq ($(CONFIG_HAS_BPF_TOOLCHAIN),)
+ifeq ($(DUMP)$(filter download refresh,$(MAKECMDGOALS)),)
   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
+endif
 
 define CompileBPF
        $(CLANG) -g -target $(BPF_ARCH)-linux-gnu $(BPF_CFLAGS) $(2) \