Skip to content

Commit 5506b7d

Browse files
eddyz87Alexei Starovoitov
authored andcommitted
selftests/bpf: make BPF_TARGET_ENDIAN non-recursive to speed up *.bpf.o build
BPF_TARGET_ENDIAN is used in CLANG_BPF_BUILD_RULE and co macros. It is defined as a recursively expanded variable, meaning that it is recomputed each time the value is needed. Thus, it is recomputed for each *.bpf.o file compilation. The variable is computed by running a C compiler in a shell. This significantly hinders parallel build performance for *.bpf.o files. This commit changes BPF_TARGET_ENDIAN to be a simply expanded variable. # Build performance stats before this commit $ git clean -xfd; time make -j12 real 1m0.000s ... # Build performance stats after this commit $ git clean -xfd; time make -j12 real 0m43.605s ... Signed-off-by: Eduard Zingerman <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent f4f25b6 commit 5506b7d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,10 @@ $(shell $(1) $(2) -dM -E - </dev/null | grep -E 'MIPS(EL|EB)|_MIPS_SZ(PTR|LONG)
461461
endef
462462

463463
# Determine target endianness.
464-
IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \
464+
IS_LITTLE_ENDIAN := $(shell $(CC) -dM -E - </dev/null | \
465465
grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
466-
MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
467-
BPF_TARGET_ENDIAN=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
466+
MENDIAN:=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
467+
BPF_TARGET_ENDIAN:=$(if $(IS_LITTLE_ENDIAN),--target=bpfel,--target=bpfeb)
468468

469469
ifneq ($(CROSS_COMPILE),)
470470
CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))

0 commit comments

Comments
 (0)