diff mbox series

[bpf-next,4/4] selftests/bpf: Fix broken riscv build

Message ID 20211028132041.516820-5-bjorn@kernel.org (mailing list archive)
State New, archived
Headers show
Series Various RISC-V BPF improvements | expand

Commit Message

Björn Töpel Oct. 28, 2021, 1:20 p.m. UTC
This patch is closely related to commit 6016df8fe874 ("selftests/bpf:
Fix broken riscv build"). When clang includes the system include
directories, but targeting BPF program, __BITS_PER_LONG defaults to
32, unless explicitly set. Workaround this problem, by explicitly
setting __BITS_PER_LONG to __riscv_xlen.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---
 tools/testing/selftests/bpf/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Björn Töpel Oct. 28, 2021, 3:58 p.m. UTC | #1
On Thu, 28 Oct 2021 at 15:20, Björn Töpel <bjorn@kernel.org> wrote:
>
> This patch is closely related to commit 6016df8fe874 ("selftests/bpf:
> Fix broken riscv build"). When clang includes the system include
> directories, but targeting BPF program, __BITS_PER_LONG defaults to
> 32, unless explicitly set. Workaround this problem, by explicitly
> setting __BITS_PER_LONG to __riscv_xlen.
>
> Signed-off-by: Björn Töpel <bjorn@kernel.org>
> ---
>  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 ac47cf9760fc..d739e62d0f90 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -277,7 +277,8 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids        \
>  define get_sys_includes
>  $(shell $(1) -v -E - </dev/null 2>&1 \
>         | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
> -$(shell $(1) -dM -E - </dev/null | grep '#define __riscv_xlen ' | sed 's/#define /-D/' | sed 's/ /=/')
> +$(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
> +

Argh, this messes things up. I'll spin a v2 with the extra NL removed.

Björn

>  endef
>
>  # Determine target endianness.
> --
> 2.32.0
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index ac47cf9760fc..d739e62d0f90 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -277,7 +277,8 @@  $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids	\
 define get_sys_includes
 $(shell $(1) -v -E - </dev/null 2>&1 \
 	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
-$(shell $(1) -dM -E - </dev/null | grep '#define __riscv_xlen ' | sed 's/#define /-D/' | sed 's/ /=/')
+$(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
+
 endef
 
 # Determine target endianness.