* [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
@ 2021-01-25 5:05 Tiezhu Yang
2021-01-25 7:10 ` Yonghong Song
2021-01-25 23:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Tiezhu Yang @ 2021-01-25 5:05 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh
Cc: netdev, bpf, linux-mips, linux-kernel, Xuefeng Li
There exists many build warnings when make M=samples/bpf on the Loongson
platform, this issue is MIPS related, x86 compiles just fine.
Here are some warnings:
CC samples/bpf/ibumad_user.o
samples/bpf/ibumad_user.c: In function ‘dump_counts’:
samples/bpf/ibumad_user.c:46:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
printf("0x%02x : %llu\n", key, value);
~~~^ ~~~~~
%lu
CC samples/bpf/offwaketime_user.o
samples/bpf/offwaketime_user.c: In function ‘print_ksym’:
samples/bpf/offwaketime_user.c:34:17: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
printf("%s/%llx;", sym->name, addr);
~~~^ ~~~~
%lx
samples/bpf/offwaketime_user.c: In function ‘print_stack’:
samples/bpf/offwaketime_user.c:68:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
printf(";%s %lld\n", key->waker, count);
~~~^ ~~~~~
%ld
MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
'int-ll64.h' in arch/mips/include/uapi/asm/types.h, then it can avoid
build warnings when printing __u64 with %llu, %llx or %lld.
The header tools/include/linux/types.h defines __SANE_USERSPACE_TYPES__,
it seems that we can include <linux/types.h> in the source files which
have build warnings, but it has no effect due to actually it includes
usr/include/linux/types.h instead of tools/include/linux/types.h, the
problem is that "usr/include" is preferred first than "tools/include"
in samples/bpf/Makefile, that sounds like a ugly hack to -Itools/include
before -Iusr/include.
So define __SANE_USERSPACE_TYPES__ for MIPS in samples/bpf/Makefile
is proper, if add "TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__" in
samples/bpf/Makefile, it appears the following error:
Auto-detecting system features:
... libelf: [ on ]
... zlib: [ on ]
... bpf: [ OFF ]
BPF API too old
make[3]: *** [Makefile:293: bpfdep] Error 1
make[2]: *** [Makefile:156: all] Error 2
With #ifndef __SANE_USERSPACE_TYPES__ in tools/include/linux/types.h,
the above error has gone and this ifndef change does not hurt other
compilations.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
v2: Update the commit message
samples/bpf/Makefile | 4 ++++
tools/include/linux/types.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 26fc96c..27de306 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -183,6 +183,10 @@ BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
endif
+ifeq ($(ARCH), mips)
+TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
+endif
+
TPROGS_CFLAGS += -Wall -O2
TPROGS_CFLAGS += -Wmissing-prototypes
TPROGS_CFLAGS += -Wstrict-prototypes
diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
index 154eb4e..e9c5a21 100644
--- a/tools/include/linux/types.h
+++ b/tools/include/linux/types.h
@@ -6,7 +6,10 @@
#include <stddef.h>
#include <stdint.h>
+#ifndef __SANE_USERSPACE_TYPES__
#define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */
+#endif
+
#include <asm/types.h>
#include <asm/posix_types.h>
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
2021-01-25 5:05 [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
@ 2021-01-25 7:10 ` Yonghong Song
2021-01-25 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2021-01-25 7:10 UTC (permalink / raw)
To: Tiezhu Yang, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, John Fastabend,
KP Singh
Cc: netdev, bpf, linux-mips, linux-kernel, Xuefeng Li
On 1/24/21 9:05 PM, Tiezhu Yang wrote:
> There exists many build warnings when make M=samples/bpf on the Loongson
> platform, this issue is MIPS related, x86 compiles just fine.
>
> Here are some warnings:
>
> CC samples/bpf/ibumad_user.o
> samples/bpf/ibumad_user.c: In function ‘dump_counts’:
> samples/bpf/ibumad_user.c:46:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf("0x%02x : %llu\n", key, value);
> ~~~^ ~~~~~
> %lu
> CC samples/bpf/offwaketime_user.o
> samples/bpf/offwaketime_user.c: In function ‘print_ksym’:
> samples/bpf/offwaketime_user.c:34:17: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf("%s/%llx;", sym->name, addr);
> ~~~^ ~~~~
> %lx
> samples/bpf/offwaketime_user.c: In function ‘print_stack’:
> samples/bpf/offwaketime_user.c:68:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf(";%s %lld\n", key->waker, count);
> ~~~^ ~~~~~
> %ld
>
> MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
> 'int-ll64.h' in arch/mips/include/uapi/asm/types.h, then it can avoid
> build warnings when printing __u64 with %llu, %llx or %lld.
>
> The header tools/include/linux/types.h defines __SANE_USERSPACE_TYPES__,
> it seems that we can include <linux/types.h> in the source files which
> have build warnings, but it has no effect due to actually it includes
> usr/include/linux/types.h instead of tools/include/linux/types.h, the
> problem is that "usr/include" is preferred first than "tools/include"
> in samples/bpf/Makefile, that sounds like a ugly hack to -Itools/include
> before -Iusr/include.
>
> So define __SANE_USERSPACE_TYPES__ for MIPS in samples/bpf/Makefile
> is proper, if add "TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__" in
> samples/bpf/Makefile, it appears the following error:
>
> Auto-detecting system features:
> ... libelf: [ on ]
> ... zlib: [ on ]
> ... bpf: [ OFF ]
>
> BPF API too old
> make[3]: *** [Makefile:293: bpfdep] Error 1
> make[2]: *** [Makefile:156: all] Error 2
>
> With #ifndef __SANE_USERSPACE_TYPES__ in tools/include/linux/types.h,
> the above error has gone and this ifndef change does not hurt other
> compilations.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
2021-01-25 5:05 [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
2021-01-25 7:10 ` Yonghong Song
@ 2021-01-25 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-25 23:30 UTC (permalink / raw)
To: Tiezhu Yang
Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
kpsingh, netdev, bpf, linux-mips, linux-kernel, lixuefeng
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
On Mon, 25 Jan 2021 13:05:46 +0800 you wrote:
> There exists many build warnings when make M=samples/bpf on the Loongson
> platform, this issue is MIPS related, x86 compiles just fine.
>
> Here are some warnings:
>
> CC samples/bpf/ibumad_user.o
> samples/bpf/ibumad_user.c: In function ‘dump_counts’:
> samples/bpf/ibumad_user.c:46:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf("0x%02x : %llu\n", key, value);
> ~~~^ ~~~~~
> %lu
> CC samples/bpf/offwaketime_user.o
> samples/bpf/offwaketime_user.c: In function ‘print_ksym’:
> samples/bpf/offwaketime_user.c:34:17: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf("%s/%llx;", sym->name, addr);
> ~~~^ ~~~~
> %lx
> samples/bpf/offwaketime_user.c: In function ‘print_stack’:
> samples/bpf/offwaketime_user.c:68:17: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘__u64’ {aka ‘long unsigned int’} [-Wformat=]
> printf(";%s %lld\n", key->waker, count);
> ~~~^ ~~~~~
> %ld
>
> [...]
Here is the summary with links:
- [bpf-next,v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
https://git.kernel.org/bpf/bpf-next/c/190d1c921ad0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-25 23:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 5:05 [PATCH bpf-next v2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
2021-01-25 7:10 ` Yonghong Song
2021-01-25 23:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).