Skip to content

Commit

Permalink
kbuild: add endianness flag to CHEKCFLAGS
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
lucvoo authored and masahir0y committed May 29, 2018
1 parent 59f7b58 commit 1451676
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion arch/s390/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1451676

Please sign in to comment.