Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2543310imm; Mon, 28 May 2018 10:05:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLyJCCRje0TS6hNi6lNkdBuvpe91NNuQwKT2SjWTA6t1SoiuDXSNaRXhE+3VicRINeu7lFC X-Received: by 2002:a17:902:bd8f:: with SMTP id q15-v6mr4736949pls.161.1527527146950; Mon, 28 May 2018 10:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527527146; cv=none; d=google.com; s=arc-20160816; b=W0ZC9Lsjw2TmDzgCmzebv0mYCXE9cLkn9SzQneDPKk22dFfKJtw94Q/7PN4XlGqR6M qlOfP5Bk5Ignc4r6Td1B4a4/Z0M4H/1LSlBaGwkOKTgtlUi0F8PX/wYx7Xi3YFTWT/6J 558miSVcISq4Aks7CfNfvwK0pPc6aGC6+MwkPqwLYn6wi2LchS8Hns7WcJgs6ov/lIZS qfdFfXMCb759Tp9be2bWPAFAU1xJJ+ph7eXZD18ZMKfcox4QfHaqiHX0nQ5rL8UNkWh7 UDx1+x5FmAXtwOB3iTdkjI4FAlOr1jinvbfQYnjmJYd7YcyxVviAwhmm1xzBLQle5bYt iUJw== 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=38FCC8pRqp7qE21cZab5pP5w3KHqlurfppaeEN9tazg=; b=r/MSusMISIta9KugDu1hAV0wLnPuLm98dXUIJGsRdCOQqvpfizFKZrcKmjjmcCh93x GAZel0XnfoxH7NAg+V2OPQ8VThdZOAo8LGu8EUO08e7AnHuHG/CCLzy+Tf81CYZF83qg RUg7p/081F7OkiEhMSJ5IaBlEX/Ch11Rb9oicDpbNvEKW4L6WYSPeclSxRdFoc96nB7c 18W1Pft143LwwXHfdocypMkTtWpf5+AxVaqJX7eh9BTmhR7P9GNx2k1e2wcjFU9yf0eg futvvxFUcV+mT08v/XjrSHXuchD9S4GtG/NxTzK5lf7uu4N8IXHY+yQVjm9QQOkta7z5 wT6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rqP2U/ce; 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 w187-v6si6279601pgb.11.2018.05.28.10.05.01; Mon, 28 May 2018 10:05:46 -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=rqP2U/ce; 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 S940407AbeE1RA6 (ORCPT + 99 others); Mon, 28 May 2018 13:00:58 -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-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-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..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 -- 2.17.0