Skip to contentSkip to conversation

selftest/bpf, riscv: Improved cross-building support

PATCH Applied Björn Töpel 3 participants 6 messages Oct 4, 2023

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover selftest/bpf, riscv: Improved cross-building support

From: Björn Töpel <[email protected]>

Yet another "more cross-building support for RISC-V" series.

An example how to invoke a gen_tar build:

  | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- CC=riscv64-linux-gnu-gcc \
  |    HOSTCC=gcc O=/workspace/kbuild FORMAT= \
  |    SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" -j $(($(nproc)-1)) \
  |    -C tools/testing/selftests gen_tar

Björn

Björn Töpel (3):
selftests/bpf: Add cross-build support for urandom_read et al selftests/bpf: Enable lld usage for RISC-V selftests/bpf: Add uprobe_multi to gen_tar target

 tools/testing/selftests/bpf/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

base-commit: 2147c8d07e1abc8dfc3433ca18eed5295e230ede

Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/3 selftests/bpf: Add cross-build support for urandom_read et al

From: Björn Töpel <[email protected]>

Some userland programs in the BPF test suite, e.g. urandom_read, is missing cross-build support. Add cross-build support for these programs

---
 tools/testing/selftests/bpf/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -2
index 47365161b6fc..a9cbb85fa180 100644
@@ -198,7 +198,7 @@ endif
 # do not fail. Static builds leave urandom_read relying on system-wide shared libraries.
 $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom_read.map
 	$(call msg,LIB,,$@)
-	$(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS))   \
+	$(Q)$(CLANG) $(CLANG_TARGET_ARCH) $(filter-out -static,$(CFLAGS) $(LDFLAGS))   \
 		     $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \
 		     -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
 		     -Wl,--version-script=liburandom_read.map \
@@ -206,7 +206,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c liburandom
 
 $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/liburandom_read.so
 	$(call msg,BINARY,,$@)
-	$(Q)$(CLANG) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
+	$(Q)$(CLANG) $(CLANG_TARGET_ARCH) $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \
 		     -lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT)  \
 		     -fuse-ld=$(LLD) -Wl,-znoseparate-code -Wl,--build-id=sha1 \
 		     -Wl,-rpath=. -o $@
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/3 selftests/bpf: Enable lld usage for RISC-V

In reply to Björn Töpel

From: Björn Töpel <[email protected]>

RISC-V has proper lld support. Use that, similar to what x86 does, for urandom_read et al.

---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index a9cbb85fa180..098e32c684d5 100644
@@ -188,7 +188,7 @@ $(OUTPUT)/%:%.c
 	$(Q)$(LINK.c) $^ $(LDLIBS) -o $@
 
 # LLVM's ld.lld doesn't support all the architectures, so use it only on x86
-ifeq ($(SRCARCH),x86)
+ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 riscv))
 LLD := lld
 else
 LLD := ld
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/3 selftests/bpf: Add uprobe_multi to gen_tar target

In reply to Björn Töpel

From: Björn Töpel <[email protected]>

The uprobe_multi program was not picked up for the gen_tar target. Fix by adding it to TEST_GEN_FILES.

---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 098e32c684d5..07ac73cc339d 100644
@@ -104,7 +104,7 @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \
 	xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \
 	xdp_features
 
-TEST_GEN_FILES += liburandom_read.so urandom_read sign-file
+TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi
 
 # Emit succinct information message describing current building step
 # $1 - generic step name (e.g., CC, LINK, etc);
Signature · 1 line
2.39.2
Acked-by on v1 3/3
#4 lore raw

Re: [PATCH bpf-next 3/3] selftests/bpf: Add uprobe_multi to gen_tar target

Quoted 6 lines · Björn Töpel

From: Björn Töpel <[email protected]>

The uprobe_multi program was not picked up for the gen_tar target. Fix by adding it to TEST_GEN_FILES.

thanks,
jirka

Quoted 21 lines
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 098e32c684d5..07ac73cc339d 100644
@@ -104,7 +104,7 @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \
 	xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \
 	xdp_features
 
-TEST_GEN_FILES += liburandom_read.so urandom_read sign-file
+TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi
 
 # Emit succinct information message describing current building step
 # $1 - generic step name (e.g., CC, LINK, etc);
Signature · 1 line
2.39.2
#5 lore raw
In reply to Björn Töpel
This series was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This series was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 4 lines · On Wed, 4 Oct 2023 14:27:18 +0200 you wrote:

From: Björn Töpel <[email protected]>

Yet another "more cross-building support for RISC-V" series.

Quoted 8 lines

An example how to invoke a gen_tar build:

  | make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- CC=riscv64-linux-gnu-gcc \
  |    HOSTCC=gcc O=/workspace/kbuild FORMAT= \
  |    SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" -j $(($(nproc)-1)) \
  |    -C tools/testing/selftests gen_tar

[...]

Here is the summary with links:
- [bpf-next,1/3] selftests/bpf: Add cross-build support for urandom_read et al

    https://git.kernel.org/bpf/bpf-next/c/97a79e502e25
  - [bpf-next,2/3] selftests/bpf: Enable lld usage for RISC-V
    https://git.kernel.org/bpf/bpf-next/c/72fae6319962
  - [bpf-next,3/3] selftests/bpf: Add uprobe_multi to gen_tar target
    https://git.kernel.org/bpf/bpf-next/c/e096ab9d9f45

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html