kbuild: add machine size to CHECKFLAGS
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Wed, 30 May 2018 20:48:38 +0000 (22:48 +0200)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 1 Jun 2018 02:36:58 +0000 (11:36 +0900)
By default, sparse assumes a 64bit machine when compiled on x86-64
and 32bit when compiled on anything else.

This can of course create all sort of problems for the other archs, like
issuing false warnings ('shift too big (32) for type unsigned long'), or
worse, failing to emit legitimate warnings.

Fix this by adding the -m32/-m64 flag, depending on CONFIG_64BIT,
to CHECKFLAGS in the main Makefile (and so for all archs).
Also, remove the now unneeded -m32/-m64 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/alpha/Makefile
arch/arm/Makefile
arch/arm64/Makefile
arch/ia64/Makefile
arch/mips/Makefile
arch/parisc/Makefile
arch/sparc/Makefile
arch/x86/Makefile

index 68982ba7bc2f702b6cf4db2d8c368b6a48194c6d..2626de329e5f338295c356a4eb438cccc2a99c3c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -877,6 +877,9 @@ endif
 # insure the checker run with the right endianness
 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
 
+# the checker needs the correct machine size
+CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
+
 # 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 2cc3cc519c549a357052a2279b7f587ed8558c9d..c5ec8c09c0c6e444281707c5285485b537c9b360 100644 (file)
@@ -11,7 +11,7 @@
 NM := $(NM) -B
 
 LDFLAGS_vmlinux        := -static -N #-relax
-CHECKFLAGS     += -D__alpha__ -m64
+CHECKFLAGS     += -D__alpha__
 cflags-y       := -pipe -mno-fp-regs -ffixed-8
 cflags-y       += $(call cc-option, -fno-jump-tables)
 
index e4e537f27339f7a1574104a4b63ca62b1d65004d..f32a5468d79f04ce784685a81c5df9952278c1a6 100644 (file)
@@ -135,7 +135,7 @@ endif
 KBUILD_CFLAGS  +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
 KBUILD_AFLAGS  +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
 
-CHECKFLAGS     += -D__arm__ -m32
+CHECKFLAGS     += -D__arm__
 
 #Default value
 head-y         := arch/arm/kernel/head$(MMUEXT).o
index 87f7d2f9f17c266fee66973f29b6efd6c0590a71..3c353b4715dc462ef26bc3bb1ad00af684cd3bc5 100644 (file)
@@ -78,7 +78,7 @@ LDFLAGS               += -maarch64linux
 UTS_MACHINE    := aarch64
 endif
 
-CHECKFLAGS     += -D__aarch64__ -m64
+CHECKFLAGS     += -D__aarch64__
 
 ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
 KBUILD_LDFLAGS_MODULE  += -T $(srctree)/arch/arm64/kernel/module.lds
index 2dd7f519ad0b9832f335430836dde7671b123390..45f59808b8429e2abe7c0ffc4c895c6de03474bf 100644 (file)
@@ -18,7 +18,7 @@ READELF := $(CROSS_COMPILE)readelf
 
 export AWK
 
-CHECKFLAGS     += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
+CHECKFLAGS     += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
 
 OBJCOPYFLAGS   := --strip-all
 LDFLAGS_vmlinux        := -static
index 5e9fce076ab6896bbcd7faf7c4e30611b6e65f5e..e2122cca4ae2ea3a5e383411a872848e1fcc56a7 100644 (file)
@@ -309,9 +309,6 @@ ifdef CONFIG_MIPS
 CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
        egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
        sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
-ifdef CONFIG_64BIT
-CHECKFLAGS             += -m64
-endif
 endif
 
 OBJCOPYFLAGS           += --remove-section=.reginfo
index 348ae4779f327286a6d229f1d59c744b36577f66..714284ea6cc214f1011c6e0593f5ad2b0c962ddc 100644 (file)
@@ -28,7 +28,7 @@ export LIBGCC
 
 ifdef CONFIG_64BIT
 UTS_MACHINE    := parisc64
-CHECKFLAGS     += -D__LP64__=1 -m64
+CHECKFLAGS     += -D__LP64__=1
 CC_ARCHES      = hppa64
 LD_BFD         := elf64-hppa-linux
 else # 32-bit
index edac927e4952347555fe6b60543d6ebf105088c9..966a13d2b127e7c4933aaf561d90f47a36a8a67d 100644 (file)
@@ -39,7 +39,7 @@ else
 # sparc64
 #
 
-CHECKFLAGS    += -D__sparc__ -D__sparc_v9__ -D__arch64__ -m64
+CHECKFLAGS    += -D__sparc__ -D__sparc_v9__ -D__arch64__
 LDFLAGS       := -m elf64_sparc
 export BITS   := 64
 UTS_MACHINE   := sparc64
index 60135cbd905c1d2e1c152b4045a9132997cdc89d..f0a6ea22429d7384d81f81e38fb39dbfc9e720ed 100644 (file)
@@ -94,7 +94,7 @@ ifeq ($(CONFIG_X86_32),y)
 else
         BITS := 64
         UTS_MACHINE := x86_64
-        CHECKFLAGS += -D__x86_64__ -m64
+        CHECKFLAGS += -D__x86_64__
 
         biarch := -m64
         KBUILD_AFLAGS += -m64