public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found
@ 2026-03-02 23:10 Ihor Solodrai
  2026-03-04 17:23 ` Paul Chaignon
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Solodrai @ 2026-03-02 23:10 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann
  Cc: Vitaly Chikunov, bpf, kernel-team

The "|| echo -lzstd" default makes zstd an unconditional link
dependency of resolve_btfids. On systems where libzstd-dev is not
installed and pkg-config fails, the linker fails:

  ld: cannot find -lzstd: No such file or directory

libzstd is a transitive dependency of libelf, so the -lzstd flag is
strictly necessary only for static builds [1].

Drop the -lzstd fallback to enable builds on systems without
libzstd-dev installed.

Reported-by: BPF CI Bot (Claude Opus 4.6) <bot+bpf-ci@kernel.org>
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Closes: https://lore.kernel.org/bpf/aaWqMcK-2AQw5dx8@altlinux.org/
Fixes: 4021848a903e ("selftests/bpf: Pass through build flags to bpftool and resolve_btfids")
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
---
 tools/bpf/resolve_btfids/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index ef083602b73a..5df897c881d3 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -66,7 +66,7 @@ LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
 LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
 
 ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
-ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null || echo -lzstd)
+ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null)
 
 HOSTCFLAGS_resolve_btfids += -g \
           -I$(srctree)/tools/include \
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found
  2026-03-02 23:10 [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found Ihor Solodrai
@ 2026-03-04 17:23 ` Paul Chaignon
  2026-03-04 19:24   ` Ihor Solodrai
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Chaignon @ 2026-03-04 17:23 UTC (permalink / raw)
  To: Ihor Solodrai
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Vitaly Chikunov, bpf, kernel-team

On Mon, Mar 02, 2026 at 03:10:58PM -0800, Ihor Solodrai wrote:
> The "|| echo -lzstd" default makes zstd an unconditional link
> dependency of resolve_btfids. On systems where libzstd-dev is not
> installed and pkg-config fails, the linker fails:
> 
>   ld: cannot find -lzstd: No such file or directory
> 
> libzstd is a transitive dependency of libelf, so the -lzstd flag is
> strictly necessary only for static builds [1].
> 
> Drop the -lzstd fallback to enable builds on systems without
> libzstd-dev installed.
> 
> Reported-by: BPF CI Bot (Claude Opus 4.6) <bot+bpf-ci@kernel.org>
> Reported-by: Vitaly Chikunov <vt@altlinux.org>
> Closes: https://lore.kernel.org/bpf/aaWqMcK-2AQw5dx8@altlinux.org/
> Fixes: 4021848a903e ("selftests/bpf: Pass through build flags to bpftool and resolve_btfids")
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> ---
>  tools/bpf/resolve_btfids/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index ef083602b73a..5df897c881d3 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -66,7 +66,7 @@ LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
>  LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
>  
>  ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
> -ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null || echo -lzstd)
> +ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null)

This change is currently failing in CI with "undefined reference to
`ZSTD_xxx'" when trying to build resolve_btfids. I think this is
happening because the selftests use static linking with
PKG_CONFIG='pkg-config --static' but then the same isn't done for
resolve_btfids, so "pkg-config libelf --libs" doesn't return -lzstd.

So maybe the solution is to define HOSTPKG_CONFIG when building
resolve_btfids, as in the following diff:

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 72a9ba41f95e..d5acbeba0383 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -409,6 +409,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids        \
                CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
                LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \
                EXTRA_LDFLAGS='$(SAN_LDFLAGS) $(EXTRA_LDFLAGS)' \
+               HOSTPKG_CONFIG=$(PKG_CONFIG) \
                OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ)

 # Get Clang's default includes on this system, as opposed to those seen by

>  
>  HOSTCFLAGS_resolve_btfids += -g \
>            -I$(srctree)/tools/include \
> -- 
> 2.53.0
> 
> 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found
  2026-03-04 17:23 ` Paul Chaignon
@ 2026-03-04 19:24   ` Ihor Solodrai
  2026-03-04 21:58     ` Paul Chaignon
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Solodrai @ 2026-03-04 19:24 UTC (permalink / raw)
  To: Paul Chaignon
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Vitaly Chikunov, bpf, kernel-team

On 3/4/26 9:23 AM, Paul Chaignon wrote:
> On Mon, Mar 02, 2026 at 03:10:58PM -0800, Ihor Solodrai wrote:
>> The "|| echo -lzstd" default makes zstd an unconditional link
>> dependency of resolve_btfids. On systems where libzstd-dev is not
>> installed and pkg-config fails, the linker fails:
>>
>>   ld: cannot find -lzstd: No such file or directory
>>
>> libzstd is a transitive dependency of libelf, so the -lzstd flag is
>> strictly necessary only for static builds [1].
>>
>> Drop the -lzstd fallback to enable builds on systems without
>> libzstd-dev installed.
>>
>> Reported-by: BPF CI Bot (Claude Opus 4.6) <bot+bpf-ci@kernel.org>
>> Reported-by: Vitaly Chikunov <vt@altlinux.org>
>> Closes: https://lore.kernel.org/bpf/aaWqMcK-2AQw5dx8@altlinux.org/
>> Fixes: 4021848a903e ("selftests/bpf: Pass through build flags to bpftool and resolve_btfids")
>> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
>> ---
>>  tools/bpf/resolve_btfids/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
>> index ef083602b73a..5df897c881d3 100644
>> --- a/tools/bpf/resolve_btfids/Makefile
>> +++ b/tools/bpf/resolve_btfids/Makefile
>> @@ -66,7 +66,7 @@ LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
>>  LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
>>  
>>  ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
>> -ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null || echo -lzstd)
>> +ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null)
> 
> This change is currently failing in CI with "undefined reference to
> `ZSTD_xxx'" when trying to build resolve_btfids. I think this is

Hi Paul, thanks for taking a look.

I'm aware, I sent a v2 yesterday (with changed subject):
https://lore.kernel.org/bpf/20260303193954.1879948-1-ihor.solodrai@linux.dev/

Your diagnosis is correct, the HOSTPKG_CONFIG wasn't set.
I fixed that by adding a default in resolve_btfids/Makefile,
but your diff makes sense too, I think we should apply both.

> happening because the selftests use static linking with
> PKG_CONFIG='pkg-config --static' but then the same isn't done for
> resolve_btfids, so "pkg-config libelf --libs" doesn't return -lzstd.
> 
> So maybe the solution is to define HOSTPKG_CONFIG when building
> resolve_btfids, as in the following diff:
> 
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 72a9ba41f95e..d5acbeba0383 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -409,6 +409,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids        \
>                 CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
>                 LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \
>                 EXTRA_LDFLAGS='$(SAN_LDFLAGS) $(EXTRA_LDFLAGS)' \
> +               HOSTPKG_CONFIG=$(PKG_CONFIG) \
>                 OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ)
> 
>  # Get Clang's default includes on this system, as opposed to those seen by
> 
>>  
>>  HOSTCFLAGS_resolve_btfids += -g \
>>            -I$(srctree)/tools/include \
>> -- 
>> 2.53.0
>>
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found
  2026-03-04 19:24   ` Ihor Solodrai
@ 2026-03-04 21:58     ` Paul Chaignon
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Chaignon @ 2026-03-04 21:58 UTC (permalink / raw)
  To: Ihor Solodrai
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Vitaly Chikunov, bpf, kernel-team

On Wed, Mar 04, 2026 at 11:24:54AM -0800, Ihor Solodrai wrote:
> On 3/4/26 9:23 AM, Paul Chaignon wrote:
> > On Mon, Mar 02, 2026 at 03:10:58PM -0800, Ihor Solodrai wrote:
> >> The "|| echo -lzstd" default makes zstd an unconditional link
> >> dependency of resolve_btfids. On systems where libzstd-dev is not
> >> installed and pkg-config fails, the linker fails:
> >>
> >>   ld: cannot find -lzstd: No such file or directory
> >>
> >> libzstd is a transitive dependency of libelf, so the -lzstd flag is
> >> strictly necessary only for static builds [1].
> >>
> >> Drop the -lzstd fallback to enable builds on systems without
> >> libzstd-dev installed.
> >>
> >> Reported-by: BPF CI Bot (Claude Opus 4.6) <bot+bpf-ci@kernel.org>
> >> Reported-by: Vitaly Chikunov <vt@altlinux.org>
> >> Closes: https://lore.kernel.org/bpf/aaWqMcK-2AQw5dx8@altlinux.org/
> >> Fixes: 4021848a903e ("selftests/bpf: Pass through build flags to bpftool and resolve_btfids")
> >> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> >> ---
> >>  tools/bpf/resolve_btfids/Makefile | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> >> index ef083602b73a..5df897c881d3 100644
> >> --- a/tools/bpf/resolve_btfids/Makefile
> >> +++ b/tools/bpf/resolve_btfids/Makefile
> >> @@ -66,7 +66,7 @@ LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
> >>  LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
> >>  
> >>  ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
> >> -ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null || echo -lzstd)
> >> +ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null)
> > 
> > This change is currently failing in CI with "undefined reference to
> > `ZSTD_xxx'" when trying to build resolve_btfids. I think this is
> 
> Hi Paul, thanks for taking a look.
> 
> I'm aware, I sent a v2 yesterday (with changed subject):
> https://lore.kernel.org/bpf/20260303193954.1879948-1-ihor.solodrai@linux.dev/

Ah, v1 was still marked as New in patchwork (probably due to changed
subject) so I missed it wasn't the latest :')

> 
> Your diagnosis is correct, the HOSTPKG_CONFIG wasn't set.
> I fixed that by adding a default in resolve_btfids/Makefile,
> but your diff makes sense too, I think we should apply both.
> 
> > happening because the selftests use static linking with
> > PKG_CONFIG='pkg-config --static' but then the same isn't done for
> > resolve_btfids, so "pkg-config libelf --libs" doesn't return -lzstd.
> > 
> > So maybe the solution is to define HOSTPKG_CONFIG when building
> > resolve_btfids, as in the following diff:
> > 
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index 72a9ba41f95e..d5acbeba0383 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -409,6 +409,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids        \
> >                 CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
> >                 LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \
> >                 EXTRA_LDFLAGS='$(SAN_LDFLAGS) $(EXTRA_LDFLAGS)' \
> > +               HOSTPKG_CONFIG=$(PKG_CONFIG) \
> >                 OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ)
> > 
> >  # Get Clang's default includes on this system, as opposed to those seen by
> > 
> >>  
> >>  HOSTCFLAGS_resolve_btfids += -g \
> >>            -I$(srctree)/tools/include \
> >> -- 
> >> 2.53.0
> >>
> >>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-04 21:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 23:10 [PATCH bpf v1] resolve_btfids: Drop -lzstd fallback if libzstd not found Ihor Solodrai
2026-03-04 17:23 ` Paul Chaignon
2026-03-04 19:24   ` Ihor Solodrai
2026-03-04 21:58     ` Paul Chaignon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox