Message ID | 1677585781-21628-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive) |
---|---|
State | Accepted |
Commit | be35f4af719c94df137cd611bf497d658eb3adc2 |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,v3] selftests/bpf: Set __BITS_PER_LONG if target is bpf for LoongArch | expand |
On Tue, Feb 28, 2023 at 4:03 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > If target is bpf, there is no __loongarch__ definition, __BITS_PER_LONG > defaults to 32, __NR_nanosleep is not defined: > > #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 > #define __NR_nanosleep 101 > __SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) > #endif > > Work around this problem, by explicitly setting __BITS_PER_LONG to > __loongarch_grlen which is defined by compiler as 64 for LA64, then > __NR_nanosleep can also be defined to fix the following build errors: > > clang -g -Werror ... -target bpf -c progs/test_vmlinux.c ... > progs/test_vmlinux.c:24:18: error: use of undeclared identifier '__NR_nanosleep' > if (args->id != __NR_nanosleep) > ^ > progs/test_vmlinux.c:42:12: error: use of undeclared identifier '__NR_nanosleep' > if (id != __NR_nanosleep) > ^ > progs/test_vmlinux.c:60:12: error: use of undeclared identifier '__NR_nanosleep' > if (id != __NR_nanosleep) > ^ > 3 errors generated. Not clear what __NR_nanosleep part has to do with this commit. I dropped this part from the commit message. Applied to bpf-next. > > This is similar with commit 36e70b9b06bf ("selftests, bpf: Fix broken > riscv build"). > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > tools/testing/selftests/bpf/Makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index b677dcd..f40606a 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -338,7 +338,8 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ > define get_sys_includes > $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ > | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ > -$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') > +$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') \ > +$(shell $(1) $(2) -dM -E - </dev/null | grep '__loongarch_grlen ' | awk '{printf("-D__BITS_PER_LONG=%d", $$3)}') > endef > > # Determine target endianness. > -- > 2.1.0 >
Hello: This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <andrii@kernel.org>: On Tue, 28 Feb 2023 20:03:01 +0800 you wrote: > If target is bpf, there is no __loongarch__ definition, __BITS_PER_LONG > defaults to 32, __NR_nanosleep is not defined: > > #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 > #define __NR_nanosleep 101 > __SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) > #endif > > [...] Here is the summary with links: - [bpf-next,v3] selftests/bpf: Set __BITS_PER_LONG if target is bpf for LoongArch https://git.kernel.org/bpf/bpf-next/c/be35f4af719c You are awesome, thank you!
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index b677dcd..f40606a 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -338,7 +338,8 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ define get_sys_includes $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ -$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') +$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') \ +$(shell $(1) $(2) -dM -E - </dev/null | grep '__loongarch_grlen ' | awk '{printf("-D__BITS_PER_LONG=%d", $$3)}') endef # Determine target endianness.
If target is bpf, there is no __loongarch__ definition, __BITS_PER_LONG defaults to 32, __NR_nanosleep is not defined: #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_nanosleep 101 __SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) #endif Work around this problem, by explicitly setting __BITS_PER_LONG to __loongarch_grlen which is defined by compiler as 64 for LA64, then __NR_nanosleep can also be defined to fix the following build errors: clang -g -Werror ... -target bpf -c progs/test_vmlinux.c ... progs/test_vmlinux.c:24:18: error: use of undeclared identifier '__NR_nanosleep' if (args->id != __NR_nanosleep) ^ progs/test_vmlinux.c:42:12: error: use of undeclared identifier '__NR_nanosleep' if (id != __NR_nanosleep) ^ progs/test_vmlinux.c:60:12: error: use of undeclared identifier '__NR_nanosleep' if (id != __NR_nanosleep) ^ 3 errors generated. This is similar with commit 36e70b9b06bf ("selftests, bpf: Fix broken riscv build"). Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- tools/testing/selftests/bpf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)