From: Alan Maguire <alan.maguire@oracle.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>,
dwarves@vger.kernel.org, bpf@vger.kernel.org
Cc: acme@kernel.org, ast@kernel.org, andrii@kernel.org,
eddyz87@gmail.com, mykolal@fb.com, kernel-team@meta.com
Subject: Re: [PATCH dwarves v4 2/6] btf_encoder: use __weak declarations of version-dependent libbpf API
Date: Thu, 6 Mar 2025 17:14:42 +0000 [thread overview]
Message-ID: <d29261bd-a08d-4519-88bc-96f19edbbc29@oracle.com> (raw)
In-Reply-To: <050b81d2c82f57f3e97b27c59198a08b1c8d7f7b@linux.dev>
On 28/02/2025 19:53, Ihor Solodrai wrote:
> On 2/28/25 11:46 AM, Ihor Solodrai wrote:
>> Instead of compile-time checks for libbpf version, use __weak
>> declarations of the required API functions and do runtime checks at
>> the call sites. This will help with compatibility when libbpf is
>> dynamically linked to pahole [1].
>>
>> [1] https://lore.kernel.org/dwarves/deff78f8-1f99-4c79-a302-cff8dce4d803@oracle.com/
>>
>> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
>> ---
>> btf_encoder.c | 48 +++++++++++++++++++-----------------------------
>> dwarves.h | 11 ++++++++++-
>> pahole.c | 2 --
>> 3 files changed, 29 insertions(+), 32 deletions(-)
>>
>> diff --git a/btf_encoder.c b/btf_encoder.c
>> index 2bea5ee..12a040f 100644
>> --- a/btf_encoder.c
>> +++ b/btf_encoder.c
>> @@ -34,6 +34,7 @@
>> #include <search.h> /* for tsearch(), tfind() and tdestroy() */
>> #include <pthread.h>
>>
>> +#define BTF_BASE_ELF_SEC ".BTF.base"
>> #define BTF_IDS_SECTION ".BTF_ids"
>> #define BTF_ID_FUNC_PFX "__BTF_ID__func__"
>> #define BTF_ID_SET8_PFX "__BTF_ID__set8__"
>> @@ -625,29 +626,6 @@ static int32_t btf_encoder__add_struct(struct btf_encoder *encoder, uint8_t kind
>> return id;
>> }
>>
>> -#if LIBBPF_MAJOR_VERSION < 1
>
> There is an identical condition in btf_loader.c, however it guards
> static functions, for example btf_enum64(). I decided to leave it as
> is, although I find it unlikely that someone would use libbpf < 1.0.
>
>> [...]
yeah, I just noticed we've got a minimum version requirement of 0.4:
pkg_check_modules(LIBBPF REQUIRED libbpf>=0.4.0)
That needs to be revisited in the future to be > v1.0 I would say. To
test libbpf shared library support, I tried building with libbpf v1.2,
but hit errors around absence of struct btf_enum64. Looks like these
compilation errors resulted from not having an up-to-date
/usr/include/linux/btf.h (IIRC the libbpf repo ships with a copy, maybe
we should do the same?). The errors are not caused by your series, so
not something you need to worry about, but more work is needed to better
support shared library builds even for libbpf > 1.0 it seems. Thanks!
Alan
next prev parent reply other threads:[~2025-03-06 17:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 19:46 [PATCH dwarves v4 0/6] btf_encoder: emit type tags for bpf_arena pointers Ihor Solodrai
2025-02-28 19:46 ` [PATCH dwarves v4 1/6] btf_encoder: refactor btf_encoder__tag_kfuncs() Ihor Solodrai
2025-02-28 19:46 ` [PATCH dwarves v4 2/6] btf_encoder: use __weak declarations of version-dependent libbpf API Ihor Solodrai
2025-02-28 19:53 ` Ihor Solodrai
2025-03-06 17:14 ` Alan Maguire [this message]
2025-02-28 19:46 ` [PATCH dwarves v4 3/6] pahole: sync with libbpf mainline Ihor Solodrai
2025-02-28 19:46 ` [PATCH dwarves v4 4/6] btf_encoder: emit type tags for bpf_arena pointers Ihor Solodrai
2025-02-28 19:46 ` [PATCH dwarves v4 5/6] pahole: introduce --btf_feature=attributes Ihor Solodrai
2025-02-28 19:46 ` [PATCH dwarves v4 6/6] man-pages: describe attributes and remove reproducible_build Ihor Solodrai
2025-03-20 16:32 ` [PATCH dwarves v4 0/6] btf_encoder: emit type tags for bpf_arena pointers Ihor Solodrai
2025-03-20 20:34 ` Alan Maguire
2025-03-23 11:11 ` Alan Maguire
2025-03-24 18:07 ` Ihor Solodrai
2025-03-24 18:47 ` Ihor Solodrai
2025-03-25 9:59 ` Alan Maguire
2025-03-26 17:41 ` Ihor Solodrai
2025-03-27 8:22 ` Alan Maguire
2025-03-27 15:33 ` Ihor Solodrai
2025-03-27 15:40 ` Alan Maguire
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=d29261bd-a08d-4519-88bc-96f19edbbc29@oracle.com \
--to=alan.maguire@oracle.com \
--cc=acme@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=mykolal@fb.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