From: Mykyta Yatsenko BPF selftests depend on the bpftool. In some environments we may link bpftool to llvm dynamically and then try to run somewhere where llvm library is not available. It's simpler to avoid llvm linking altogether in those cases, this change allows to do it. Signed-off-by: Mykyta Yatsenko --- tools/bpf/bpftool/Makefile | 12 ++++++++++-- tools/testing/selftests/bpf/Makefile | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 5442073a2e42..7ccdd2acf65e 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -97,6 +97,11 @@ RM ?= rm -f FEATURE_USER = .bpftool +# Set SKIP_LLVM=1 to build bpftool without LLVM dependency. When set, +# bpftool will fall back to libbfd for JIT disassembly (if available), +# or build without disassembly support. +SKIP_LLVM ?= 0 + FEATURE_TESTS := clang-bpf-co-re FEATURE_TESTS += llvm FEATURE_TESTS += libcap @@ -149,8 +154,11 @@ all: $(OUTPUT)bpftool SRCS := $(wildcard *.c) -ifeq ($(feature-llvm),1) - # If LLVM is available, use it for JIT disassembly +ifneq ($(feature-llvm),1) # Force SKIP_LLVM if LLVM is not available + SKIP_LLVM := 1 +endif + +ifneq ($(SKIP_LLVM),1) CFLAGS += -DHAVE_LLVM_SUPPORT LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets # llvm-config always adds -D_GNU_SOURCE, however, it may already be in CFLAGS diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 2c2f68a171ed..e354c7302b25 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -331,6 +331,7 @@ $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \ + SKIP_LLVM=$(SKIP_LLVM) \ prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin ifneq ($(CROSS_COMPILE),) @@ -343,6 +344,7 @@ $(CROSS_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ OUTPUT=$(BUILD_DIR)/bpftool/ \ LIBBPF_OUTPUT=$(BUILD_DIR)/libbpf/ \ LIBBPF_DESTDIR=$(SCRATCH_DIR)/ \ + SKIP_LLVM=$(SKIP_LLVM) \ prefix= DESTDIR=$(SCRATCH_DIR)/ install-bin endif -- 2.52.0