Skip to content

Commit 24f6505

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
selftests/bpf: Enforce no-ALU32 for test_progs-no_alu32
With the most recent Clang, alu32 is enabled by default if -mcpu=probe or -mcpu=v3 is specified. Use a separate build rule with -mcpu=v2 to enforce no ALU32 mode. Suggested-by: Yonghong Song <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a0d7da2 commit 24f6505

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ define CLANG_BPF_BUILD_RULE
163163
-c $1 -o - || echo "BPF obj compilation failed") | \
164164
$(LLC) -march=bpf -mcpu=probe $4 -filetype=obj -o $2
165165
endef
166+
# Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
167+
define CLANG_NOALU32_BPF_BUILD_RULE
168+
($(CLANG) $3 -O2 -target bpf -emit-llvm \
169+
-c $1 -o - || echo "BPF obj compilation failed") | \
170+
$(LLC) -march=bpf -mcpu=v2 $4 -filetype=obj -o $2
171+
endef
166172
# Similar to CLANG_BPF_BUILD_RULE, but using native Clang and bpf LLC
167173
define CLANG_NATIVE_BPF_BUILD_RULE
168174
($(CLANG) $3 -O2 -emit-llvm \
@@ -275,6 +281,7 @@ TRUNNER_BPF_LDFLAGS := -mattr=+alu32
275281
$(eval $(call DEFINE_TEST_RUNNER,test_progs))
276282

277283
# Define test_progs-no_alu32 test runner.
284+
TRUNNER_BPF_BUILD_RULE := CLANG_NOALU32_BPF_BUILD_RULE
278285
TRUNNER_BPF_LDFLAGS :=
279286
$(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
280287

0 commit comments

Comments
 (0)