On Mon, Nov 17, 2025 at 3:04 PM Yonghong Song <[email protected]> wrote:
>
>
>
> On 11/15/25 2:55 PM, Hoyeon Lee wrote:
> > The selftests/bpf invokes a nested make when building runqslower, but
> > LLVM toolchain version (clang/llvm-strip) is not propagated. As a
> > result, runqslower is built with system default clang, not respecting
> > specified LLVM version.
> >
> >      # LLVM=-21 make -C tools/testing/selftests/bpf
> >      ...
> >      make feature_display=0 -C /bpf/tools/bpf/runqslower                    
> >     \
> >          OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/runqslower/    
> >     \
> >          BPFOBJ_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/ 
> >     \
> >          
> > BPFOBJ=/bpf/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.a    \
> >          BPF_INCLUDE=/bpf/tools/testing/selftests/bpf/tools/include         
> >     \
> >          
> > BPFTOOL_OUTPUT=/bpf/tools/testing/selftests/bpf/tools/build/bpftool/   \
> >          VMLINUX_BTF=/sys/kernel/btf/vmlinux 
> > BPF_TARGET_ENDIAN=--target=bpfel   \
> >          EXTRA_CFLAGS='-g -O0  ' EXTRA_LDFLAGS=' ' &&                       
> >     \
> >          cp  
> > /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower \
> >              /bpf/tools/testing/selftests/bpf/runqslower
> >      clang -g -O2 --target=bpfel 
> > -I/bpf/tools/testing/selftests/bpf/tools/build/runqslower/ \
> >            -I/bpf/tools/testing/selftests/bpf/tools/include 
> > -I/bpf/tools/include/uapi       \
> >            -c runqslower.bpf.c -o 
> > /bpf/tools/testing/selftests/bpf/tools/build/runqslower/runqslower.bpf.o && 
> > \
> >            llvm-strip -g 
> > /bpf/tools/testing/selftests/bpf/tools/build/runqslower//runqslower.bpf.o
> >      /bin/sh: 1: clang: not found
>
> I tried with LLVM=-20 make -C tools/testing/selftests/bpf in my system and
> there is no build error.
>
> Also could you try with command line
>     make -C tools/testing/selftests/bpf LLVM=1
> for clang build kernel or selftests, LLVM=1 is recommended as it
> encodes a bunch of clang command lines:
>    CC              = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
>    LD              = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)
>    AR              = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
>    NM              = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)
>    OBJCOPY         = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
>    OBJDUMP         = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
>    READELF         = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
>    STRIP           = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>
>
Thanks for the review.

Just to clarify, the issue is not the build failure itself. The error
"clang: not found" only appeared because I intentionally did not set
update-alternatives to avoid falling back to the system default compiler.

The real issue is that the runqslower sub-make invokes "clang" instead
of "clang-21" when LLVM=-21 is specified. This shows that the selected
LLVM toolchain version is not being propagated into the nested build.

LLVM=1 works well for general builds, but in this case the intention is
to verify that a specific LLVM version is consistently applied across
all sub-makes. That propagation does not currently happen, and the patch
addresses exactly that.

Thanks again for taking a look.
>
>
> >
> > Explicitly propagate CLANG and LLVM_STRIP to the runqslower sub-make so
> > that the LLVM toolchain selection from lib.mk is preserved.
> >
> > Signed-off-by: Hoyeon Lee <[email protected]>
> > ---
> >   tools/testing/selftests/bpf/Makefile | 1 +
> >   tools/testing/selftests/lib.mk       | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile 
> > b/tools/testing/selftests/bpf/Makefile
> > index 34ea23c63bd5..79ab69920dca 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -306,6 +306,7 @@ endif
> >
> >   $(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT)
> >       $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower           
> >  \
> > +                 CLANG=$(CLANG) LLVM_STRIP=$(LLVM_STRIP)                   
> >  \
> >                   OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF)    
> >  \
> >                   BPFTOOL_OUTPUT=$(HOST_BUILD_DIR)/bpftool/                 
> >  \
> >                   BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf/                        
> >  \
> > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> > index a448fae57831..f14255b2afbd 100644
> > --- a/tools/testing/selftests/lib.mk
> > +++ b/tools/testing/selftests/lib.mk
> > @@ -8,6 +8,7 @@ LLVM_SUFFIX := $(LLVM)
> >   endif
> >
> >   CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
> > +LLVM_STRIP := $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
> >
> >   CLANG_TARGET_FLAGS_arm          := arm-linux-gnueabi
> >   CLANG_TARGET_FLAGS_arm64        := aarch64-linux-gnu
>

Reply via email to