linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: add endianness flag to CHEKCFLAGS
@ 2018-05-28 18:27 Luc Van Oostenryck
  2018-05-29 13:08 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Van Oostenryck @ 2018-05-28 18:27 UTC (permalink / raw)
  To: Masahiro Yamada, Jonas Bonn, Stefan Kristiansson, Stafford Horne,
	James E . J . Bottomley, Helge Deller, Martin Schwidefsky,
	Heiko Carstens
  Cc: Michal Marek, linux-kbuild, linux-kernel, openrisc, linux-parisc,
	linux-s390, Luc Van Oostenryck

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>
---
 Makefile               | 3 +++
 arch/openrisc/Makefile | 1 -
 arch/parisc/Makefile   | 2 +-
 arch/s390/Makefile     | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 56ba070df..6c6610913 100644
--- a/Makefile
+++ b/Makefile
@@ -878,6 +878,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
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index cf8802962..89076a66e 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -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)
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 34ac503e2..348ae4779 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -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
 
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index c79936d02..68a690442 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -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
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] kbuild: add endianness flag to CHEKCFLAGS
  2018-05-28 18:27 [PATCH v2] kbuild: add endianness flag to CHEKCFLAGS Luc Van Oostenryck
@ 2018-05-29 13:08 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2018-05-29 13:08 UTC (permalink / raw)
  To: Luc Van Oostenryck
  Cc: Jonas Bonn, Stefan Kristiansson, Stafford Horne,
	James E . J . Bottomley, Helge Deller, Martin Schwidefsky,
	Heiko Carstens, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List, openrisc, linux-parisc, linux-s390

2018-05-29 3:27 GMT+09:00 Luc Van Oostenryck <luc.vanoostenryck@gmail.com>:
> 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>
> ---


Applied to linux-kbuild. Thanks.


>  Makefile               | 3 +++
>  arch/openrisc/Makefile | 1 -
>  arch/parisc/Makefile   | 2 +-
>  arch/s390/Makefile     | 2 +-
>  4 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 56ba070df..6c6610913 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -878,6 +878,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
> diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
> index cf8802962..89076a66e 100644
> --- a/arch/openrisc/Makefile
> +++ b/arch/openrisc/Makefile
> @@ -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)
> diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
> index 34ac503e2..348ae4779 100644
> --- a/arch/parisc/Makefile
> +++ b/arch/parisc/Makefile
> @@ -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
>
> diff --git a/arch/s390/Makefile b/arch/s390/Makefile
> index c79936d02..68a690442 100644
> --- a/arch/s390/Makefile
> +++ b/arch/s390/Makefile
> @@ -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
>
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-29 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28 18:27 [PATCH v2] kbuild: add endianness flag to CHEKCFLAGS Luc Van Oostenryck
2018-05-29 13:08 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).