[v2,2/2] sparc: pass endianness info to sparse

Message ID 20171109061652.14948-3-luc.vanoostenryck@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • sparc: pass endianness info to sparse
Related show

Commit Message

Luc Van Oostenryck Nov. 9, 2017, 6:16 a.m.
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 <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 arch/sparc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Nov. 9, 2017, 8:34 a.m. | #1
On Thu, Nov 09, 2017 at 07:16:52AM +0100, Luc Van Oostenryck wrote:
> 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.

You're posted patches for this for about half a dozen architectures
now, but we also now have generic Kconfig symbols for the byte order.

I'd much rather see this done in generic code than hacking it up
everywhere.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luc Van Oostenryck Nov. 9, 2017, 1:13 p.m. | #2
On Thu, Nov 9, 2017 at 9:34 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Thu, Nov 09, 2017 at 07:16:52AM +0100, Luc Van Oostenryck wrote:
>> 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.
>
> You're posted patches for this for about half a dozen architectures
> now, but we also now have generic Kconfig symbols for the byte order.
>
> I'd much rather see this done in generic code than hacking it up
> everywhere.

OK, when I wrote these patch (in June, IIRC) there wasn't yet the
generic Kconfig symbol. I'll see what can now be generic and what
need to stay specific (for example, ARM need __ARME{L,B}__,
ARM64 & MIPS are in the same situation as are a few others archs).

-- Luc Van Oostenryck
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index a42aa114e..08d477faf 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -14,7 +14,7 @@  else
         KBUILD_DEFCONFIG := sparc64_defconfig
 endif
 
-CHECKFLAGS     += -D__sparc__
+CHECKFLAGS     += -D__sparc__ -mbig-endian
 
 ifeq ($(CONFIG_SPARC32),y)
 #####