Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Support dynamically linking LLVM if static is not available

Since 67ab80a01886 ("selftests/bpf: Prefer static linking for LLVM
libraries"), only statically linking test_progs is supported. However,
some distros only provide a dynamically linkable LLVM.

This commit adds a fallback for dynamically linking LLVM if static
linking is not available. If both options are available, static linking
is chosen.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/872b64e93de9a6cd6a7a10e6a5c5e7893704f743.1738276344.git.dxu@dxuuu.xyz

authored by

Daniel Xu and committed by
Andrii Nakryiko
2a9d30fa 12befebe

+8 -3
+8 -3
tools/testing/selftests/bpf/Makefile
··· 184 184 LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets 185 185 # both llvm-config and lib.mk add -D_GNU_SOURCE, which ends up as conflict 186 186 LLVM_CFLAGS += $(filter-out -D_GNU_SOURCE,$(shell $(LLVM_CONFIG) --cflags)) 187 - LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --libs $(LLVM_CONFIG_LIB_COMPONENTS)) 188 - LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --system-libs $(LLVM_CONFIG_LIB_COMPONENTS)) 189 - LLVM_LDLIBS += -lstdc++ 187 + # Prefer linking statically if it's available, otherwise fallback to shared 188 + ifeq ($(shell $(LLVM_CONFIG) --link-static --libs &> /dev/null && echo static),static) 189 + LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --libs $(LLVM_CONFIG_LIB_COMPONENTS)) 190 + LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --system-libs $(LLVM_CONFIG_LIB_COMPONENTS)) 191 + LLVM_LDLIBS += -lstdc++ 192 + else 193 + LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-shared --libs $(LLVM_CONFIG_LIB_COMPONENTS)) 194 + endif 190 195 LLVM_LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags) 191 196 endif 192 197