Skip to contentSkip to conversation

riscv: add riscv-specific predefines to CHECKFLAGS

PATCH In review Luc Van Oostenryck 2 participants 2 messages May 31, 2018 – Jun 5, 2018 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: add riscv-specific predefines to CHECKFLAGS

RISC-V uses the macro __riscv_xlen, predefined by GCC, to make the distinction between 32 or 64 bit code.

However, sparse doesn't know anything about this macro which lead to wrong warnings and failures.

Fix this by adding a define of __riscv_xlen to CHECKFLAGS and add one for __riscv too.

---
 arch/riscv/Makefile | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/Makefile +3 -0
index 76e958a54..6d4a5f6c3 100644
@@ -71,6 +71,9 @@ KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
 # architectures.  It's faster to have GCC emit only aligned accesses.
 KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
 
+# arch specific predefines for sparse
+CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
+
 head-y := arch/riscv/kernel/head.o
 
 core-y += arch/riscv/kernel/ arch/riscv/mm/
Signature · 1 line
2.17.1
#1 lore raw
Quoted 19 lines · luc.vanoostenryck at gmail.com

RISC-V uses the macro __riscv_xlen, predefined by GCC, to make the distinction between 32 or 64 bit code.

However, sparse doesn't know anything about this macro which lead to wrong warnings and failures.

Fix this by adding a define of __riscv_xlen to CHECKFLAGS and add one for __riscv too.

---
 arch/riscv/Makefile | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/Makefile +0 -0
index 76e958a54..6d4a5f6c3 100644

arch/riscv/Makefile KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) · line 79

Quoted 9 lines
arch/riscv/Makefile +3 -0
@@ -71,6 +71,9 @@ KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
 # architectures.  It's faster to have GCC emit only aligned accesses.
 KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
 
+# arch specific predefines for sparse
+CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
+
 head-y := arch/riscv/kernel/head.o
 
 core-y += arch/riscv/kernel/ arch/riscv/mm/

Thanks!