From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "David Faust" <david.faust@oracle.com>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <yonghong.song@linux.dev>,
<eddyz87@gmail.com>, <jose.marchesi@oracle.com>,
<cupertino.miranda@oracle.com>, <vineet.gupta@linux.dev>
Subject: Re: [PATCH bpf-next] selftests/bpf: remove string.h includes in bpf progs
Date: Tue, 21 Apr 2026 14:07:52 -0700 [thread overview]
Message-ID: <DHZ51LAF3MRD.20EUP6N4BB5P@gmail.com> (raw)
In-Reply-To: <20260421202233.528128-1-david.faust@oracle.com>
On Tue Apr 21, 2026 at 1:22 PM PDT, David Faust wrote:
> Sources for some BPF test programs currently include string.h, which
> is a glibc header and not a toolchain header. Since there is no BPF
> glibc, this means it is the native system glibc string.h which gets
> included when building the test programs.
>
> In all cases the include is only necessary for the prototypes of
> non-builtin versions of memset, memcpy, etc., and in every case both
> clang and gcc already replace these with the compiler built-in versions
> and expand them inline.
>
> In the case of gcc this replacement happens after initial debuginfo is
> generated, which includes the calls to the glibc routines. This means a
> BTF record for e.g. 'extern memset' is emitted, resulting in load
> failures like:
>
> libbpf: BTF loading error: -22
> ...
> [26] FUNC memset type_id=1 Invalid func linkage
...
> - memcpy(&val, keys, sizeof(val));
> + __builtin_memcpy(&val, keys, sizeof(val));
This is not an option. It works for llvm because it inlines it for small sizes.
GCC should do the same.
For large sizes llvm will emit libcall to memset
that libbpf will error with "FUNC memset type_id=1 Invalid func linkage"
and that's a separate issue to deal with.
pw-bot: cr
next prev parent reply other threads:[~2026-04-21 21:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 20:22 [PATCH bpf-next] selftests/bpf: remove string.h includes in bpf progs David Faust
2026-04-21 21:07 ` Alexei Starovoitov [this message]
2026-04-22 0:15 ` David Faust
2026-04-22 0:57 ` Alexei Starovoitov
2026-04-21 21:08 ` Vineet Gupta
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=DHZ51LAF3MRD.20EUP6N4BB5P@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cupertino.miranda@oracle.com \
--cc=david.faust@oracle.com \
--cc=eddyz87@gmail.com \
--cc=jose.marchesi@oracle.com \
--cc=vineet.gupta@linux.dev \
--cc=yonghong.song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox