mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
selftests/bpf: Avoid static LLVM linking for cross builds
The BPF selftests prefer static LLVM linking, which works for native builds but can break cross builds. Its --link-static output may include host-only libraries that are unavailable for the cross compilation, causing link failures. Avoid static LLVM linking for cross builds and use shared LLVM libraries instead. Native builds keep the existing behavior. Signed-off-by: Leo Yan <leo.yan@arm.com> Link: https://lore.kernel.org/r/20260602-tools_build_fix_zero_init_bpf_only-v2-8-c76e5250ea1c@arm.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
584f3b7a35
commit
62617d28d9
|
|
@ -194,8 +194,15 @@ ifeq ($(feature-llvm),1)
|
|||
LLVM_CONFIG_LIB_COMPONENTS := mcdisassembler all-targets
|
||||
# both llvm-config and lib.mk add -D_GNU_SOURCE, which ends up as conflict
|
||||
LLVM_CFLAGS += $(filter-out -D_GNU_SOURCE,$(shell $(LLVM_CONFIG) --cflags))
|
||||
# Prefer linking statically if it's available, otherwise fallback to shared
|
||||
ifeq ($(shell $(LLVM_CONFIG) --link-static --libs >/dev/null 2>&1 && echo static),static)
|
||||
# Cross compilation must use dynamic linking to avoid unresolved library
|
||||
# dependencies. For native build, prefer linking statically if it's
|
||||
# available, otherwise fallback to shared.
|
||||
ifneq ($(ARCH), $(HOSTARCH))
|
||||
LLVM_LINK_STATIC :=
|
||||
else
|
||||
LLVM_LINK_STATIC := $(shell $(LLVM_CONFIG) --link-static --libs >/dev/null 2>&1 && echo y)
|
||||
endif
|
||||
ifeq ($(LLVM_LINK_STATIC),y)
|
||||
LLVM_LDLIBS += $(shell $(LLVM_CONFIG) --link-static --libs $(LLVM_CONFIG_LIB_COMPONENTS))
|
||||
LLVM_LDLIBS += $(filter-out -lxml2,$(shell $(LLVM_CONFIG) --link-static --system-libs $(LLVM_CONFIG_LIB_COMPONENTS)))
|
||||
LLVM_LDLIBS += -lstdc++
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user