public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Amery Hung" <ameryhung@gmail.com>,
	"Mykyta Yatsenko" <yatsenko@meta.com>,
	"Alexis Lothoré" <alexis.lothore@bootlin.com>,
	bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	"Kernel Team" <kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v1 01/14] selftests/bpf: Pass through build flags to bpftool and resolve_btfids
Date: Thu, 12 Feb 2026 16:08:47 -0800	[thread overview]
Message-ID: <4ff82800-2daa-4b9f-95a9-6f512859ee70@linux.dev> (raw)
In-Reply-To: <a93dd012-8c01-43f3-ac7b-befbc2a83341@linux.dev>

On 2/11/26 7:08 PM, Ihor Solodrai wrote:
> 
> 
> On 2/11/26 6:39 PM, Alexei Starovoitov wrote:
>> On Wed, Feb 11, 2026 at 5:14 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote:
>>>
>>> EXTRA_* and SAN_* build flags were not correctly propagated to bpftool
>>> and resolve_btids when building selftests/bpf. This led to various
>>> build errors on attempt to build with SAN_CFLAGS="-fsanitize=address",
>>> for example.
>>>
>>> Fix the makefiles to address this:
>>>   - Pass SAN_CFLAGS/SAN_LDFLAGS to bpftool and resolve_btfids build
>>>   - Propagate EXTRA_LDFLAGS to resolve_btfids link command
>>>   - Use pkg-config to detect zlib and zstd for resolve_btfids, similar
>>>     libelf handling
>>>
>>> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
>>> ---
>>>  tools/bpf/resolve_btfids/Makefile    | 7 +++++--
>>>  tools/testing/selftests/bpf/Makefile | 9 +++++----
>>>  2 files changed, 10 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
>>> index 1733a6e93a07..ef083602b73a 100644
>>> --- a/tools/bpf/resolve_btfids/Makefile
>>> +++ b/tools/bpf/resolve_btfids/Makefile
>>> @@ -65,6 +65,9 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
>>>  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)
>>
>> The first two patches look serious enough and justify going to bpf tree.
>> The rest can probably go via bpf as well, since we're early
>> in the merge window.
>> Would be great to have some Acks first though.
>>
>> Why add zstd here? It's not used by resolve_btfid. Why add it?
> 
> IIRC zstd is a transitive dependency of libelf.
> 
> I stumbled on a combination of build flags that caused link errors
> because of this missing.  I can find or produce an example log later
> if that'd be helpful.

Reproduced the splat. See below.

Basically, the bug here was that building selftests/bpf with
EXTRA_LDFLAGS="-static" didn't propagate -static to resolve_btfids so
zstd and co were actually linked dynamically.

After I fixed the propagation of EXTRA_LDFLAGS, the static build of
selftests would fail on linking of resolve_btfids, because of -zstd
missing:

  LINK     resolve_btfids
/usr/bin/x86_64-linux-gnu-ld.bfd: /lib/x86_64-linux-gnu/libelf.a(elf_compress.o): in function `__libelf_compress':
(.text+0xe4): undefined reference to `ZSTD_createCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x243): undefined reference to `ZSTD_compressStream2'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x24e): undefined reference to `ZSTD_isError'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x272): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x4ff): undefined reference to `ZSTD_compressStream2'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x50a): undefined reference to `ZSTD_isError'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x6e1): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x708): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x78e): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x828): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0x8f7): undefined reference to `ZSTD_freeCCtx'
/usr/bin/x86_64-linux-gnu-ld.bfd: /lib/x86_64-linux-gnu/libelf.a(elf_compress.o): in function `__libelf_decompress':
(.text+0xaf7): undefined reference to `ZSTD_decompress'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0xb02): undefined reference to `ZSTD_isError'
/usr/bin/x86_64-linux-gnu-ld.bfd: /lib/x86_64-linux-gnu/libelf.a(elf_compress.o): in function `__libelf_decompress_elf':
(.text+0xc37): undefined reference to `ZSTD_decompress'
/usr/bin/x86_64-linux-gnu-ld.bfd: (.text+0xc42): undefined reference to `ZSTD_isError'
clang-21: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:89: /ws/linux/tools/testing/selftests/bpf/tools/build/resolve_btfids//resolve_btfids] Error 1
make: *** [Makefile:404: /ws/linux/tools/testing/selftests/bpf/tools/build/resolve_btfids/resolve_btfids] Error 2
make: *** Waiting for unfinished jobs....





  reply	other threads:[~2026-02-13  0:09 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12  1:13 [PATCH bpf-next v1 00/14] selftests/bpf: Fixes for userspace ASAN Ihor Solodrai
2026-02-12  1:13 ` [PATCH bpf-next v1 01/14] selftests/bpf: Pass through build flags to bpftool and resolve_btfids Ihor Solodrai
2026-02-12  2:39   ` Alexei Starovoitov
2026-02-12  3:08     ` Ihor Solodrai
2026-02-13  0:08       ` Ihor Solodrai [this message]
2026-02-12  1:13 ` [PATCH bpf-next v1 02/14] resolve_btfids: Fix memory leaks reported by ASAN Ihor Solodrai
2026-02-12 11:28   ` Jiri Olsa
2026-02-12  1:13 ` [PATCH bpf-next v1 03/14] selftests/bpf: Add DENYLIST.asan Ihor Solodrai
2026-02-12  1:13 ` [PATCH bpf-next v1 04/14] selftests/bpf: Refactor bpf_get_ksyms() trace helper Ihor Solodrai
2026-02-12 11:29   ` Jiri Olsa
2026-02-17 20:42     ` Ihor Solodrai
2026-02-18 13:14       ` Jiri Olsa
2026-02-13  9:56   ` Alexis Lothoré
2026-02-12  1:13 ` [PATCH bpf-next v1 05/14] selftests/bpf: Fix memory leaks in tests Ihor Solodrai
2026-02-12 23:08   ` Eduard Zingerman
2026-02-12  1:13 ` [PATCH bpf-next v1 06/14] selftests/bpf: Fix cleanup in check_fd_array_cnt__fd_array_too_big() Ihor Solodrai
2026-02-12 23:17   ` Eduard Zingerman
2026-02-12  1:13 ` [PATCH bpf-next v1 07/14] veristat: Fix a memory leak for preset ENUMERATOR Ihor Solodrai
2026-02-12 13:37   ` Mykyta Yatsenko
2026-02-12  1:13 ` [PATCH bpf-next v1 08/14] selftests/bpf: Fix use-after-free in xdp_metadata test Ihor Solodrai
2026-02-12 13:40   ` Mykyta Yatsenko
2026-02-12  1:13 ` [PATCH bpf-next v1 09/14] selftests/bpf: Fix double thread join in uprobe_multi_test Ihor Solodrai
2026-02-12 11:29   ` Jiri Olsa
2026-02-12 14:49   ` Mykyta Yatsenko
2026-02-13 16:48     ` Jiri Olsa
2026-02-12  1:13 ` [PATCH bpf-next v1 10/14] selftests/bpf: Fix resource leaks caused by missing cleanups Ihor Solodrai
2026-02-13  0:45   ` Eduard Zingerman
2026-02-12  1:13 ` [PATCH bpf-next v1 11/14] selftests/bpf: Free bpf_object in test_sysctl Ihor Solodrai
2026-02-13  0:54   ` Eduard Zingerman
2026-02-12  1:13 ` [PATCH bpf-next v1 12/14] selftests/bpf: Fix array bounds warning in jit_disasm_helpers Ihor Solodrai
2026-02-13  1:02   ` Eduard Zingerman
2026-02-12  1:13 ` [PATCH bpf-next v1 13/14] selftests/bpf: Fix out-of-bounds array access bugs reported by ASAN Ihor Solodrai
2026-02-13  1:11   ` Eduard Zingerman
2026-02-17 23:27     ` Ihor Solodrai
2026-02-12  1:13 ` [PATCH bpf-next v1 14/14] selftests/bpf: Check BPFTOOL env var in detect_bpftool_path() Ihor Solodrai
2026-02-12 15:03   ` Mykyta Yatsenko
2026-02-13 10:36   ` Alexis Lothoré
2026-02-12 22:00 ` [PATCH bpf-next v1 00/14] selftests/bpf: Fixes for userspace ASAN Eduard Zingerman
2026-02-12 23:57   ` Ihor Solodrai
2026-02-13  0:23     ` Eduard Zingerman
2026-02-13 16:13       ` Ihor Solodrai
2026-02-13 18:06         ` Eduard Zingerman
2026-02-12 23:26 ` Eduard Zingerman
2026-02-13 17:56   ` Ihor Solodrai
2026-02-13 18:09     ` Eduard Zingerman
2026-02-13 18:29       ` Ihor Solodrai
2026-02-13 18:35         ` Eduard Zingerman

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=4ff82800-2daa-4b9f-95a9-6f512859ee70@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yatsenko@meta.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox