Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2953380imm; Mon, 28 May 2018 20:49:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqa/m/0/Dkx16s0dH9eKJybe0iGrxHbn6OvGNRx6rLz5OQvJ0WcR0gjHDM4/RXalJsU4Sjr X-Received: by 2002:a17:902:b087:: with SMTP id p7-v6mr15955505plr.227.1527565751264; Mon, 28 May 2018 20:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527565751; cv=none; d=google.com; s=arc-20160816; b=t6iYGfAPN9F48vJxkYNRts/OqNM+ChUDnHZIyqOVxWljEDk/E5n5K4TxjO3o76NZkA 8xlAHip2lp0C7L/N9ouRJ4+dGhJlALFOQIwfVD01+nRtysnJex7NNEnlndvQsqIitIxr /KDZZN+JaFnJu845G8ULhxEGJ6i/EDi15LNQ67AccjrUZNEqi4rdl4kIhC0caZukeCqP nypaeX4xzLQR/kbxCmzAoMuxJH91bEp7eUlg9PzPw83VEk5F5nR6UTR8IcnfFpXMEQMx 3CBxOKT2NV//DRlkknsRNlP5sEsftVftaUSSjcD5BvX6d0u43qi1kQby7nQ8Ora9ZUvk 1+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yYJhQR9S2D01uvxvgSEbMB91y3F9/95k4xNYdlI/xZE=; b=FKwInJPv4tLJj1a6/oj74tQFhJrHQ7jen1QJW2Y4YoY725HrDotS2BHBMsPwf/W7gj UbJr2oskGDpfn6SjKd3yau+EbAGFq5F7Fx2KVM/We8qdEC3ug83Fd0wgnwsN5wfMk1T5 WS1bdYPCO2UuwD9qtiXUnktZv+7jCX22XouxUeA3gFuZv6+2Exjqw8TWOISjz0gkWOcA AJInhppdLAwTL9ymBrYyjG06x1Iz0PNYdXDkObNo8PFFuMVniQpe6BVntXxcmmPCiMmF 8F4RMShoQd4GYVkN8WUuxzjDoFmChuU6jvFvKZgC3Fhre4jWYelR2YUqgOIqr31TZS7+ F8Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kCgKOGuz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k139-v6si31848768pfd.97.2018.05.28.20.48.56; Mon, 28 May 2018 20:49:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kCgKOGuz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933237AbeE1S1q (ORCPT + 99 others); Mon, 28 May 2018 14:27:46 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55554 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755686AbeE1S1m (ORCPT ); Mon, 28 May 2018 14:27:42 -0400 Received: by mail-wm0-f67.google.com with SMTP id a8-v6so34135578wmg.5; Mon, 28 May 2018 11:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=yYJhQR9S2D01uvxvgSEbMB91y3F9/95k4xNYdlI/xZE=; b=kCgKOGuzo9ek9V9AnIn6R40KZYw9UIam4CwkCKVb8K0DIPSQMkd+JvTqiYW/MPXDgI nQ/NsrCa7DHUTTmJdpnhwr5sylP5FXQ6lJtNcVUPQT1VKCD2oxnVzND6T4LfhgSs3Iz5 gZ5b8JW7GaN8iBwtAt46VcvBmDXpg5d2VRXkzggOLGGVFrtL2gzEZCEz23bRQRVorbyI bwE4j+ZxtGiElg2BpgPGd+RZgYooXJOrO573XHqay6CguCWfCw/nVqAXEeGUeGuY0ChC s9z2DYcpDop/Q4xUPnxDW6d+6qnt2+Tjj+D8n9qcsjg13jr7NWziKKUzARCEh/sxhE44 Iwvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yYJhQR9S2D01uvxvgSEbMB91y3F9/95k4xNYdlI/xZE=; b=Ygt6UEtsnjYbZ7ZgJGou4FZiQDbT7D6LhFM6D7ByExfjS34bGr+ZGIUDcm9G9uSoJl cNhbX1gHaXGTZSWAcSCBk4P3dRxuclHU7OdY2MkWIoE5J0Z4CriQpHEucwDOVw+EWw/8 mE3CawdkwmBUsff4ak9PZLDSmeKE6gZzrsQ+sMiWgit608wx6xDQ7Fh+VMGU4tuoXg59 dJ5hn5HM1i0Ybl9tTeI35SWIITKzfJcnv8OSWV+YpvkrP2Hets715tvJ0ZL9+mjFD0X9 Ki/hP0omKhQes/8YHu2VYX2xZBZNh61Q/jTVF8smrEr8fGOJkZHqMdAdZXh7fhbrE9ch 9Ucg== X-Gm-Message-State: ALKqPwfgkz5T6SYic6XtRS3WvPx5Azn5JVefN6jf5oDgn08M822zhZ+C r2rPtI9XLuHv5Wea4SIE1n4= X-Received: by 2002:a50:8cc4:: with SMTP id r4-v6mr15880915edr.115.1527532060583; Mon, 28 May 2018 11:27:40 -0700 (PDT) Received: from localhost.localdomain (252.178-246-81.adsl-dyn.isp.belgacom.be. [81.246.178.252]) by smtp.gmail.com with ESMTPSA id q6-v6sm16449817edh.9.2018.05.28.11.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 11:27:40 -0700 (PDT) From: Luc Van Oostenryck To: Masahiro Yamada , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E . J . Bottomley" , Helge Deller , Martin Schwidefsky , Heiko Carstens Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, Luc Van Oostenryck Subject: [PATCH v2] kbuild: add endianness flag to CHEKCFLAGS Date: Mon, 28 May 2018 20:27:35 +0200 Message-Id: <20180528182735.18257-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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