Skip to content

Commit 0518dbe

Browse files
broonieakpm00
authored andcommitted
selftests/mm: fix cross compilation with LLVM
Currently the MM selftests attempt to work out the target architecture by using CROSS_COMPILE or otherwise querying the host machine, storing the target architecture in a variable called MACHINE rather than the usual ARCH though as far as I can tell (including for x86_64) the value is the same as we would use for architecture. When cross compiling with LLVM we don't need a CROSS_COMPILE as LLVM can support many target architectures in a single build so this logic does not work, CROSS_COMPILE is not set and we end up selecting tests for the host rather than target architecture. Fix this by using the more standard ARCH to describe the architecture, taking it from the environment if specified. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Albert Ou <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Tom Rix <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 823b37e commit 0518dbe

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tools/testing/selftests/mm/Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ LOCAL_HDRS += $(selfdir)/mm/local_config.h $(top_srcdir)/mm/gup_test.h
55

66
include local_config.mk
77

8+
ifeq ($(ARCH),)
9+
810
ifeq ($(CROSS_COMPILE),)
911
uname_M := $(shell uname -m 2>/dev/null || echo not)
1012
else
1113
uname_M := $(shell echo $(CROSS_COMPILE) | grep -o '^[a-z0-9]\+')
1214
endif
13-
MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
15+
ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
16+
endif
1417

1518
# Without this, failed build products remain, with up-to-date timestamps,
1619
# thus tricking Make (and you!) into believing that All Is Well, in subsequent
@@ -65,7 +68,7 @@ TEST_GEN_PROGS += ksm_tests
6568
TEST_GEN_PROGS += ksm_functional_tests
6669
TEST_GEN_PROGS += mdwe_test
6770

68-
ifeq ($(MACHINE),x86_64)
71+
ifeq ($(ARCH),x86_64)
6972
CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
7073
CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
7174
CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_program.c -no-pie)
@@ -87,13 +90,13 @@ TEST_GEN_PROGS += $(BINARIES_64)
8790
endif
8891
else
8992

90-
ifneq (,$(findstring $(MACHINE),ppc64))
93+
ifneq (,$(findstring $(ARCH),ppc64))
9194
TEST_GEN_PROGS += protection_keys
9295
endif
9396

9497
endif
9598

96-
ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
99+
ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
97100
TEST_GEN_PROGS += va_high_addr_switch
98101
TEST_GEN_PROGS += virtual_address_range
99102
TEST_GEN_PROGS += write_to_hugetlbfs
@@ -112,7 +115,7 @@ $(TEST_GEN_PROGS): vm_util.c
112115
$(OUTPUT)/uffd-stress: uffd-common.c
113116
$(OUTPUT)/uffd-unit-tests: uffd-common.c
114117

115-
ifeq ($(MACHINE),x86_64)
118+
ifeq ($(ARCH),x86_64)
116119
BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
117120
BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
118121

0 commit comments

Comments
 (0)