kbuild: tell sparse about the $ARCH
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Sat, 9 Nov 2019 12:12:16 +0000 (13:12 +0100)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 14 Nov 2019 15:13:23 +0000 (00:13 +0900)
Sparse uses the same executable for all archs and uses flags
like -m64, -mbig-endian or -D__arm__ for arch-specific parameters.
But Sparse also uses value from the host machine used to build
Sparse as default value for the target machine.

This works, of course, well for native build but can create
problems when cross-compiling, like defining both '__i386__'
and '__arm__' when cross-compiling for arm on a x86-64 machine.

Fix this by explicitely telling sparse the target architecture.

Reported-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Makefile

index 1d5298356ea8c75ce4441de8c373555ceea93b46..42bfda209cb82793fdb193be28e1626fe1164570 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -917,6 +917,9 @@ ifeq ($(CONFIG_RELR),y)
 LDFLAGS_vmlinux        += --pack-dyn-relocs=relr
 endif
 
+# make the checker run with the right architecture
+CHECKFLAGS += --arch=$(ARCH)
+
 # insure the checker run with the right endianness
 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)