From patchwork Mon May 28 17:00:48 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: 10433865 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 2A1DF60327 for ; Mon, 28 May 2018 17:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ABEB283CF for ; Mon, 28 May 2018 17:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F235283D9; Mon, 28 May 2018 17:00:59 +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 B7F02283D1 for ; Mon, 28 May 2018 17:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932286AbeE1RA5 (ORCPT ); Mon, 28 May 2018 13:00:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36129 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932116AbeE1RA4 (ORCPT ); Mon, 28 May 2018 13:00:56 -0400 Received: by mail-wm0-f66.google.com with SMTP id v131-v6so14480194wma.1; Mon, 28 May 2018 10:00:55 -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=38FCC8pRqp7qE21cZab5pP5w3KHqlurfppaeEN9tazg=; b=rqP2U/ceziqO2iCXV4TJHUl3ORdmap8c5srFvMqsnewFHtA1n5bDHMHwSd+3bRVWSY oz7UQOY+XSNkNm/Sg4eKzpl9J2P4jCHsHQXbnfwW8UznQlKqtyicwF06tzMIwW2mLt1B IAih8dOsxwmE6zD1Jz9jUwbGu58lq2EU6h+BYRpK3ujf9rlyBA005zqmHglgqE4wmUu1 eLJqB4/IOkNIXZc0kmirCvvHrpS7jL50bitE1xGeMHK4+mQUs0IbHPkPOd8sPxQuIfk+ TeyJw6tC/i1MEV6tUniFMG6lslhSPo0bFuNez335/hOKic39A6u4fg8YtxM71fIQJq23 py2Q== 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=38FCC8pRqp7qE21cZab5pP5w3KHqlurfppaeEN9tazg=; b=C6LeZLfF5S+PqZ9Zi2KGkBRoL9iQ8QqRa/OIjOrNxPDse7eiAQrBzOJrutXM7eedAN u1iulIlwx7/C13QQgt752EXVT+XguJDKulE5s7rHmqAhY0iyj68ZoTQvARjPvVu5Disl SdGKZSQkfTKSiFIyt8/9OuXQfOTi6VfWyz81wlo4qEHgli3ls5Dx994fFN9OIGwCmV1P XBf94/REIsWP26jePknCUbgBPAb/Yz/Hr6XRQAC7MGHO+1QaD5jTlGY8DPKDhA78ybAa kDHOdhJ4KugB9aGBCDvIkdA89sbr1KL/lErn07VqtFq5ilFmr/9yCWjnAiP2nE6Nk3IM hppw== X-Gm-Message-State: ALKqPwcoUaCfIpb9x6A+hcr+4q/uiE1kW+P5/Nc2xxuwQeN2U/StNEOG N4C6+w9f5RZ8CPEp5yCByRg= X-Google-Smtp-Source: AB8JxZpLTPoKDoQ27OfKLQDaxw/hbPwtDmPh12xAQ1SohuMG3Fg6qOwRLul8PfTWAimbq8vEy8ZRxQ== X-Received: by 2002:a50:dc02:: with SMTP id q2-v6mr15723308edk.245.1527526854558; Mon, 28 May 2018 10:00:54 -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 d6-v6sm6368201edo.18.2018.05.28.10.00.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 10:00:53 -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] kbuild: add endianness flag to CHEKCFLAGS Date: Mon, 28 May 2018 19:00:48 +0200 Message-Id: <20180528170048.16595-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..057a278d2 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,-mlittle) + # 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