kbuild: add endianness flag to CHEKCFLAGS
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Mon, 28 May 2018 18:27:35 +0000 (20:27 +0200)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 29 May 2018 13:05:08 +0000 (22:05 +0900)
The kernel depends on macros like __BYTE_ORDER__,
__BIG_ENDIAN__ or __LITTLE_ENDIAN__.

OTOH, sparse doesn't know about the endianness of the kernel and
by default uses the same as the machine on which sparse was built.

Ensure that sparse can predefine the macros corresponding to
how the kernel was configured by adding -m{big,little}-endian
to CHECKFLAGS in the main Makefile (and so for all archs).
Also, remove the equivalent done in arch specific Makefiles.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Makefile
arch/openrisc/Makefile
arch/parisc/Makefile
arch/s390/Makefile

index 1617ab517819fff15f95b944ec25783cbbadb77e..68982ba7bc2f702b6cf4db2d8c368b6a48194c6d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -874,6 +874,9 @@ ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
 LDFLAGS_vmlinux        += $(call ld-option, -X,)
 endif
 
+# insure the checker run with the right endianness
+CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
+
 # Default kernel image to build when no specific target is given.
 # KBUILD_IMAGE may be overruled on the command line or
 # set in the environment
index cf88029628643b1120b15407eab08e50f44886fc..89076a66eee266d79782949f93a9cbba30371b1a 100644 (file)
@@ -25,7 +25,6 @@ LDFLAGS_vmlinux :=
 LIBGCC                 := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 KBUILD_CFLAGS  += -pipe -ffixed-r10 -D__linux__
-CHECKFLAGS     += -mbig-endian
 
 ifeq ($(CONFIG_OPENRISC_HAVE_INST_MUL),y)
        KBUILD_CFLAGS += $(call cc-option,-mhard-mul)
index 34ac503e28add6c2e47d0e90bf3230f06eab64ed..348ae4779f327286a6d229f1d59c744b36577f66 100644 (file)
@@ -22,7 +22,7 @@ KBUILD_IMAGE := vmlinuz
 KBUILD_DEFCONFIG := default_defconfig
 
 NM             = sh $(srctree)/arch/parisc/nm
-CHECKFLAGS     += -D__hppa__=1 -mbig-endian
+CHECKFLAGS     += -D__hppa__=1
 LIBGCC         = $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 export LIBGCC
 
index c79936d02f7bd428dd8c8d5d64012d1d10ace8bf..68a690442be052cd4eeaf565442c2b67e9367f74 100644 (file)
@@ -18,7 +18,7 @@ KBUILD_CFLAGS += -m64
 KBUILD_AFLAGS  += -m64
 UTS_MACHINE    := s390x
 STACK_SIZE     := 16384
-CHECKFLAGS     += -D__s390__ -D__s390x__ -mbig-endian
+CHECKFLAGS     += -D__s390__ -D__s390x__
 
 export LD_BFD