On Tue, Feb 28, 2023 at 4:03 AM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> 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@xxxxxxxxxxx> > --- > 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 >