Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seb128
Copy link

@seb128 seb128 commented Jun 12, 2025

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
Copy link
Author

seb128 commented Jun 12, 2025

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

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 seb128 force-pushed the fix-ppc64el-build branch from 696993f to 59ed32d Compare June 12, 2025 13:17
@seb128
Copy link
Author

seb128 commented Jun 12, 2025

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...

@yonghong-song
Copy link
Collaborator

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

@jeromemarchand
Copy link
Contributor

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 aeed9e2 ("libbpf-tools: Add flag -Werror=undef").

@seb128
Copy link
Author

seb128 commented Jul 16, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants