Skip to contentSkip to conversation

selftests/bpf: Fix cross-compiling urandom_read

PATCH Applied Tony Ambardar 2 participants 2 messages Oct 9, 2024 – Oct 11, 2024

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

PATCH 1/1 selftests/bpf: Fix cross-compiling urandom_read

Linking of urandom_read and liburandom_read.so prefers LLVM's 'ld.lld' but falls back to using 'ld' if unsupported. However, this fallback discards any existing makefile macro for LD and can break cross-compilation.

Fix by changing the fallback to use the target linker $(LD), passed via '-fuse-ld=' using an absolute path rather than a linker "flavour".

Fixes 08c79c9cd67f ("selftests/bpf: Don't force lld on non-x86 architectures")
---
 tools/testing/selftests/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/Makefile +1 -1
index 5e366f2fc02a..f2a0f912e038 100644
@@ -263,7 +263,7 @@ $(OUTPUT)/%:%.c
 ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 riscv))
 LLD := lld
 else
-LLD := ld
+LLD := $(shell command -v $(LD))
 endif
 
 # Filter out -static for liburandom_read.so and its dependent targets so that static builds
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to bpf/bpf.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 8 Oct 2024 21:07:20 -0700 you wrote:

Linking of urandom_read and liburandom_read.so prefers LLVM's 'ld.lld' but falls back to using 'ld' if unsupported. However, this fallback discards any existing makefile macro for LD and can break cross-compilation.

Fix by changing the fallback to use the target linker $(LD), passed via '-fuse-ld=' using an absolute path rather than a linker "flavour".

[...]

Here is the summary with links:
- [bpf,v1] selftests/bpf: Fix cross-compiling urandom_read

    https://git.kernel.org/bpf/bpf/c/fd526e121c4d

You are awesome, thank you!

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