bcc icon indicating copy to clipboard operation
bcc copied to clipboard

libbpf-tools: fix build error on ppc64el (#5330)

Open seb128 opened this issue 6 months ago • 5 comments

bashreadline.c: In function ‘handle_lost_events’: bashreadline.c:90:14: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Werror=format=] 90 | warn("lost %llu events on CPU #%d\n", lost_cnt, cpu); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ | | | __u64 {aka long unsigned int}

seb128 avatar Jun 12 '25 10:06 seb128

in fact the fix is incomplete since the other sources have the same issue, I will work on changing also those

seb128 avatar Jun 12 '25 11:06 seb128

I've edited the other files and force pushed now, but then I'm hitting the same error for other variables

biopattern.c: In function ‘print_map’:
biopattern.c:140:49: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 6 has type ‘__u64’ {aka ‘long unsigned int’} [-Werror=format=]
  140 |                 printf("%-7s %5ld %5ld %8d %10lld\n",
      |                                            ~~~~~^
      |                                                 |
      |                                                 long long int
      |                                            %10ld
......
  144 |                         counter.bytes / 1024);
      |                         ~~~~~~~~~~~~~~~~~~~~     
      |                                       |
      |                                       __u64 {aka long unsigned int}
cc1: all warnings being treated as errors
make[2]: *** [Makefile:190: /<<PKGBUILDDIR>>/libbpf-tools/.output/biopattern.o] Error 1
make[2]: Leaving directory '/<<PKGBUILDDIR>>/libbpf-tools'

Unsure if my current approach is the right way to try to fix it, I would welcome input on it...

seb128 avatar Jun 12 '25 13:06 seb128

Probably you can find out how __u64 is defined in your ppc64el platform?

In my x64 system, the __u64 is defined in /usr/include/asm-generic/int-ll64.h:

#ifdef __GNUC__
__extension__ typedef __signed__ long long __s64;
__extension__ typedef unsigned long long __u64;
#else
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

yonghong-song avatar Jun 19 '25 19:06 yonghong-song

On ppc64, __u64 is defined as an unsigned long in /usr/include/asm-generic/int-l64.h. I'm not sure what the compiler warning is about since, AFAICT, on ppc64 long and long long integer are both 64 bits. There must be some subtlety I'm missing. No doubt this issue has been brought to light by commit aeed9e23 ("libbpf-tools: Add flag -Werror=undef").

jeromemarchand avatar Jul 10 '25 12:07 jeromemarchand

The definition on the ppc64el machine is similar to the one shared before

#ifdef __GNUC__
__extension__ typedef __signed__ long long __s64;
__extension__ typedef unsigned long long __u64;
#else
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

seb128 avatar Jul 16 '25 13:07 seb128