All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Leo Yan" <leo.yan@arm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 8/8] selftests/bpf: Avoid static LLVM linking for cross builds
Date: Tue, 02 Jun 2026 17:33:47 +0000	[thread overview]
Message-ID: <20260602173348.0E0491F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-8-c76e5250ea1c@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Flawed native vs cross-build detection using un-normalized `ARCH` against normalized `HOSTARCH`.
--

commit 9a32865094dbf702cf09a9de14d120a1f3ca8a92
Author: Leo Yan <leo.yan@arm.com>

selftests/bpf: Avoid static LLVM linking for cross builds

This commit modifies the BPF selftests Makefile to avoid static LLVM linking
during cross builds. It intends to use dynamic linking for cross compilation
while preserving the existing preference for static linking on native builds.

> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 1e47e29ba4214..ffa90674e86f6 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -188,8 +188,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))

[Severity: Medium]
Will this comparison accurately identify native builds?

The kernel build system normalizes $(HOSTARCH) (for example, "x86_64" becomes
"x86"), but $(ARCH) might retain the un-normalized string if passed from the
environment or top-level Makefile.

If $(ARCH) is "x86_64" and $(HOSTARCH) is "x86", this check evaluates to true
even on a native build, unintentionally forcing shared LLVM libraries instead
of keeping the static linking behavior as intended.

Would it be more robust to compare $(SRCARCH) to $(HOSTARCH), or to check if
$(CROSS_COMPILE) is empty instead?

> +    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))

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com?part=8

  reply	other threads:[~2026-06-02 17:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 14:47 [PATCH bpf-next v2 0/8] tools build: bpf: Append EXTRA_CFLAGS and HOST_EXTRACFLAGS Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 1/8] bpftool: Pass host flags to bootstrap libbpf Leo Yan
2026-06-03  9:21   ` Quentin Monnet
2026-06-02 14:47 ` [PATCH bpf-next v2 2/8] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 3/8] bpftool: Append extra host flags Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 4/8] libbpf: Initialize CFLAGS before including Makefile.include Leo Yan
2026-06-02 15:11   ` sashiko-bot
2026-06-02 14:47 ` [PATCH bpf-next v2 5/8] tools/bpf: build: Append extra cflags Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 6/8] selftests/bpf: Initialize operation name before use Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 7/8] selftests/bpf: Use common CFLAGS for urandom_read Leo Yan
2026-06-02 15:32   ` bot+bpf-ci
2026-06-02 17:25   ` sashiko-bot
2026-06-02 14:47 ` [PATCH bpf-next v2 8/8] selftests/bpf: Avoid static LLVM linking for cross builds Leo Yan
2026-06-02 17:33   ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-02 21:00 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260602173348.0E0491F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=leo.yan@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.