Re: [PATCH] bpftool: Fix generated code in codegen_asserts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Mon, Mar 28, 2022 at 10:37:03AM +0200, Jiri Olsa escreveu:
> Arnaldo reported perf compilation fail with:
> 
>   $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 PYTHON=python3
>   ...
>   In file included from util/bpf_counter.c:28:
>   /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h: In function ‘bperf_leader_bpf__assert’:
>   /tmp/build/perf//util/bpf_skel/bperf_leader.skel.h:351:51: error: unused parameter ‘s’ [-Werror=unused-parameter]
>     351 | bperf_leader_bpf__assert(struct bperf_leader_bpf *s)
>         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~^
>   cc1: all warnings being treated as errors
> 
> If there's nothing to generate in the new assert function,
> we will get unused 's' warn/error, adding 'unused' attribute to it.

We need some Makefile dependency to trigger the skels to be regenerated
when bpftool is updated.

And before that to notice that the bpftool source code changed and thus
the bootstrap bpftool needs to be rebuilt.

So, after a full tools/perf/ build from scratch it works:

Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Ah, and to wire up a tools/perf/ build when doing a selftests build
perhaps so that libbpf developers can check if in-kernel tools linking
against it still builds when they change libbpf/bpftool?

Regards,

- Arnaldo
 
> Cc: Delyan Kratunov <delyank@xxxxxx>
> Reported-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Fixes: 08d4dba6ae77 ("bpftool: Bpf skeletons assert type sizes")
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
>  tools/bpf/bpftool/gen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 7ba7ff55d2ea..91af2850b505 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -477,7 +477,7 @@ static void codegen_asserts(struct bpf_object *obj, const char *obj_name)
>  	codegen("\
>  		\n\
>  		__attribute__((unused)) static void			    \n\
> -		%1$s__assert(struct %1$s *s)				    \n\
> +		%1$s__assert(struct %1$s *s __attribute__((unused)))	    \n\
>  		{							    \n\
>  		#ifdef __cplusplus					    \n\
>  		#define _Static_assert static_assert			    \n\
> -- 
> 2.35.1

-- 

- Arnaldo



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux