public inbox for linux-trace-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: linux-trace-devel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] Fix build failure due to btf on Linux < 6.0
Date: Thu, 12 Mar 2026 21:36:55 +0100	[thread overview]
Message-ID: <7002d259-d8b8-452a-98dc-c5ef29f16591@benettiengineering.com> (raw)
In-Reply-To: <20260312195733.3034533-1-giulio.benetti@benettiengineering.com>

Please drop this patch that is buggy.

V2 is coming.
Sorry for the noise

Best regards
Giulio

On 12/03/2026 20:57, Giulio Benetti wrote:
> With commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6089fb325cf737eeb2c4d236c94697112ca860da
> enum BTF_KIND_ENUM64 has been firstly introduced and this is the latest
> BTF_KIND_* enumaration to be added to libtraceevent. So let's check
> in runtime, both in Makefile and meson, if BTF_KIND_ENUM64 does exist.
> If it's not there let's disable btf support.
> 
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> Co-authored-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> ---
>   Makefile        | 28 +++++++++++++++++++++-------
>   src/meson.build | 12 ++++++++++++
>   src/trace-btf.c | 10 ++++++++++
>   3 files changed, 43 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index e1a10a0..bd88a98 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -27,6 +27,13 @@ $(call allow-override,PKG_CONFIG,pkg-config)
>   $(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
>   $(call allow-override,LDCONFIG,ldconfig)
>   
> +# Set compile option CFLAGS
> +ifdef EXTRA_CFLAGS
> +  CFLAGS ?= $(EXTRA_CFLAGS)
> +else
> +  CFLAGS ?= -g -Wall
> +endif
> +
>   EXT = -std=gnu99
>   INSTALL = install
>   
> @@ -37,6 +44,20 @@ INSTALL = install
>   DESTDIR ?=
>   DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
>   
> +test-build = $(if $(shell sh -c 'echo "$(1)" | tee /tmp/t.c| \
> +	$(CC) -o /dev/null -x c - > /dev/null 2>&1 && echo y'), $2)
> +
> +define BTF_LATEST_SOURCE
> +#include <linux/btf.h>
> +int main(void) { return BTF_KIND_ENUM64; }
> +endef
> +
> +BTF_OK := $(call test-build,$(BTF_LATEST_SOURCE),y)
> +
> +ifneq ($(strip $(BTF_OK)), y)
> +CFLAGS += -DNO_BTF
> +endif
> +
>   LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
>   ifeq ($(LP64), 1)
>     libdir_relative_temp = lib64
> @@ -123,13 +144,6 @@ INCLUDES = -I. -I $(srctree)/include -I $(EP_HEADERS_DIR) $(CONFIG_INCLUDES)
>   
>   export LIBTRACEEVENT_STATIC LIBTRACEEVENT_SHARED EP_HEADERS_DIR
>   
> -# Set compile option CFLAGS
> -ifdef EXTRA_CFLAGS
> -  CFLAGS := $(EXTRA_CFLAGS)
> -else
> -  CFLAGS := -g -Wall
> -endif
> -
>   LIBS ?= -ldl
>   export LIBS
>   
> diff --git a/src/meson.build b/src/meson.build
> index 3a7a082..23b43ff 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -17,6 +17,18 @@ sources= [
>   cc = meson.get_compiler('c')
>   dl_dep = cc.find_library('dl')
>   
> +btf_enum64_test_code = '''
> +#include <linux/btf.h>
> +int main(void) {
> +    int x = BTF_KIND_ENUM64;
> +    return 0;
> +}
> +'''
> +
> +if cc.compiles(btf_enum64_test_code, name : 'BTF_KIND_ENUM64 check')
> +    add_project_arguments('-DNO_BTF', language : 'c')
> +endif
> +
>   libtraceevent = library(
>       'traceevent',
>       sources,
> diff --git a/src/trace-btf.c b/src/trace-btf.c
> index 859b086..4e3a853 100644
> --- a/src/trace-btf.c
> +++ b/src/trace-btf.c
> @@ -471,6 +471,9 @@ static int init_btf_func(struct tep_btf *btf, struct trace_seq *s,
>    */
>   int tep_btf_list_args(struct tep_handle *tep, struct trace_seq *s, const char *func)
>   {
> +#ifdef NO_BTF
> +	return -1;
> +#else
>   	struct tep_btf *btf = tep->btf;
>   	struct btf_type *type = tep_btf_find_func(btf, func);
>   	struct btf_param *param;
> @@ -520,6 +523,7 @@ int tep_btf_list_args(struct tep_handle *tep, struct trace_seq *s, const char *f
>   			trace_seq_printf(s, "%s", param_name);
>   	}
>   	return p;
> +#endif
>   }
>   
>   /**
> @@ -543,6 +547,11 @@ int tep_btf_list_args(struct tep_handle *tep, struct trace_seq *s, const char *f
>   int tep_btf_print_args(struct tep_handle *tep, struct trace_seq *s, void *args,
>   		       int nmem, int size, const char *func)
>   {
> +#ifdef NO_BTF
> +	tep_warning("BTF not supported. Args:\n
> +		    args: %08x, nmem: %d, size: %d, func: %08x\n");
> +	return -1;
> +#else
>   	struct tep_btf *btf = tep->btf;
>   	struct btf_type *type = tep_btf_find_func(btf, func);
>   	struct btf_param *param;
> @@ -646,4 +655,5 @@ int tep_btf_print_args(struct tep_handle *tep, struct trace_seq *s, void *args,
>   		}
>   	}
>   	return 0;
> +#endif
>   }


      reply	other threads:[~2026-03-12 20:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 19:57 [PATCH] Fix build failure due to btf on Linux < 6.0 Giulio Benetti
2026-03-12 20:36 ` Giulio Benetti [this message]

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=7002d259-d8b8-452a-98dc-c5ef29f16591@benettiengineering.com \
    --to=giulio.benetti@benettiengineering.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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