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@xxxxxxxxxx/ >> >> Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx> >> --- >> 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