diff mbox series

selftests/mm: Fix cross compilation with LLVM

Message ID 20230614-kselftest-mm-llvm-v1-1-180523f277d3@kernel.org (mailing list archive)
State Handled Elsewhere
Headers show
Series selftests/mm: Fix cross compilation with LLVM | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next at HEAD d5e45e810e0e
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 6 and now 6
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Mark Brown June 14, 2023, 9:18 p.m. UTC
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.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/mm/Makefile | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)


---
base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
change-id: 20230614-kselftest-mm-llvm-a25a7daffa6f

Best regards,

Comments

Nick Desaulniers June 15, 2023, 9:01 p.m. UTC | #1
On Wed, Jun 14, 2023 at 5:19 PM Mark Brown <broonie@kernel.org> wrote:
>
> 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.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>

Broonie,
Thanks for the patch! What's the best way to test this?

$ ARCH=arm64 make LLVM=1 -j128 -C tools/testing/selfte
sts/mm/

Is what I would have guessed, but I get errors with or without this patch.

Also, fwiw, b4 shows that you don't have a pgp key setup for
broonie@kernel.org; I don't think it matters, but maybe it's a
surprise to you if you thought you had set that up,
$ b4 shazam https://lore.kernel.org/llvm/20230614-kselftest-mm-llvm-v1-1-180523f277d3@kernel.org/
...
  ✗ No key: openpgp/broonie@kernel.org


> ---
>  tools/testing/selftests/mm/Makefile | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
> index 23af4633f0f4..4f0c50c33ba7 100644
> --- a/tools/testing/selftests/mm/Makefile
> +++ b/tools/testing/selftests/mm/Makefile
> @@ -5,12 +5,15 @@ LOCAL_HDRS += $(selfdir)/mm/local_config.h $(top_srcdir)/mm/gup_test.h
>
>  include local_config.mk
>
> +ifeq ($(ARCH),)
> +
>  ifeq ($(CROSS_COMPILE),)
>  uname_M := $(shell uname -m 2>/dev/null || echo not)
>  else
>  uname_M := $(shell echo $(CROSS_COMPILE) | grep -o '^[a-z0-9]\+')
>  endif
> -MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
> +ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
> +endif
>
>  # Without this, failed build products remain, with up-to-date timestamps,
>  # thus tricking Make (and you!) into believing that All Is Well, in subsequent
> @@ -65,7 +68,7 @@ TEST_GEN_PROGS += ksm_tests
>  TEST_GEN_PROGS += ksm_functional_tests
>  TEST_GEN_PROGS += mdwe_test
>
> -ifeq ($(MACHINE),x86_64)
> +ifeq ($(ARCH),x86_64)
>  CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
>  CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
>  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)
>  endif
>  else
>
> -ifneq (,$(findstring $(MACHINE),ppc64))
> +ifneq (,$(findstring $(ARCH),ppc64))
>  TEST_GEN_PROGS += protection_keys
>  endif
>
>  endif
>
> -ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
> +ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
>  TEST_GEN_PROGS += va_high_addr_switch
>  TEST_GEN_PROGS += virtual_address_range
>  TEST_GEN_PROGS += write_to_hugetlbfs
> @@ -112,7 +115,7 @@ $(TEST_GEN_PROGS): vm_util.c
>  $(OUTPUT)/uffd-stress: uffd-common.c
>  $(OUTPUT)/uffd-unit-tests: uffd-common.c
>
> -ifeq ($(MACHINE),x86_64)
> +ifeq ($(ARCH),x86_64)
>  BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
>  BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
>
>
> ---
> base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
> change-id: 20230614-kselftest-mm-llvm-a25a7daffa6f
>
> Best regards,
> --
> Mark Brown <broonie@kernel.org>
>
>
Mark Brown June 15, 2023, 9:22 p.m. UTC | #2
On Thu, Jun 15, 2023 at 05:01:56PM -0400, Nick Desaulniers wrote:

> Broonie,
> Thanks for the patch! What's the best way to test this?
> 
> $ ARCH=arm64 make LLVM=1 -j128 -C tools/testing/selfte
> sts/mm/

> Is what I would have guessed, but I get errors with or without this patch.

make ARCH=arm64 LLVM=1 -C tools/testing/mm TARGETS=mm

> Also, fwiw, b4 shows that you don't have a pgp key setup for
> broonie@kernel.org; I don't think it matters, but maybe it's a
> surprise to you if you thought you had set that up,
> $ b4 shazam https://lore.kernel.org/llvm/20230614-kselftest-mm-llvm-v1-1-180523f277d3@kernel.org/
> ...
>   ✗ No key: openpgp/broonie@kernel.org

That's an issue on your/b4's end, my key has had an ID on it for
broonie@kernel.org for years (looks like back to 2011).  You probably
just don't have a copy of the key locally at all, the keyserver networks
are pretty borked.  keyring.debian.org should work.
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 23af4633f0f4..4f0c50c33ba7 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -5,12 +5,15 @@  LOCAL_HDRS += $(selfdir)/mm/local_config.h $(top_srcdir)/mm/gup_test.h
 
 include local_config.mk
 
+ifeq ($(ARCH),)
+
 ifeq ($(CROSS_COMPILE),)
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 else
 uname_M := $(shell echo $(CROSS_COMPILE) | grep -o '^[a-z0-9]\+')
 endif
-MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
+ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
+endif
 
 # Without this, failed build products remain, with up-to-date timestamps,
 # thus tricking Make (and you!) into believing that All Is Well, in subsequent
@@ -65,7 +68,7 @@  TEST_GEN_PROGS += ksm_tests
 TEST_GEN_PROGS += ksm_functional_tests
 TEST_GEN_PROGS += mdwe_test
 
-ifeq ($(MACHINE),x86_64)
+ifeq ($(ARCH),x86_64)
 CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
 CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
 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)
 endif
 else
 
-ifneq (,$(findstring $(MACHINE),ppc64))
+ifneq (,$(findstring $(ARCH),ppc64))
 TEST_GEN_PROGS += protection_keys
 endif
 
 endif
 
-ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
+ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
 TEST_GEN_PROGS += va_high_addr_switch
 TEST_GEN_PROGS += virtual_address_range
 TEST_GEN_PROGS += write_to_hugetlbfs
@@ -112,7 +115,7 @@  $(TEST_GEN_PROGS): vm_util.c
 $(OUTPUT)/uffd-stress: uffd-common.c
 $(OUTPUT)/uffd-unit-tests: uffd-common.c
 
-ifeq ($(MACHINE),x86_64)
+ifeq ($(ARCH),x86_64)
 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))