From patchwork Mon May 28 18:27:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10433955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17AF0602CC for ; Mon, 28 May 2018 18:27:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0870A2847D for ; Mon, 28 May 2018 18:27:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFD402848B; Mon, 28 May 2018 18:27:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0E782847D for ; Mon, 28 May 2018 18:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933194AbeE1S1n (ORCPT ); Mon, 28 May 2018 14:27:43 -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-Google-Smtp-Source: AB8JxZrNoUyReFDq+P2n8ImUmQlEqBcRz2BKz+RkPufVXPF/4TtRMXaclUCDM1U9XZsxNVGHTknqbw== 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-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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