[PATCH 2/2] riscv: pass machine size to sparse

From: Luc Van Oostenryck
Date: Thu Nov 09 2017 - 00:56:25 EST


By default, sparse assumes a 64bit machine when compiled on x86-64
and 32bit when compiled on anything else.

This can of course create all sort of problems when this doesn't
correspond to the target's machine size, like issuing false
warnings like: 'constant ... is so big it is unsigned long long'
or 'shift too big (32) for type unsigned long' when the architecture
is 64bit while sparse was compiled on a 32bit machine, or worse,
to not emit legitimate warnings in the reverse situation.

Fix this by passing the appropriate -m32/-m64 flag to sparse.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
arch/riscv/Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 206484dde..a0ea7a71d 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -27,6 +27,7 @@ ifeq ($(CONFIG_ARCH_RV64I),y)
KBUILD_AFLAGS += -mabi=lp64
KBUILD_MARCH = rv64im
LDFLAGS += -melf64lriscv
+ CHECKFLAGS += -m64
else
BITS := 32
UTS_MACHINE := riscv32
@@ -35,6 +36,7 @@ else
KBUILD_AFLAGS += -mabi=ilp32
KBUILD_MARCH = rv32im
LDFLAGS += -melf32lriscv
+ CHECKFLAGS += -m32
endif

KBUILD_CFLAGS += -Wall
--
2.14.0