Skip to contentSkip to conversation

sparc: pass endianness info to sparse

PATCH In review Luc Van Oostenryck 2 participants 3 messages Oct 31, 2017 – Nov 2, 2017 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: pass endianness info to sparse

sparc is big-endian only but sparse assumes the same endianness as the building machine.
This is problematic for code which expect __BYTE_ORDER__ being correctly predefined by the compiler which sparse can then pre-process differently from what gcc would, depending on the building machine endianness.

Fix this by letting sparse know about the architecture endianness.

To: David S. Miller <[email protected]>

---
 arch/sparc/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/sparc/Makefile +2 -0
index 8496a074b..ef1598f5a 100644
@@ -55,6 +55,8 @@ endif
 
 endif
 
+CHECKFLAGS     += -mbig-endian
+
 head-y                 := arch/sparc/kernel/head_$(BITS).o
 
 # See arch/sparc/Kbuild for the core part of the kernel
Signature · 1 line
2.14.0
#1 lore raw

Hi Luc.

Quoted 21 lines · Luc Van Oostenryck

sparc is big-endian only but sparse assumes the same endianness as the building machine.
This is problematic for code which expect __BYTE_ORDER__ being correctly predefined by the compiler which sparse can then pre-process differently from what gcc would, depending on the building machine endianness.

Fix this by letting sparse know about the architecture endianness.

To: David S. Miller <[email protected]>

---
 arch/sparc/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/sparc/Makefile +0 -0
index 8496a074b..ef1598f5a 100644

arch/sparc/Makefile endif · line 59

Quoted 5 lines
arch/sparc/Makefile +2 -0
@@ -55,6 +55,8 @@ endif
 
 endif
 
+CHECKFLAGS     += -mbig-endian
+

You have added a new assignment to CHECKFLAGS because this options is the same for sparc32 and sparc64, which is fine.

But could you then in the same patch
also move the assingmnet to -D__sparc__ this place, as this is also a common option for sparc32 and sparc64.
As it is after your patch we have common options duplicated (__sparc__) and in their own assignment (-mbig-endian).
This is inconsistent and may confuse the next reader.

Sam

#2 lore raw
In reply to Luc Van Oostenryck
Quoted 1 line · Sam Ravnborg

Hi Luc.

Hi,

Quoted 6 lines

arch/sparc/Makefile endif · line 59

Quoted 2 lines
arch/sparc/Makefile +2 -0
+CHECKFLAGS     += -mbig-endian
+

You have added a new assignment to CHECKFLAGS because this options is the same for sparc32 and sparc64, which is fine.

Quoted 6 lines

But could you then in the same patch
also move the assingmnet to -D__sparc__ this place, as this is also a common option for sparc32 and sparc64.
As it is after your patch we have common options duplicated (__sparc__) and in their own assignment (-mbig-endian).
This is inconsistent and may confuse the next reader.

Yes, I agree but it seems a bit strange to me to do that in the same patch. I suppose it doesn't matter much for such small patch, anyway.

-- Luc